本片博客是基于对韦东山老师的USB相关学习视频、《USB2.0》、《MindShare USB 3.0 Technology》、《vdocuments.mx_universal-serial-bus-system-architecture》的学习总结,主要是借鉴了韦东山老师的学习笔记。

USB学习3-USB描述符

  • 1. USB设备状态切换图
  • 2. 标准设备请求
    • 2.1 SETUP事务的数据格式
    • 2.2 标准设备请求
    • 2.2 设备/配置/接口/端点
  • 3. 描述符
    • 3.1 设备描述符
    • 3.2 设备限定符(Device_Qualifier)
    • 3.3 配置描述符
    • 3.4 Other_Speed_Configuration:其他速度配置
    • 3.5 接口描述符
    • 3.6 端点描述符
    • 3.7 字符串描述符(String)
    • 3.6 示例
  • 4. 设备枚举过程示例

1. USB设备状态切换图


2. 标准设备请求

2.1 SETUP事务的数据格式

Host使用控制传输来识别设备、设置设备地址、启动设备的某些特性,对于控制传输,它首先发出"setup事务",如下:

在"setup事务"中,

  • SETUP令牌包:用来通知设备,“要开始传输了”
  • DATA0数据包:它含有固定的格式,用来告诉设备"是读还是写"、“读什么”、“写什么”
    Hos通过DATA0数据包发送8字节数据给设备,它的格式如下图所示:

2.2 标准设备请求

控制传输的建立事务中,可以使用下列格式的数据:

上表中各个"宏"取值如下:

2.2 设备/配置/接口/端点

在SETUP事务的数据里,表示了要访问的是什么:Device?Interface?Endpoint?
对于一个USB设备,它可以多种配置(Configuration)。比如4G上网卡就有2种配置:U盘、上网卡。第1次把4G上网卡插入电脑时,它是一个U盘,可以按照里面的程序。装好程序后,把它再次插入电脑,它就是一个上网卡。驱动程序可以选择让它工作于哪种配置,同一时间只能有一种配置。大多数的USB设备只有一种配置。
一个配置下,可以有多个接口(Interface),接口等同于功能(Function)。比如USB耳机有两个接口(功能):声音收发、按键控制。
一个接口,可能有多个设置(Setting),比如默认设置下它使用较低的带宽,可以选择其他设置以使用更高带宽。
一个接口,由一个或多个端点(Endpoint)组成。端点0属于整个设备的,端点0是双向的。接口还可以有其他端点,这些端点是单向的,要么是批量(Bulk)端点、要么是中断(Interrupt)端点、要么是同步(Isochronous)端点。

3. 描述符

怎么描述设备、配置、接口、端点?使用描述符(Descriptors),有设备描述符、配置描述符、接口描述符、端点描述符。所谓描述符,就是一些格式化的数据,用来描述信息。
一个USB设备,

  • 只有一个设备描述符:用来表示设备的ID、它有多少个配置、它的端点0一次最大能传输多少字节数据
  • 可能有多个配置描述符:用来表示它有多少个接口、供电方式、最大电流
  • 一个配置描述符下面,可能有多个接口描述符:用来表示它是哪类接口、有几个设置(Setting)、有几个端点
  • 一个接口描述符符下面,可能有多个端点描述符:用来表示端点号、方向(IN/OUT)、类型(批量/中断/同步)

还有一些字符串描述符(String descriptors),它用可读的文字来描述设备,是可选的。

3.1 设备描述符

3.2 设备限定符(Device_Qualifier)

The device_qualifier descriptor describes information about a high-speed capable device that would change if the device were operating at the other speed. For example, if the device is currently operating at full-speed, the device_qualifier returns information about how it would operate at high-speed and vice-versa. Table 9-9 shows the fields of the device_qualifier descriptor.
device_限定符描述符描述了有关高速能力设备的信息,如果设备以其他速度运行,该设备将会发生变化。例如,如果设备当前全速运行,设备限定符返回有关高速运行的信息,反之亦然。表9-9显示了device_限定符描述符的字段。

3.3 配置描述符

3.4 Other_Speed_Configuration:其他速度配置

The other_speed_configuration descriptor shown in Table 9-11 describes a configuration of a highspeed capable device if it were operating at its other possible speed. The structure of the other_speed_configuration is identical to a configuration descriptor.
表9-11中所示的另一个速度配置描述符描述了一个高速能力设备的配置,如果它以其他可能的速度运行。Other_Speed_Configuration的结构与配置描述符相同。

3.5 接口描述符

3.6 端点描述符

3.7 字符串描述符(String)

String descriptors are optional. As noted previously, if a device does not support string descriptors, all references to string descriptors within device, configuration, and interface descriptors must be reset to zero.
字符串描述符是可选的。如前所述,如果设备不支持字符串描述符,则在设备、配置和接口描述符中对字符串描述符的所有引用都必须重置为零。
The strings in a USB device may support multiple languages. When requesting a string descriptor, the requester specifies the desired language using a sixteenbit language ID (LANGID) defined by the USB-IF. The list of currently defined USB LANGIDs can be found at http://www.usb.org/developers/docs.html. String index zero for all languages returns a string descriptor that contains an array of two-byte LANGID codes supported by the device. Table 9-15 shows the LANGID code array. A USB device may omit all string descriptors. USB devices that omit all string descriptors must not return an array of LANGID codes.
USB设备中的字符串可能支持多种语言。当请求字符串描述符时,请求者使用USB-IF定义的16位语言ID(LANGID)指定所需的语言。当前定义的USBlangid的列表可以在http://www.usb.org/developers/docs.html上找到。所有语言的字符串索引0返回一个字符串描述符,该描述符包含一个由设备支持的双字节LANGID代码数组。表9-15显示了LANGID代码数组。一个USB设备可能会省略所有的字符串描述符。省略所有字符串描述符的USB设备不能返回LANGID代码数组。
The array of LANGID codes is not NULL-terminated. The size of the array (in bytes) is computed by
subtracting two from the value of the first byte of the descriptor.
LANGID代码数组没有空终止。数组的大小(以字节为单位)是通过从描述符的第一个字节的值中减去2来计算的。

The UNICODE string descriptor (shown in Table 9-16) is not NULL-terminated. The string length is
computed by subtracting two from the value of the first byte of the descriptor.
UNICODE字符串描述符(如表9-16所示)并不以NULL结尾。字符串的长度是通过从描述符的第一个字节的值中减去两个来计算的。

3.6 示例

在Ubuntu中可以执行lsusb -v查看USB设备的描述符信息:

xxx@jimmy:linux-5.10$ lsusb -v
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Couldn't open device, some information will be missing
Device Descriptor:bLength                18bDescriptorType         1bcdUSB               3.00bDeviceClass            9 HubbDeviceSubClass         0 bDeviceProtocol         3 bMaxPacketSize0         9idVendor           0x1d6b Linux FoundationidProduct          0x0003 3.0 root hubbcdDevice            5.15iManufacturer           3 iProduct                2 iSerial                 1 bNumConfigurations      1Configuration Descriptor:bLength                 9bDescriptorType         2wTotalLength       0x001fbNumInterfaces          1bConfigurationValue     1iConfiguration          0 bmAttributes         0xe0Self PoweredRemote WakeupMaxPower                0mAInterface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        0bAlternateSetting       0bNumEndpoints           1bInterfaceClass         9 HubbInterfaceSubClass      0 bInterfaceProtocol      0 Full speed (or root) hubiInterface              0 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x81  EP 1 INbmAttributes            3Transfer Type            InterruptSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0004  1x 4 bytesbInterval              12bMaxBurst               0Bus 003 Device 004: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Couldn't open device, some information will be missing
Device Descriptor:bLength                18bDescriptorType         1bcdUSB               2.00bDeviceClass            9 HubbDeviceSubClass         0 bDeviceProtocol         0 Full speed (or root) hubbMaxPacketSize0        64idVendor           0x0e0f VMware, Inc.idProduct          0x0002 Virtual USB HubbcdDevice            1.00iManufacturer           1 iProduct                2 iSerial                 0 bNumConfigurations      1Configuration Descriptor:bLength                 9bDescriptorType         2wTotalLength       0x0019bNumInterfaces          1bConfigurationValue     1iConfiguration          1 bmAttributes         0xe0Self PoweredRemote WakeupMaxPower                0mAInterface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        0bAlternateSetting       0bNumEndpoints           1bInterfaceClass         9 HubbInterfaceSubClass      0 bInterfaceProtocol      0 Full speed (or root) hubiInterface              1 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x81  EP 1 INbmAttributes            3Transfer Type            InterruptSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0001  1x 1 bytesbInterval               4Bus 003 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Couldn't open device, some information will be missing
Device Descriptor:bLength                18bDescriptorType         1bcdUSB               1.10bDeviceClass            9 HubbDeviceSubClass         0 bDeviceProtocol         0 Full speed (or root) hubbMaxPacketSize0         8idVendor           0x0e0f VMware, Inc.idProduct          0x0002 Virtual USB HubbcdDevice            1.00iManufacturer           1 iProduct                2 iSerial                 0 bNumConfigurations      1Configuration Descriptor:bLength                 9bDescriptorType         2wTotalLength       0x0019bNumInterfaces          1bConfigurationValue     1iConfiguration          1 bmAttributes         0xe0Self PoweredRemote WakeupMaxPower                0mAInterface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        0bAlternateSetting       0bNumEndpoints           1bInterfaceClass         9 HubbInterfaceSubClass      0 bInterfaceProtocol      0 Full speed (or root) hubiInterface              1 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x81  EP 1 INbmAttributes            3Transfer Type            InterruptSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0001  1x 1 bytesbInterval             255Bus 003 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Couldn't open device, some information will be missing
Device Descriptor:bLength                18bDescriptorType         1bcdUSB               1.10bDeviceClass            0 bDeviceSubClass         0 bDeviceProtocol         0 bMaxPacketSize0         8idVendor           0x0e0f VMware, Inc.idProduct          0x0003 Virtual MousebcdDevice            1.03iManufacturer           1 iProduct                2 iSerial                 0 bNumConfigurations      1Configuration Descriptor:bLength                 9bDescriptorType         2wTotalLength       0x0022bNumInterfaces          1bConfigurationValue     1iConfiguration          1 bmAttributes         0xc0Self PoweredMaxPower                0mAInterface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        0bAlternateSetting       0bNumEndpoints           1bInterfaceClass         3 Human Interface DevicebInterfaceSubClass      1 Boot Interface SubclassbInterfaceProtocol      2 MouseiInterface              1 HID Device Descriptor:bLength                 9bDescriptorType        33bcdHID               1.10bCountryCode            0 Not supportedbNumDescriptors         1bDescriptorType        34 ReportwDescriptorLength      46Report Descriptors: ** UNAVAILABLE **Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x81  EP 1 INbmAttributes            3Transfer Type            InterruptSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0008  1x 8 bytesbInterval               1Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Couldn't open device, some information will be missing
Device Descriptor:bLength                18bDescriptorType         1bcdUSB               2.00bDeviceClass            9 HubbDeviceSubClass         0 bDeviceProtocol         1 Single TTbMaxPacketSize0        64idVendor           0x1d6b Linux FoundationidProduct          0x0002 2.0 root hubbcdDevice            5.15iManufacturer           3 iProduct                2 iSerial                 1 bNumConfigurations      1Configuration Descriptor:bLength                 9bDescriptorType         2wTotalLength       0x0019bNumInterfaces          1bConfigurationValue     1iConfiguration          0 bmAttributes         0xe0Self PoweredRemote WakeupMaxPower                0mAInterface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        0bAlternateSetting       0bNumEndpoints           1bInterfaceClass         9 HubbInterfaceSubClass      0 bInterfaceProtocol      0 Full speed (or root) hubiInterface              0 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x81  EP 1 INbmAttributes            3Transfer Type            InterruptSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0004  1x 4 bytesbInterval              12Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Couldn't open device, some information will be missing
Device Descriptor:bLength                18bDescriptorType         1bcdUSB               2.00bDeviceClass            9 HubbDeviceSubClass         0 bDeviceProtocol         0 Full speed (or root) hubbMaxPacketSize0        64idVendor           0x1d6b Linux FoundationidProduct          0x0002 2.0 root hubbcdDevice            5.15iManufacturer           3 iProduct                2 iSerial                 1 bNumConfigurations      1Configuration Descriptor:bLength                 9bDescriptorType         2wTotalLength       0x0019bNumInterfaces          1bConfigurationValue     1iConfiguration          0 bmAttributes         0xe0Self PoweredRemote WakeupMaxPower                0mAInterface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        0bAlternateSetting       0bNumEndpoints           1bInterfaceClass         9 HubbInterfaceSubClass      0 bInterfaceProtocol      0 Full speed (or root) hubiInterface              0 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x81  EP 1 INbmAttributes            3Transfer Type            InterruptSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0004  1x 4 bytesbInterval              12Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Couldn't open device, some information will be missing
Device Descriptor:bLength                18bDescriptorType         1bcdUSB               1.10bDeviceClass            9 HubbDeviceSubClass         0 bDeviceProtocol         0 Full speed (or root) hubbMaxPacketSize0         8idVendor           0x0e0f VMware, Inc.idProduct          0x0002 Virtual USB HubbcdDevice            1.00iManufacturer           1 iProduct                2 iSerial                 0 bNumConfigurations      1Configuration Descriptor:bLength                 9bDescriptorType         2wTotalLength       0x0019bNumInterfaces          1bConfigurationValue     1iConfiguration          1 bmAttributes         0xe0Self PoweredRemote WakeupMaxPower                0mAInterface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        0bAlternateSetting       0bNumEndpoints           1bInterfaceClass         9 HubbInterfaceSubClass      0 bInterfaceProtocol      0 Full speed (or root) hubiInterface              1 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x81  EP 1 INbmAttributes            3Transfer Type            InterruptSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0001  1x 1 bytesbInterval             255Bus 002 Device 002: ID 0e0f:0008 VMware, Inc. Virtual Bluetooth Adapter
Couldn't open device, some information will be missing
Device Descriptor:bLength                18bDescriptorType         1bcdUSB               2.00bDeviceClass          224 WirelessbDeviceSubClass         1 Radio FrequencybDeviceProtocol         1 BluetoothbMaxPacketSize0        64idVendor           0x0e0f VMware, Inc.idProduct          0x0008 bcdDevice            1.00iManufacturer           1 iProduct                2 iSerial                 3 bNumConfigurations      1Configuration Descriptor:bLength                 9bDescriptorType         2wTotalLength       0x00b1bNumInterfaces          2bConfigurationValue     1iConfiguration          0 bmAttributes         0xc0Self PoweredMaxPower                0mAInterface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        0bAlternateSetting       0bNumEndpoints           3bInterfaceClass       224 WirelessbInterfaceSubClass      1 Radio FrequencybInterfaceProtocol      1 BluetoothiInterface              0 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x81  EP 1 INbmAttributes            3Transfer Type            InterruptSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0010  1x 16 bytesbInterval               1Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x02  EP 2 OUTbmAttributes            2Transfer Type            BulkSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0040  1x 64 bytesbInterval               0Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x82  EP 2 INbmAttributes            2Transfer Type            BulkSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0040  1x 64 bytesbInterval               0Interface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        1bAlternateSetting       0bNumEndpoints           2bInterfaceClass       224 WirelessbInterfaceSubClass      1 Radio FrequencybInterfaceProtocol      1 BluetoothiInterface              0 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x03  EP 3 OUTbmAttributes            1Transfer Type            IsochronousSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0000  1x 0 bytesbInterval               1Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x83  EP 3 INbmAttributes            1Transfer Type            IsochronousSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0000  1x 0 bytesbInterval               1Interface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        1bAlternateSetting       1bNumEndpoints           2bInterfaceClass       224 WirelessbInterfaceSubClass      1 Radio FrequencybInterfaceProtocol      1 BluetoothiInterface              0 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x03  EP 3 OUTbmAttributes            1Transfer Type            IsochronousSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0009  1x 9 bytesbInterval               1Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x83  EP 3 INbmAttributes            1Transfer Type            IsochronousSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0009  1x 9 bytesbInterval               1Interface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        1bAlternateSetting       2bNumEndpoints           2bInterfaceClass       224 WirelessbInterfaceSubClass      1 Radio FrequencybInterfaceProtocol      1 BluetoothiInterface              0 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x03  EP 3 OUTbmAttributes            1Transfer Type            IsochronousSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0011  1x 17 bytesbInterval               1Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x83  EP 3 INbmAttributes            1Transfer Type            IsochronousSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0011  1x 17 bytesbInterval               1Interface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        1bAlternateSetting       3bNumEndpoints           2bInterfaceClass       224 WirelessbInterfaceSubClass      1 Radio FrequencybInterfaceProtocol      1 BluetoothiInterface              0 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x03  EP 3 OUTbmAttributes            1Transfer Type            IsochronousSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0019  1x 25 bytesbInterval               1Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x83  EP 3 INbmAttributes            1Transfer Type            IsochronousSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0019  1x 25 bytesbInterval               1Interface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        1bAlternateSetting       4bNumEndpoints           2bInterfaceClass       224 WirelessbInterfaceSubClass      1 Radio FrequencybInterfaceProtocol      1 BluetoothiInterface              0 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x03  EP 3 OUTbmAttributes            1Transfer Type            IsochronousSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0021  1x 33 bytesbInterval               1Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x83  EP 3 INbmAttributes            1Transfer Type            IsochronousSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0021  1x 33 bytesbInterval               1Interface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        1bAlternateSetting       5bNumEndpoints           2bInterfaceClass       224 WirelessbInterfaceSubClass      1 Radio FrequencybInterfaceProtocol      1 BluetoothiInterface              0 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x03  EP 3 OUTbmAttributes            1Transfer Type            IsochronousSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0031  1x 49 bytesbInterval               1Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x83  EP 3 INbmAttributes            1Transfer Type            IsochronousSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0031  1x 49 bytesbInterval               1Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Couldn't open device, some information will be missing
Device Descriptor:bLength                18bDescriptorType         1bcdUSB               1.10bDeviceClass            9 HubbDeviceSubClass         0 bDeviceProtocol         0 Full speed (or root) hubbMaxPacketSize0        64idVendor           0x1d6b Linux FoundationidProduct          0x0001 1.1 root hubbcdDevice            5.15iManufacturer           3 iProduct                2 iSerial                 1 bNumConfigurations      1Configuration Descriptor:bLength                 9bDescriptorType         2wTotalLength       0x0019bNumInterfaces          1bConfigurationValue     1iConfiguration          0 bmAttributes         0xe0Self PoweredRemote WakeupMaxPower                0mAInterface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        0bAlternateSetting       0bNumEndpoints           1bInterfaceClass         9 HubbDeviceSubClass         0 bDeviceProtocol         0 Full speed (or root) hubbMaxPacketSize0        64idVendor           0x1d6b Linux FoundationidProduct          0x0001 1.1 root hubbcdDevice            5.15iManufacturer           3 iProduct                2 iSerial                 1 bNumConfigurations      1Configuration Descriptor:bLength                 9bDescriptorType         2wTotalLength       0x0019bNumInterfaces          1bConfigurationValue     1iConfiguration          0 bmAttributes         0xe0Self PoweredRemote WakeupMaxPower                0mAInterface Descriptor:bLength                 9bDescriptorType         4bInterfaceNumber        0bAlternateSetting       0bNumEndpoints           1bInterfaceClass         9 HubbInterfaceSubClass      0 bInterfaceProtocol      0 Full speed (or root) hubiInterface              0 Endpoint Descriptor:bLength                 7bDescriptorType         5bEndpointAddress     0x81  EP 1 INbmAttributes            3Transfer Type            InterruptSynch Type               NoneUsage Type               DatawMaxPacketSize     0x0002  1x 2 bytesbInterval             255
xxx@jimmy:linux-5.10$

4. 设备枚举过程示例

使用"usbprotocolsuite"打开,可以看到设备的枚举过程:

  • 使用控制传输,读取设备信息(设备描述符):第一次读取时,它只需要得到8字节数据,因为第8个数据表示端点0能传输的最大数据长度。
  • Host分配地址给设备,然后把新地址发给设备:
  • 使用新地址,重新读取设备描述符,设备描述符长度是18:
  • 读取配置描述符:它传入的长度是255,想一次性把当前配置描述符、它下面的接口描述符、端点描述符全部读出来
  • 读取字符描述符

USB学习3-USB描述符相关推荐

  1. USB(六)-HID(报告描述符的结构实现)

    USB HID设备是通过报告(report)来传输数据的,报告有输入报告和输出报告.输入报告是USB设备发送给主机:输出报告是主机发送给USB设备. 报告描述符是用来描述一个报告的结构以及该报告里面的 ...

  2. USB接口的键盘描述符范例

    ;========================================= ; Device descriptor 设备描述符 ;============================== ...

  3. HID报表描述符(目前最全的解析,也是USB最复杂的描述符)

    说一下为什么写这篇文章,主要是最近在做关于USB-HID设备的描述符,看到关于HID报表描述符的解析有点少,自己看了下,后续还会发布还有关于USB的各种解析,有兴趣可以看看,可以让你更加明白USB工作 ...

  4. 【USB笔记】端点描述符Endpoint Descriptor

    USB笔记 端点描述符 (Endpoint Descriptor) 端点描述符 (Endpoint Descriptor)描述了USB规范定义的端点信息,包含有端点的带宽等信息.每一个端点都有自己的端 ...

  5. USB键盘实现——字符串描述符(四)

    目录 字符串描述符 获取字符串描述符请求 标准设备请求 语言 ID 获取(字符串索引为 0) USB 控制端点收到的数据 语言 ID 返回 厂商字符串获取(字符串索引为 1) USB 控制端点收到的数 ...

  6. USB HID设备报告描述符详解

    概述: 报告在这里意思是数据传输(data transfer),而报告描述符是对这些传输的数据作用途(usage)上的说明. USB通讯协议的规范是以1ms产生一个USB帧(Frame),USB设备可 ...

  7. 【USB笔记】配置描述符Configuration Descriptor

    USB笔记 配置描述符(Configuration Descriptor) 配置描述符(Configuration Descriptor)说明了一个特定配置的相关信息.取得设备描述符(Device D ...

  8. 【USB笔记】接口描述符Interface Descriptor

    USB笔记 接口描述符 (Interface Descriptor) 接口描述符(Interface Descriptor)描述了配置中一个特定的接口.配置提供了一个或多个接口,每个接口都含有类(Cl ...

  9. USB学习5---android usb驱动源代码目录说明

    kernel\msm-3.18\drivers\usb下目录内容 我们msm8937+android7.1平台编译out目录下usb目录下有编译到的目录如下: 我们先参考kernel\msm-3.18 ...

  10. Linux学习:文件描述符相关函数

    (1)复制文件描述符 头文件: #include <unistd.h> 原型: int dup(int oldfd); 参数: 要复制的文件描述符. 返回值:新的文件描述符. 效果: du ...

最新文章

  1. python2.7除法_对python中的float除法和整除法的实例详解
  2. 敏感数据,“一键脱敏”,Sharding Sphere 完美搞定
  3. C语言函数集(十七)
  4. maven2创建或者导入eclipse工程 设置M2_REPO消除错误
  5. Paxos、Raft分布式一致性算法应用场景
  6. 高级软件工程课程第一次作业的小结
  7. Mybatis源码分析之(四)mapper访问数据库的底层原理(代理方法中具体访问数据库的细节)
  8. 如何保证文章中同一组样品在不同子图颜色一致?
  9. 即使不会node.js,拖拽就可完成数据的可视化展示
  10. Qt与MySQL的连接与基本操作
  11. 一篇文章帮你梳理清楚API设计时需要考虑的几个关键点
  12. 模拟手机通讯录管理系统
  13. 全自动抠图换背景软件下载_抠图换背景的证件照软件
  14. 柳传志给杨元庆的信件 (zt)
  15. 新浪-InSAR博客网址Blog of Jerome Cheung
  16. AR/VR/MR三者之间的区别和联系
  17. Aleo提高高算力的解决方法(精选)
  18. BUUCTF-WEB 【0CTF 2016】piapiapia 1
  19. 百度回复针对目前相关性问题
  20. 最全的cmd命令大全

热门文章

  1. docker使用笔记(一)如何部署Tomcat?
  2. Socket -- 网络编程
  3. nats服务器状态未启用,消息系统NATS常见的几个问题
  4. 为什么计算机桌面显示器,为什么电脑屏幕显示器的字体会模糊呢
  5. Fibonacci数列取余10007
  6. php 修改图像大小,PHP中修改图像大小 - PHP - 软件工程|架构设计|网站设计|艺术营销 - 河洛炎黄 - 魏文侯...
  7. UMeditor,简称UM 添加缩进功能
  8. 联想小新pro16哪个版本好 联想小新pro16标压锐龙版、 锐龙独显版和酷睿独显版选哪个
  9. install freemind on ubuntu
  10. #3.14 Piday#我的圆周率日