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:
struct usb_bos_descriptor_header {
u8_t bLength;
u8_t bDescriptorType;
u16_t wTotalLength;
u8_t bNumDeviceCaps;
};
We can also use https://github.com/libusb/libusb/blob/master/examples/xusb.c to get BOS descriptor.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.