第三篇 ME909s-821设备描述符分析

来源:互联网 发布:178软件源地址 编辑:程序博客网 时间:2024/06/03 20:09

1、使用在ubuntu下使用usbview得到设备描述符

ME909S-821的设备描述符如下:
HUAWEI Mobile V7R11Manufacturer: Huawei Technologies Co., Ltd.Serial Number: 0123456789ABCDEFSpeed: 480Mb/s (high)USB Version:  2.10Device Class: 00(>ifc )Device Subclass: 00Device Protocol: ffMaximum Default Endpoint Size: 64Number of Configurations: 3Vendor Id: 12d1Product Id: 15c1Revision Number:  1.02Config Number: 1Number of Interfaces: 6Attributes: a0MaxPower Needed:   2mAInterface Number: 0Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 10Number of Endpoints: 3Endpoint Address: 82Direction: inAttribute: 3Type: Int.Max Packet Size: 10Interval: 32msEndpoint Address: 81Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 01Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 1Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 13Number of Endpoints: 2Endpoint Address: 83Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 02Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 2Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 12Number of Endpoints: 2Endpoint Address: 84Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 03Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 3Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 16Number of Endpoints: 1Endpoint Address: 86Direction: inAttribute: 3Type: Int.Max Packet Size: 16Interval: 2msInterface Number: 3Name: Alternate Number: 1Class: ff(vend.) Sub Class: 06Protocol: 16Number of Endpoints: 3Endpoint Address: 86Direction: inAttribute: 3Type: Int.Max Packet Size: 16Interval: 2msEndpoint Address: 85Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 04Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 4Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 06Number of Endpoints: 2Endpoint Address: 87Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 05Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 5Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 1bNumber of Endpoints: 2Endpoint Address: 88Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 06Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msConfig Number: 2Number of Interfaces: 7Attributes: a0MaxPower Needed:   2mAInterface Number: 0Name: cdc_etherAlternate Number: 0Class: 02(comm.) Sub Class: 06Protocol: 00Number of Endpoints: 1Endpoint Address: 82Direction: inAttribute: 3Type: Int.Max Packet Size: 16Interval: 2msInterface Number: 1Name: cdc_etherAlternate Number: 0Class: 0a(data ) Sub Class: 06Protocol: 00Number of Endpoints: 2Endpoint Address: 81Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 01Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 2Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 10Number of Endpoints: 3Endpoint Address: 84Direction: inAttribute: 3Type: Int.Max Packet Size: 10Interval: 32msEndpoint Address: 83Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 02Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 3Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 13Number of Endpoints: 2Endpoint Address: 85Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 03Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 4Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 12Number of Endpoints: 2Endpoint Address: 86Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 04Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 5Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 06Number of Endpoints: 2Endpoint Address: 87Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 05Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 6Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 1bNumber of Endpoints: 2Endpoint Address: 88Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 06Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msConfig Number: 3Number of Interfaces: 2Attributes: a0MaxPower Needed:   2mAInterface Number: 0Name: Alternate Number: 0Class: 02(comm.) Sub Class: 0eProtocol: 00Number of Endpoints: 1Endpoint Address: 82Direction: inAttribute: 3Type: Int.Max Packet Size: 16Interval: 2msInterface Number: 1Name: Alternate Number: 0Class: 0a(data ) Sub Class: 00Protocol: 02Number of Endpoints: 0Interface Number: 1Name: Alternate Number: 1Class: 0a(data ) Sub Class: 00Protocol: 02Number of Endpoints: 2Endpoint Address: 81Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 01Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0ms
是不是特别多、特别长,但是以上设备描述符中,接口描述符不一定都有用。
简单描述一下设备描述符的组成,还是用图片加描述的方式:

在USB协议里,一个设备描述符代表一个USB设备,一个设备描述符有多个配置描述符,一般情况下,只有一个配置描述符其作用,同时,这个每个配置描述符也有多个接口描述符,这些接口描述符里边也存在不起作用的接口描述符。在这个4G模块里边,没有其他设备类描述符,什么叫设备类描述符,这里有点内容过了,与4G模块无关。

2、分析设备描述符方法

       从设备描述符入手,在USB协议上找到相应的定义。下面是ME909S的设备描述符,其中将没有用的配置描述符去掉了,只剩下配置描述符2。
HUAWEI Mobile V7R11---------------------------------设备名字
Manufacturer: Huawei Technologies Co., Ltd.-----制造商
Serial Number: 0123456789ABCDEF---------------序列号,写驱动反正没用上
Speed: 480Mb/s (high)---------------------------------这是一个高速的USB设备
USB Version:  2.10--------------------------------------使用的USB2.0协议,当然高速设备就是USB2.0的接口
Device Class: 00(>ifc )---------------------------------1、设备类,有用
Device Subclass: 00------------------------------------2、设备子类,有用
Device Protocol: ff---------------------------------------3、设备协议,只要是FF,就代表厂商自己定义的
Maximum Default Endpoint Size: 64
Number of Configurations: 3--------------------------包含配置描述符个数
Vendor Id: 12d1-----------------------------------------4、厂商ID号
Product Id: 15c1----------------------------------------4、产品ID号
Revision Number:  1.02-------------------------------


Config Number: 2--------------------------------------配置描述符2,通过分析只有这个里边的接口描述符才有详细名字
Number of Interfaces: 7------------------------接口描述符个数
Attributes: a0-------------------------------------5、属性
MaxPower Needed:   2mA


Interface Number: 0
Name: cdc_ether
Alternate Number: 0
Class: 02(comm.) -------------------------6、接口的类
Sub Class: 06-------------------------------7、接口子类
Protocol: 00---------------------------------8、使用的协议
Number of Endpoints: 1

Endpoint Address: 82
Direction: in
Attribute: 3
Type: Int.
Max Packet Size: 16
Interval: 2ms

Interface Number: 1
Name: cdc_ether
Alternate Number: 0
Class: 0a(data ) 
Sub Class: 06
Protocol: 00
Number of Endpoints: 2

Endpoint Address: 81
Direction: in
Attribute: 2
Type: Bulk
Max Packet Size: 512
Interval: 0ms

Endpoint Address: 01
Direction: out
Attribute: 2
Type: Bulk
Max Packet Size: 512
Interval: 0ms

Interface Number: 2
Name: option
Alternate Number: 0
Class: ff(vend.) 
Sub Class: 06
Protocol: 10
Number of Endpoints: 3

Endpoint Address: 84
Direction: in
Attribute: 3
Type: Int.
Max Packet Size: 10
Interval: 32ms

Endpoint Address: 83
Direction: in
Attribute: 2
Type: Bulk
Max Packet Size: 512
Interval: 0ms

Endpoint Address: 02
Direction: out
Attribute: 2
Type: Bulk
Max Packet Size: 512
Interval: 0ms

Interface Number: 3
Name: option
Alternate Number: 0
Class: ff(vend.) 
Sub Class: 06
Protocol: 13
Number of Endpoints: 2

Endpoint Address: 85
Direction: in
Attribute: 2
Type: Bulk
Max Packet Size: 512
Interval: 0ms

Endpoint Address: 03
Direction: out
Attribute: 2
Type: Bulk
Max Packet Size: 512
Interval: 0ms

Interface Number: 4
Name: option
Alternate Number: 0
Class: ff(vend.) 
Sub Class: 06
Protocol: 12
Number of Endpoints: 2

Endpoint Address: 86
Direction: in
Attribute: 2
Type: Bulk
Max Packet Size: 512
Interval: 0ms

Endpoint Address: 04
Direction: out
Attribute: 2
Type: Bulk
Max Packet Size: 512
Interval: 0ms

Interface Number: 5
Name: option
Alternate Number: 0
Class: ff(vend.) 
Sub Class: 06
Protocol: 06
Number of Endpoints: 2

Endpoint Address: 87
Direction: in
Attribute: 2
Type: Bulk
Max Packet Size: 512
Interval: 0ms

Endpoint Address: 05
Direction: out
Attribute: 2
Type: Bulk
Max Packet Size: 512
Interval: 0ms

Interface Number: 6
Name: option
Alternate Number: 0
Class: ff(vend.) 
Sub Class: 06
Protocol: 1b
Number of Endpoints: 2

Endpoint Address: 88
Direction: in
Attribute: 2
Type: Bulk
Max Packet Size: 512
Interval: 0ms

Endpoint Address: 06
Direction: out
Attribute: 2
Type: Bulk
Max Packet Size: 512
Interval: 0ms
        在这里,先对第4点说明,厂商ID和设备ID是绑定一个USB驱动首要标准。
        重点说明class、subclass和protocol(参考USB开发者网站:点击打开链接):在USB开发者网站有一张表:

       在这个4G模块里边,首先是设备描述符开头,其class、subclass为00,从上表说明可以看出,这个4G模块的功能是在USB接口描述符里边说明或者表现出来的。
          接下来是配置描述符2里边接口描述符0的class、subclass和protocol,这里只分析接口描述符0,对其他起作用的接口描述符不分析,分析方法是一致的。如下面:
Class: 02(comm.) -------------------------6、接口的类
Sub Class: 06-------------------------------7、接口子类
Protocol: 00---------------------------------8、使用的协议

从上面的表里,可以找到class为02的含义:代表这个USB设备为一个通信设备////2017/06/18晚
Sub Class = 06 代表这个是Ethernet Control Model(以太网控制模型),
Protocol = 00 代表不需要类特定协议
接下来,就是在什么地方找到这些答案的-----------------------------------?????????????
1--Class的定义 答案:Defined 1.0 Class Codes
2--Sub Class定义 答案:USB Device Class Specifications
        上面这两个USB协议网站有些不同,第一个主要就是上边的表格,下面的网站比较详细,对USB协议中五种设备的详细说明。
3--Protocol定义 答案:USB Device Class Specifications,里面包括每一种设备的详细说明。

3、详细分析4G模块的Class、Sub Class、Protocol与接口驱动程序之间的关系

来吧,看一张图,只是说明很小部分的关系,不可强证:

     对于4G模块,采用了第三种寻找驱动的方法,由于4G模块采用的USB驱动绑定套路是:先根据常规的USB驱动绑定套路,绑定一个常规USB驱动,执行USB驱动里边probe探测函数,在探测函数里会根据前面枚举得到的设备描述符里的接口描述符(当然了,是有用的接口描述符,如何才算有用:接口有名字或者根据class和subclass分析,知道这个接口对于实现某一功能有用),4G模块
为5个接口描述符绑定了同一个usbserial接口驱动程序(usbtty0---usbtty4),具体有些接口没有研究透,实现打电话、发短信只是有到了usbtty0。




原创粉丝点击