简体   繁体   English

如何在 Linux 上读取 USB 设备的二进制设备对象存储 (BOS) 描述符

[英]How to read Binary Device Object Store (BOS) descriptor of USB Device on Linux

I need to programmatically read device descriptors of a USB device plugged into a Linux system (Ubuntu 18.04).我需要以编程方式读取插入 Linux 系统(Ubuntu 18.04)的 USB 设备的设备描述符。 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/ .我可以通过解析lsusb输出或直接从/sys/bus/usb/devices/处的usbfs文件读取我需要的大部分描述符(iSerial、iProduct 等)。 However I'm having trouble finding the Binary Device Object Store (BOS) descriptor using either method.但是,我无法使用任一方法查找二进制设备对象存储 (BOS) 描述符。

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.我想我可以使用libusb查询 BOS,但似乎因为这是 USB 规范标准描述符,所以可能有更简单的方法。 Is possible read it directly from the usbfs , or query it from a standard utility tool like lsusb or other?是否可以直接从usbfs读取它,或者从lsusb或其他标准实用工具中查询它?

BOS descriptor can be get through control transfer. BOS 描述符可以通过控制传输获得。 The control transfer parameters are:控制传输参数为:

bmRequestType: 0x80, bRequest: 0x06, wValue: 0x0F00, wIndex: 0x0000, bmRequestType: 0x80, bRequest: 0x06, wValue: 0x0F00, wIndex: 0x0000,

The header BOS descriptor is:头 BOS 描述符是:

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.我们也可以使用https://github.com/libusb/libusb/blob/master/examples/xusb.c来获取 BOS 描述符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM