I need to programmatically read device descriptors of a USB device plugged into a Linux system (Ubuntu 18.04). I can read most of the descriptors I need (iSerial, iProduct, etc) by parsing lsusb output, or by reading directly from the usbfs files at /sys/bus/usb/devices/. However I'm having trouble finding the Binary Device Object Store (BOS) descriptor using either method.
I imagine I can query the BOS using libusb but it seems like since this is a USB spec standard descriptor, there may be a simpler way. Is possible read it directly from the usbfs, or query it from a standard utility tool like lsusb or other?
BOS descriptor can be get through control transfer. The control transfer parameters are:
bmRequestType: 0x80, bRequest: 0x06, wValue: 0x0F00, wIndex: 0x0000,
The header BOS descriptor is:
We can also use https://github.com/libusb/libusb/blob/master/examples/xusb.c to get BOS descriptor.