USB集线器GetPortStatus
2023-04-12
本文链接为:http://www.usbzh.com/article/detail-1162.html ,欢迎转载,转载请附上本文链接。
| Request | bmRequestType | bRequest | wValue | wIndex | wLength | Data |
|---|---|---|---|---|---|---|
| GetPortStatus | 10100011B (0xA3) | GET_STATUS(0x00) | 0 | Port | 4 | Port Status and Change Status |
获取下游端口的4个端口状态

Port Status Bits
- BIT0:Current Connect Status 0设备不在线,1设备在线
- BIT1:Port Enabled/Disabled: 0端口变为禁用,1端口变为使用。
- BIT2:Suspend
- BIT3:Over-current: (PORT_OVER_CURRENT)
- BIT4:Reset: (PORT_RESET) 端口复位完成
- BIT5~7:保留
- BIT8:Port Power: (PORT_POWER)
- BIT9:Low- Speed Device Attached
- BIT10:High-speed Device Attached
- BIT11:Port Test Mode : (PORT_TEST)
- BIT12:Port Indicator Control: (PORT_INDICATOR)
- BIT13~15:保留
Port Status Change Bits
- BIT0:Connect Status Change(0无事件,1有事件)
- BIT1:Port Enable/Disable Change
- BIT2:Suspend Change:(0无事件,1唤醒完成)
- BIT3:Over-Current Indicator Change(0过流未变化,1过流已变化)
- BIT4:Reset Change(0无事件,1复位完成)
- BIT5~15:保留
0代表无事件发,1代表有事件发生
抓包显示

Port状态变化处理汇总
| 状态位 | ack:ClearFeature | IoInvalidateDevice Relations | 其他动作 |
|---|---|---|---|
| PORT_STATUS_CONNECT | FEATURE_C_PORT_CONNECT | ✓ | 删除/更新 PDO |
| PORT_STATUS_RESET | FEATURE_C_PORT_RESET | x | 无 |
| PORT_STATUS_ENABLE | FEATURE_C_PORT_ENABLE | x | 无 |
| PORT_STATUS_SUSPEND | FEATURE_C_PORT_SUSPEND | x | 无 |
| PORT_STATUS_OVER_CURRENT | FEATURE_C_PORT_OVER_CURRENT | x | 无 |
| HUB_STATUS_LOCAL_POWER | FEATURE_C_HUB_LOCAL_POWER | x | 更新 HubState |
| HUB_STATUS_OVER_CURRENT | FEATURE_C_HUB_OVER_CURRENT | x | ESD恢复, 标记删除 |
驱动层 PnP管理器 总线驱动
───────────────────────────────────────────────────────────────────
CONNECT事件
│
▼
IoInvalidateDeviceRelations(BusRelations)
│
└────────────► PnP管理器收到通知
│
▼
延迟执行 QueryBusRelations
│
▼
等待端口状态稳定
│
▼
检测到端口 ENABLE
│
▼
开始设备枚举
│
└────────────► Get Device Descriptor
| 时间点 | 驱动动作 | PnP动作 |
|---|---|---|
| T1 | CONNECT 事件 | - |
| T2 | IoInvalidateDeviceRelations | 收到通知,标记需要重新枚举 |
| T3 | RESET 事件 | 等待端口就绪 |
| T4 | ENABLE 事件 | 确认端口就绪 |
| T5 | - | 开始枚举设备 |
驱动调用 IoInvalidateDeviceRelations
│
▼
PnP管理器放入工作队列
│
▼
延迟一段时间(通常数毫秒)
│
▼
检查端口状态是否稳定
│
▼
如果端口 ENABLED → 开始枚举
如果端口 DISABLED → 等待或取消
// USB 1.1: 11.16.2.6.1 Port Status Bits, Table 11-15. Port Status Field, wPortStatus
// USB 2.0: 11.24.2.7.1 Port Status Bits, Table 11-21. Port Status Field, wPortStatus
//
typedef union _USB_20_PORT_STATUS {
USHORT AsUshort16;
struct {
USHORT CurrentConnectStatus:1; // 0
USHORT PortEnabledDisabled:1; // 1
USHORT Suspend:1; // 2
USHORT OverCurrent:1; // 3
USHORT Reset:1; // 4
USHORT L1:1; // 5
USHORT Reserved0:2; // 6-7
USHORT PortPower:1; // 8
USHORT LowSpeedDeviceAttached:1; // 9
USHORT HighSpeedDeviceAttached:1; // 10 (USB 1.1 Reserved)
USHORT PortTestMode:1; // 11 (USB 1.1 Reserved)
USHORT PortIndicatorControl:1; // 12 (USB 1.1 Reserved)
USHORT Reserved1:3; // 13-15
};
} USB_20_PORT_STATUS, *PUSB_20_PORT_STATUS;
本文链接为:http://www.usbzh.com/article/detail-1162.html ,欢迎转载,转载请附上本文链接。
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936 USB技术交流3:1031974172
USB2.0集线器HUB





