Tizen Native API
7.0
|
This module provides an API for raw access to USB devices.
Required Header
#include <usb_host.h>
Overview
USB host API provides direct access to USB devices. Applications with user confirmation can get access to external USB devices, which include card readers, NFC readers, printers, and QR code readers. Before using it, become familiar with USB protocol specification. Note that this API is created for *host* mode USB, i.e. communication with connected devices.
Before using any of usb_host API functions you must initialize API context. Also you must cleanup context after using USB host API.
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 List.
Functions | |
int | usb_host_create (usb_host_context_h *ctx) |
Initializes usb_host context. | |
int | usb_host_destroy (usb_host_context_h ctx) |
Deinitializes usb_host context. | |
Typedefs | |
typedef struct usb_host_context_s * | usb_host_context_h |
Context handle to USB host. |
Typedef Documentation
typedef struct usb_host_context_s* usb_host_context_h |
Context handle to USB host.
This structure represents usb_host session. Using own session allows to use this API independently. For example calling usb_host_destroy() will not destroy resources that are being used by another user of the library.
To create session there is need to call usb_host_create(), to destroy call usb_host_destroy(). Each session created by usb_host_create() has to be destroyed using usb_host_destroy()
- Since :
- 3.0
Enumeration Type Documentation
enum usb_host_error_e |
Enumeration of error codes reported by USB host API.
- Since :
- 3.0
- Enumerator:
Function Documentation
int usb_host_create | ( | usb_host_context_h * | ctx | ) |
Initializes usb_host context.
This function must be called before any other function from this module.
- Since :
- 3.0
- Remarks:
- ctx should be destroyed by calling usb_host_destroy() when no longer needed.
- Parameters:
-
[out] ctx Context pointer
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
USB_HOST_ERROR_OUT_OF_MEMORY Out of memory USB_HOST_ERROR_INVALID_PARAMETER Invalid parameter was passed USB_HOST_ERROR_NONE Successful
- Postcondition:
- usb_host_destroy() should be called to free resources allocated for ctx by this function.
int usb_host_destroy | ( | usb_host_context_h | ctx | ) |
Deinitializes usb_host context.
This function must be called after closing all devices and before application close. It has to be called to clean the memory used by library.
- Since :
- 3.0
- Parameters:
-
[in] ctx Context to deinitialize
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
USB_HOST_ERROR_NONE Success USB_HOST_ERROR_INVALID_PARAMETER Invalid parameter was passed
- Precondition:
- Context must be initialized by usb_host_create().