-
Notifications
You must be signed in to change notification settings - Fork 6
USB API
Ankur Yadav edited this page Aug 25, 2015
·
6 revisions
#USB API
This page contains native API functions for accessing USB of beaglebone black. Code of this API can be found in usb.c. Sample JNI wrapper functions can be found here. Sample application for USB can be found here. Note : _This API using libusb library. It is only to demonstrate how libusb can be used, it does not contain all functionalities of libusb. _
###CAN API functions description
- ssize_t usbInit() : It creates USB session and gets number of USB devices attached and then returns number of USB devices attached.
Returns : If successful then number of USB devices attached is returned and if it fails then -1 is returned.
Example :
int count = usbInit(); // It creates USB session and returns number of usb devices attached.
- int usbGetDevices(int ids[][8], unsigned char strings[][3][256]) : This function takes one 2D array to store IDs (bus, device, manufacturer and vendor) for each USB device and one 3D array to store path, manufacturer descriptor and vendor descriptor. It returns 0 if successful and -1 if it fails. It is only to demonstrate and develop lsusb kind of app. Similar functions can be made using libusb for other functionalities of USB.
Returns : 0 if successful and -1 if it fails.
Example :
int ids[][] = new int[count][8];
byte strings[][][] = new byte[count][3][256];
int ret = usbGetDevices(ids, strings); // It stores usb ids in ids array and description strings in strings array.
- void usbClose() : This function is used to close USB devices.
Example :
usbClose(); // It closes usb session.
###Screenshot of USB android application