日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

USB鼠标-配置描述符(三)

發布時間:2023/12/1 33 生活家
生活随笔 收集整理的這篇文章主要介紹了 USB鼠标-配置描述符(三) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?USB?鼠標詳解閱讀順序

1、枚舉

2、設備描述符

3、設置地址

4、配置描述符

5、接口描述符

6、HID 描述符

7、端點描述符

8、字符串描述符

9、HID 報告描述符

10、HID 報告的返回

配置描述符定義

配置描述符結構

typedef struct __attribute__ ((packed))
{uint8_t  bLength             ; ///< Size of this descriptor in bytesuint8_t  bDescriptorType     ; ///< CONFIGURATION Descriptor Typeuint16_t wTotalLength        ; ///< Total length of data returned for this configuration. Includes the combined length of all descriptors (configuration, interface, endpoint, and class- or vendor-specific) returned for this configuration.uint8_t  bNumInterfaces      ; ///< Number of interfaces supported by this configurationuint8_t  bConfigurationValue ; ///< Value to use as an argument to the SetConfiguration() request to select this configuration.uint8_t  iConfiguration      ; ///< Index of string descriptor describing this configurationuint8_t  bmAttributes        ; ///< Configuration characteristics \n D7: Reserved (set to one)\n D6: Self-powered \n D5: Remote Wakeup \n D4...0: Reserved (reset to zero) \n D7 is reserved and must be set to one for historical reasons. \n A device configuration that uses power from the bus and a local source reports a non-zero value in bMaxPower to indicate the amount of bus power required and sets D6. The actual power source at runtime may be determined using the GetStatus(DEVICE) request (see USB 2.0 spec Section 9.4.5). \n If a device configuration supports remote wakeup, D5 is set to one.uint8_t  bMaxPower           ; ///< Maximum power consumption of the USB device from the bus in this specific configuration when the device is fully operational. Expressed in 2 mA units (i.e., 50 = 100 mA).
}usb_desc_configuration_t;
  • bLength:配置描述符的長度。標準的 USB?配置描述符的長度為 9?字節
  • bDescriptorType:描述符的類型。配置描述符的類型編碼為 0x02
  • wTotalLength:2?個字節,表示整個配置描述符集合的總長度,包括配置描述符,接口描述符,類特殊描述符(如果有)和端點描述符,注意低字節在前。
  • bNumInterfaces:表示該配置所支持的接口數量。通常功能單一的設備只具有一個接口,而復合設備則具有多個接口
  • bConfiguration:表示該配置的值。通常一個 USB?設備可以支持多個配置,bConfiguration?就是每個配置的標識
  • iConfiguration:描述該配置的字符串的索引值,如果該值為 0 ,表示沒有字符串
  • bmAttributes:用來描述設備的一些特性
  • bMaxPower:表示設備需要從總線獲取的最大電流量,單位為 2 mA。

配置描述符抓包

配置描述符的數據格式

  • 0x09?bLength字段。配置描述符的長度為9字節
  • 0x02?bDescriptorType字段。配置描述符編號為0x02
  • 0x22?wTotalLength字段。配置描述符集合的總長度,包括配置描述符本身、接口描述符、類描述符、端點描述符等,LSB
  • 0x00
  • 0x01?bNumInterfaces字段。該配置包含的接口數,只有一個接口
  • 0x01?bConfiguration字段。該配置的值為1
  • 0x00?iConfigurationz字段,該配置的字符串索引。這里沒有,為0
  • 0xA0?bmAttributes字段,該設備的屬性
  • 0x32?bMaxPower字段,該設備需要的最大電流量。每單位電流為 2 mA

總結

以上是生活随笔為你收集整理的USB鼠标-配置描述符(三)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。