22 if ((vendor == 0x1589) && (product == 0xa101) ) {
37 ssize_t device_count, i;
39 struct libusb_device_descriptor descriptor;
47 device_count = libusb_get_device_list(
usb_context, &list);
50 for (i = 0; i < device_count; i++) {
52 if (0 == libusb_get_device_descriptor(list[i], &descriptor)) {
59 libusb_free_device_list(list, 1);
68 struct libusb_device_descriptor *descriptor,
AR_DWORD dwNumDevice) {
71 for (i = 0; i < list_count; i++) {
73 if (0 == libusb_get_device_descriptor(list[i], descriptor)) {
89 ssize_t device_count, i;
91 struct libusb_device_descriptor descriptor;
93 libusb_device_handle *device_handle;
102 device_count = libusb_get_device_list(
usb_context, &list);
108 if (libusb_open(list[i], &device_handle) != 0 ) {
112 if (0 > libusb_get_string_descriptor_ascii(
117 if (0 > libusb_get_string_descriptor_ascii(
124 libusb_close(device_handle);
128 libusb_free_device_list(list, 1);
134 return libusb_control_transfer(device_handle,
145 ssize_t device_count, i;
146 libusb_device **list;
147 struct libusb_device_descriptor descriptor;
157 device_count = libusb_get_device_list(
usb_context, &list);
163 if (0 != libusb_open(list[i], device_handle) ) {
166 if (0 != libusb_claim_interface(*device_handle, 0) ) {
171 libusb_free_device_list(list, 1);
188 if (0 != libusb_release_interface(device_handle, 0) ) {
191 libusb_close(device_handle);
216 result = libusb_bulk_transfer(device_handle, 0x82, buffer,
sizeof(buffer), &transferred,
libusb_ReadTimeout);
219 result = libusb_bulk_transfer(device_handle, 0x02, wBuffer, dwNumBytesToWrite, &transferred,
libusb_WriteTimeout);
222 printf(
"sent: %d (%d) result %d '%s'\n", transferred, (
int)dwNumBytesToWrite, result, (
char *)wBuffer);
229 result = libusb_bulk_transfer(device_handle, 0x82, rBuffer, dwNumBytesToRead, &transferred,
libusb_ReadTimeout);
232 printf(
"received: %d (%d) result %d - %s\n", transferred, (
int)dwNumBytesToRead, result, (
char *)rBuffer);