1
0
mirror of git://projects.qi-hardware.com/f32xbase.git synced 2024-11-23 22:35:20 +02:00

lib/usb.c (open_usb): libusb documentation claims that considerable

bureaucracy is needed before operations can be performed. This doesn't
seem to be the case, but let's put the code (commented out) anyway,
since it's been written. (This was done while trying to debug another
problem.)
This commit is contained in:
Werner Almesberger 2010-08-24 21:09:22 -03:00
parent fd09655773
commit a77a9a611f

View File

@ -26,6 +26,10 @@ usb_dev_handle *open_usb(uint16_t default_vendor, uint16_t default_product)
{
const struct usb_bus *bus;
struct usb_device *dev;
usb_dev_handle *handle;
#ifdef DO_FULL_USB_BUREAUCRACY
int res;
#endif
usb_init();
usb_find_busses();
@ -39,7 +43,30 @@ usb_dev_handle *open_usb(uint16_t default_vendor, uint16_t default_product)
if (dev->descriptor.idProduct !=
product ? product : default_product)
continue;
return usb_open(dev);
handle = usb_open(dev);
#ifdef DO_FULL_USB_BUREAUCRACY
if (!handle)
return NULL;
res = usb_set_configuration(handle, 1);
if (res < 0) {
fprintf(stderr, "usb_set_configuration: %d\n",
res);
return NULL;
}
res = usb_claim_interface(handle, 0);
if (res < 0) {
fprintf(stderr, "usb_claim_interface: %d\n",
res);
return NULL;
}
res = usb_set_altinterface(handle, 0);
if (res < 0) {
fprintf(stderr, "usb_set_altinterface: %d\n",
res);
return NULL;
}
#endif
return handle;
}
return NULL;
}