Tizen Native API
5.5
|
This API is used to perform synchronous operations.
Overview
A transfer is performed by single function call which returns after transfer was finished. Before transferring, you must select proper endpoint. Then you can perform transfer operations on it:
int transferred; usb_host_config_h cfg; usb_host_interface_h iface; usb_host_endpoint_h ep; usb_host_device_get_config(dev, cfg_index, &cfg); usb_host_config_get_interface(cfg, interface_number, &iface); usb_host_interface_get_endpoint(iface, ep_number, &ep); ret = usb_host_transfer(ep, data, length, &transfered, 0); if (ret < 0) error();
In this example data buffer contains data received from device. Value of transfered is set to the number of received bytes.
Related Features
This API is related with the following features:
- http://tizen.org/feature/usb.host
It is recommended to design feature related codes in your application for reliability.
You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from Feature Element.
Functions | |
int | usb_host_control_transfer (usb_host_device_h dev, uint8_t bm_request_type, uint8_t b_request, uint16_t w_value, uint16_t w_index, unsigned char *data, uint16_t w_length, unsigned int timeout, int *transferred) |
Performs USB control transfer. | |
int | usb_host_transfer (usb_host_endpoint_h ep, unsigned char *data, int length, int *transferred, unsigned int timeout) |
Performs transfer on given endpoint. |
Function Documentation
int usb_host_control_transfer | ( | usb_host_device_h | dev, |
uint8_t | bm_request_type, | ||
uint8_t | b_request, | ||
uint16_t | w_value, | ||
uint16_t | w_index, | ||
unsigned char * | data, | ||
uint16_t | w_length, | ||
unsigned int | timeout, | ||
int * | transferred | ||
) |
Performs USB control transfer.
For more explanation about the values please refer to USB protocol specification
- Since :
- 3.0
- Remarks:
- The wValue, wIndex and wLength fields values should be given in host-endian byte order.
- Parameters:
-
[in] dev Device handle [in] bm_request_type bmRequestType type field for the setup packet [in] b_request bRequest field for the setup packet [in] w_value wValue field for the setup packet [in] w_index wIndex field for the setup packet [in] data Suitably-sized data buffer for either input or output (depending on direction bits within bmRequestType) [in] w_length wLength field for the setup packet. The data buffer should be at least this size [in] timeout Timeout (in milliseconds) that this function should wait before giving up due to no response being received. For an unlimited [out] transferred Number of transferred bytes timeout, 0 value should be used.
- Returns:
- 0 on success, negative error code otherwise
- Return values:
-
USB_HOST_ERROR_NONE Successful USB_HOST_ERROR_TIMED_OUT Transfer timed out USB_HOST_ERROR_BROKEN_PIPE Control request was not supported by the device USB_HOST_ERROR_NO_SUCH_DEVICE The device has been disconnected USB_HOST_ERROR_INVALID_PARAMETER Invalid parameter was passed USB_HOST_ERROR_NOT_SUPPORTED Not supported USB_HOST_ERROR_DEVICE_NOT_OPENED The device was not opened USB_HOST_ERROR_OVERFLOW Device offered more data
- Precondition:
- dev must point to device opened by usb_host_device_open() or usb_host_device_open_with_vid_pid()
int usb_host_transfer | ( | usb_host_endpoint_h | ep, |
unsigned char * | data, | ||
int | length, | ||
int * | transferred, | ||
unsigned int | timeout | ||
) |
Performs transfer on given endpoint.
Performs a USB transfer on given endpoint. Direction of transfer is determined by the endpoint.
- Since :
- 3.0
- Parameters:
-
[in] ep Endpoint handle [in] data Suitably-sized data buffer for either input or output (depending on endpoint) [in] length For writes, the number of bytes from data to be sent, for reads the maximum number of bytes to receive into the data buffer [out] transferred number of bytes actually transferred [in] timeout Timeout (in milliseconds) that this function should wait before giving up due to no response being received (for an unlimited timeout 0 value should be used)
- Returns:
- 0 on success (and populates transferred), negative error code on error
- Return values:
-
USB_HOST_ERROR_NONE Successful USB_HOST_ERROR_TIMED_OUT Transfer timed out USB_HOST_ERROR_BROKEN_PIPE Endpoint halted USB_HOST_ERROR_OVERFLOW Device offered more data USB_HOST_ERROR_NO_SUCH_DEVICE Device has been disconnected USB_HOST_ERROR_INVALID_PARAMETER Invalid parameter was passed USB_HOST_ERROR_NOT_SUPPORTED Not supported USB_HOST_ERROR_DEVICE_NOT_OPENED The device was not opened
- Precondition:
- ep must be a valid endpoint received from usb_host_interface_get_endpoint().
- ep must be an endpoint of device opened by usb_host_device_open() or usb_host_device_open_with_vid_pid().