How can I find out which USB configuration of a USB device is the current active one? I use libusb 0.1 (Not the newer 1.0 because I need libusb-win32) and there is only a usb_set_configuration() function but no usb_get_configuration开发者_开发技巧(). Maybe the configuration value of the active configuration can be read from some descriptor?
You are right, libusb-win32 curiously doesn't export such a method. However, there's a USB request for that, and you can easily make it yourself -- just scroll to line 106 in libusb-win32/src/windows.c.
Basically, this is what you want to do:
#define LIBUSB_DEFAULT_TIMEOUT 5000
char config;
int ret = usb_control_msg(dev, USB_RECIP_DEVICE | USB_ENDPOINT_IN,
USB_REQ_GET_CONFIGURATION, 0, 0, &config, 1,
LIBUSB_DEFAULT_TIMEOUT);
精彩评论