usb hub状态 改变状态

来源:互联网 发布:mysql 建库 编辑:程序博客网 时间:2024/04/29 07:17

一. 前言

在前文中,我们看过hub的处理并没有对hub的请求命令做个详细的讲解,在本文中,我们会针对这些hub的请求来看hub的处理,也可以说是从另一个方面来看hub,主要是结合usb2.0协议来看。

二. hub请求命令

1.     GetHub Status

bRequestType

bRequest

wValue

wIndex

wLength

Data

10100000B

GET_ STATUS

0

0

4

Hub status and Change Status

struct usb_hub_status {

       __le16wHubStatus;    --hub状态

       __le16 wHubChange;   --hub改变

} __attribute__ ((packed));

下面来说明这两个成员各个bit位的含义

wHubStatus:

该成员表明hub的电源状态

bit 0 : 该位表明hub的电源是依靠本地供电还是外部电源。0表明本地供电良好,1表明本地供电不良。

Bit1 : 该位表明是否有过流存在 0 表明无过流存在 1表明有过流存在。如果所有的端口电流总和超过了hub支持电流的最大值则会设置该位,同时所有的端口都将处于断电状态。

Bit2~bit15 : 保留

wHubChange:

而该成员则用于表示电源状态是否改变

Bit 0 : 本地电源改变。0 本地电源状态没有改变 1 改变。其实该域的变化与否跟上面的wHubStatus的值息息相关,如果wHubStatus的bit0从0->1或从1->0,那该位会设置。在clear_feature时其对应的是C_HUB_LOCAL_POWER

Bit1 :过流状态是否改变。该bit的设定与上面相同。在clear_feature时其对应的是C_HUB_OVER_CURRENT

2.     GetPort Status

bRequestType

bRequest

wValue

wIndex

wLength

Data

10100011B

GET_ STATUS

0

Port

4

Port status and Change Status

struct usb_port_status {

       __le16 wPortStatus;

       __le16wPortChange;

} __attribute__ ((packed));

wPortStatus:

Bit0:当前连接状态(PORT_CONNECTION) 0 无设备连接 1 有设备连接

Bit1:端口使能与否(PORT_ENABLE) 0 禁止端口 1 使能端口 该位仅能有usb系统软件设定。

Bit2:挂起(PORT_SUSPEND) 0 未挂起 1 挂起或恢复

Bit3:过流(PORT_OVER_CURRENT) 0 无过流 1 存在过流

Bit4:复位(PORT_RESET) 0 无复位信号 1 复位信号 如果主机想复位该端口连接的设备则设置该位,该位会一直保留设置直到hub不鸟复位信号。

Bit5~bit7:保留

Bit8:端口电源(PORT_POWER) 0 该端口处于断电 1 该端口供电正常

Bit9:连接设备为低速设备(PORT_LOW_SPEED) 0 全速或高速设备链接在该端口 1 该端口链接的设备为低速设备

Bit10:连接设备为高速设备(PORT_HIGH_SPEED) 0 全速设备连接在该端口 1 高速设备链接在该端口

Bit11:端口测试模式(PORT_TEST) 0 端口未处在端口测试模式 1 处于端口测试模式

Bit12:端口指示灯控制(PORT_INDICATOR) 0 端口指示灯为默认颜色 1 端口指示灯软件控制颜色

Bit13~bit15:保留

wPortChange:

bit0:链接状态改变(C_PORT_CONNECTION) 0 没有改变 1 改变

bit1:端口禁止/使能改变(C_PORT_ENABLE) 该bit位会由于Port_Error条件导致端口禁止时设置1

bit2:挂起改变(C_PORT_SUSPEND) 0 没有改变 1 恢复结束

bit3:过流指示改变(C_PORT_OVER_CURRENT) 0 无过流 1 过流指示改变

bit4:复位改变(C_PORT_RESET) 0 无改变 1 复位结束

bit5~bit15:保留

集线器类的请求:请求集线器描述符a0  06 

地址偏移量

字段名

长度/字节

说明

当前值

0

bDescLength

可变

长度 09

09

1

bDescriptorType

1

描述符的类型:29 for hub

29

2

bNbrPorts

1

支持的下行口数量

04

3

wHubCharacteristics

2

Hub特性

00e0

5

bPwrOn2PwrGood

1

端口上电时间 ×2ms

32

6

bHubContrCurrent

1

Hub需要的最大电流

64

7

DeviceRemovable

可变的,决定于端口的        数量

指示端口是否有一个可删除的设备

00

Variable

PortPwrCtrlMask

可变,决定于端口的        数量

This field exists for reasons of compatibility with software written for 1.0 compliant devices.

Ff

GetPortStatusa3 00 00hub class request  

 端口状态请求。01表示port 1 04 data length,设备返回的4byteThe first word of data contains wPortStatus (refer to Table 11-21). The second word of data contains wPortChange (refer to Table 11-22).   See USB 2.0 Specification section 11.24.2.7.

Table 11-21端点状态域(wPortStatus

Bit

Description

当前值

0

Current Connect Status:  (PORT_CONNECTION) 当前端口上是否有一个设备链接。

0 =没有设备存在

1 =端口上有一个设备.

1

1

Port Enabled/Disabled: (PORT_ENABLE) Ports can be enabled by the USB System Software only. 

0 = Port is disabled.

1 = Port is enabled.

0

2

Suspend: (PORT_SUSPEND) This field indicates whether or not the device on this port is suspended.

0 = Not suspended.

1 = Suspended or resuming.

0

3

Over-current: (PORT_OVER_CURRENT)

If the hub reports over-current conditions on a per-port basis, this field will indicate that port exceeds the specified maximum. 

0 = All no over-current condition exists on this port.

1 = An over-current condition exists on this port.

0

4

Reset: (PORT_RESET) This field is set when the host wishes to reset the attached device. It remains set until the reset signaling is turned off by the hub.

0 = Reset signaling not asserted.

1 = Reset signaling asserted.

 

5-7

保留

0

8

Port Power: (PORT_POWER) This field reflects a port’s logical, power control state. Because hubs can implement different methods of port power switching, this field may or may not represent whether power is applied to the port. The device descriptor reports the type of power switching implemented by the hub.

0 = This port is in the Powered-off state.

1 = This port is not in the Powered-off state.

0

9

Low- Speed Device Attached: (PORT_LOW_SPEED) This is relevant only if a device is attached.

0 = Full-speed or High-speed device attached to this port (determined by bit 10).

1 = Low-speed device attached to this port.

0

10

High-speed Device Attached: (PORT_HIGH_SPEED) This is relevant only if a device is attached.

0 = Full-speed device attached to this port.

1 = High-speed device attached to this port.

0

11

Port Test Mode : (PORT_TEST) This field reflects the status of the port's test mode. Software uses the SetPortFeature() and ClearPortFeature() requests to manipulate the port test mode.

0 = This port is not in the Port Test Mode.

1 = This port is in Port Test Mode.

0

12

Port Indicator Control: (PORT_INDICATOR) This field is set to reflect software control of the port indicator.For more details see Sections 11.5.3, 11.24.2.7.1.10, and 11.24.2.13.

0 = Port indicator displays default colors.

1 = Port indicator displays software controlled color.

0

13-15

保留

0

Table 11-20. Hub Change Field, wHubChange

Bit

Description

.

 

 

0

Connect Status Change: (C_PORT_CONNECTION)  Indicates a change has occurred in the port’s Current Connect Status. The hub device sets this field as described in Section 11.24.2.7.2.1.

0 = No change has occurred to Current Connect status.

1 = Current Connect status has changed

0

1

Port Enable/Disable Change: (C_PORT_ENABLE) This field is set to one when a port is disabled becauseof a Port_Error condition (see Section 11.8.1).

0

2

Suspend Change: (C_PORT_SUSPEND) This field indicates a change in the host-visible suspend state of the attached device. It indicates the device has transitioned out of the Suspend state. This field is set only when the entire resume process has completed. That is, the hub has ceased signaling resume on this port.

0 = No change.

1 = Resume complete.

0

3

Over-Current Indicator Change: (C_PORT_OVER_CURRENT) This field applies only to hubs that report over-current conditions on a per-port basis (as reported in the hub descriptor).

0 = No change has occurred to Over-Current Indicator.

1 = Over-Current Indicator has changed.

If the hub does not report over-current on a per-port basis, then this field is always zero.

 

4

Reset Change: (C_PORT_RESET) This field is set when reset processing on this port is complete.

0 = No change.

1 = Reset complete.

0

5-15

Reserved    These bits return 0 when read.

0


原创粉丝点击