4.4.3.2. 详细分析USB枚举数据的每个字段的具体含义

接下来,就是分析,每一部分的数据,到底对应的是何种含义。

此处,再把上述数据贴出来,并进行分析:

0902420002010480E11
0904000002FF0000002
092110010001223F003
070501034000014
070581034000015
0904010001030000006
0921100100012221007
0705820340000A8
                

1

此部分内容对应着的是:Configuration

其定义为:

表 4.3. USB Configuration Descriptors

OffsetFieldSizeValueDescription
0bLength1NumberSize of Descriptor in Bytes
1bDescriptorType1ConstantConfiguration Descriptor (0x02)
2wTotalLength2NumberTotal length in bytes of data returned
4bNumInterfaces1NumberNumber of Interfaces
5bConfigurationValue1NumberValue to use as an argument to select this configuration
6iConfiguration1IndexIndex of String Descriptor describing this configuration
7bmAttributes1Bitmap
D7Reserved, set to 1. (USB 1.0 Bus Powered)
D6Self Powered
D5Remote Wakeup
D4..0Reserved, set to 0.
8bMaxPower1mAMaximum Power Consumption in 2mA units


其每个字节对应的含义为:

图 4.7. Configuration Descriptor: 0902420002010480E1

Configuration Descriptor: 0902420002010480E1


2

此部分内容对应着的是:Interface

其定义为:

表 4.4. USB Interface Descriptors

OffsetFieldSizeValueDescription
0bLength1NumberSize of Descriptor in Bytes (9 Bytes)
1bDescriptorType1ConstantInterface Descriptor (0x04)
2bInterfaceNumber1NumberNumber of Interface
3bAlternateSetting1NumberValue used to select alternative setting
4bNumEndpoints1NumberNumber of Endpoints used for this interface
5bInterfaceClass1ClassClass Code (Assigned by USB Org)
6bInterfaceSubClass1SubClassSubclass Code (Assigned by USB Org)
7bInterfaceProtocol1ProtocolProtocol Code (Assigned by USB Org)
8iInterface1IndexIndex of String Descriptor Describing this interface


其每个字节对应的含义为:

图 4.8. Interface Descriptor: 0904000002FF000000

Interface Descriptor: 0904000002FF000000


3

此部分内容对应着的是:Class

由于其前面的2中bInterfaceClass=0xFF,对应着表 4.1 “USB Class表”中的vendor-specific,所以此部分的值的含义,是针对特定厂家的特定的含义,因此此处就不具体解释了。

4

此部分内容对应着的是:Endpoint

其定义为:

表 4.5. USB Endpoint Descriptors

OffsetFieldSizeValueDescription
0bLength1NumberSize of Descriptor in Bytes (7 bytes)
1bDescriptorType1ConstantEndpoint Descriptor (0x05)
2bEndpointAddress1EndpointEndpoint Address
Bits 0..3bEndpoint Number
Bits 4..6bReserved. Set to Zero
Bits 7Remote Wakeup
D4..D0Direction
0Out
1In (Ignored for Control Endpoints)
3bmAttributes1Bitmap
Bits 0..1Transfer Type
00Control
01Isochronous
10Bulk
11Interrupt
Bits 2..7are reserved.

If Isochronous endpoint:

Bits 3..2Synchronisation Type (Iso Mode)
00No Synchonisation
01Asynchronous
10Adaptive
11Synchronous
Bits 5..4Usage Type (Iso Mode)
00Data Endpoint
01Feedback Endpoint
10Explicit Feedback Data Endpoint
11Reserved
4wMaxPacketSize2NumberMaximum Packet Size this endpoint is capable of sending or receiving
6bInterval1NumberInterval for polling endpoint data transfers. Value in frame counts. Ignored for Bulk & Control Endpoints. Isochronous must equal 1 and field may range from 1 to 255 for interrupt endpoints.


其每个字节对应的含义为:

图 4.9. Endpoint (Interrupt Out) Descriptor: 07050103400001

Endpoint (Interrupt Out) Descriptor: 07050103400001


5

此部分内容和4类似,也是对应着:Endpoint

对应定义为:表 4.5 “USB Endpoint Descriptors”

其每个字节对应的含义为:

图 4.10. Endpoint (Interrupt In) Descriptor: 07058103400001

Endpoint (Interrupt In) Descriptor: 07058103400001


6

此部分内容对应着的是:Interface

其定义为参考:表 4.4 “USB Interface Descriptors”

其每个字节对应的含义为:

图 4.11. Interface Descriptor: 090401000103000000

Interface Descriptor: 090401000103000000


7

由于6中bInterfaceClass=0x03,对应着表 4.1 “USB Class表”中的HID,所以,此部分内容的解析,依赖于对应的HID中的定义。

可在官方的1.1版本的HID协议:HID1_11.pdf中的“6.2.1 HID Descriptor”部分找到对应的定义:

表 4.6. USB HID Descriptors

PartOffset/Size(Bytes)Description
bLength0/1Numeric expression that is the total size of the HID descriptor.
bDescriptorType1/1Constant name specifying type of HID descriptor.
bcdHID2/2Numeric expression identifying the HID Class Specification release.
bCountryCode4/1Numeric expression identifying country code of the localized hardware.
bNumDescriptors5/1Numeric expression specifying the number of class descriptors (always at least one i.e. Report descriptor.)
bDescriptorType6/1Constant name identifying type of class descriptor. See Section 7.1.2: Set_Descriptor Request for a table of class descriptor constants.
wDescriptorLength7/2Numeric expression that is the total size of the Report descriptor.
[bDescriptorType]9/1Constant name specifying type of optional descriptor.
[wDescriptorLength]10/2Numeric expression that is the total size of the optional descriptor.


其每个字节对应的含义为:

表 4.7. USB HID Descriptor: 090401000103000000

OffsetFieldSizeValueDescription
0bLength109the total size of the HID descriptor =9 bytes
1bDescriptorType121descriptor constant, HID = 0x21
2bcdHID21001HID Class Specification release 0x0110= 1.10
4bCountryCode100No country code of the localized hardware
5bNumDescriptors101the number of class descriptors = 1
6bDescriptorType122Class descriptor constant, 0x22 = Report descriptor
7wDescriptorLength22100the total size of the Report descriptor =0x0021=33 bytes
9[bDescriptorType]2  
10[wDescriptorLength]   


8

此部分内容和5类似,也是对应着:Endpoint

对应定义为:表 4.5 “USB Endpoint Descriptors”

其每个字节对应的含义为:

图 4.12. Endpoint (Interrupt In 2) Descriptor: 0705820340000A

Endpoint (Interrupt In 2) Descriptor: 0705820340000A