2

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?

mofahead
  • 21
  • 2

1 Answers1

1

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.

Yihui Xiong
  • 531
  • 1
  • 4
  • 6