USB百科
+ -

伴随端口CompanionPortNumber与伴随HUB链接名CompanionHubSymLnk

2026-09-29 本文链接为:http://www.usbzh.com/article/detail-1810.html ,欢迎转载,转载请附上本文链接。

通过IOCTL_USB_GET_PORT_CONNECTOR_PROPERTIES获取的结构信息如下:

typedef struct _USB_PORT_CONNECTOR_PROPERTIES {
    // one based port number
    ULONG  ConnectionIndex;

    // The number of bytes required to hold the entire USB_PORT_CONNECTOR_PROPERTIES
    // structure, including the full CompanionHubSymbolicLinkName string
    ULONG  ActualLength;

    // bitmask of flags indicating properties and capabilities of the port
    USB_PORT_PROPERTIES  UsbPortProperties;

    // Zero based index number of the companion port being queried.
    USHORT                CompanionIndex;

    // Port number of the companion port
    USHORT                CompanionPortNumber;

    // Symbolic link name for the companion hub
    WCHAR                 CompanionHubSymbolicLinkName[1];
} USB_PORT_CONNECTOR_PROPERTIES, *PUSB_PORT_CONNECTOR_PROPERTIES;

其中

  • ConnectionIndex:该端口号
  • CompanionPortNumber:是该端品对应的伴随端口
  • CompanionHubSymbolicLinkName:端口对应的伴随端口所在的HUB的链接名

例用usbtreeviewer也可以快速速看到该信息,点击任意一HUB,即可以看到类似的信息:

    =========================== USB Port2 ===========================

Connection Status        : 0x01 (Device is connected)
Port Chain               : 1-1-2
Properties               : 0x01
 IsUserConnectable       : yes
 PortIsDebugCapable      : no
 PortHasMultiCompanions  : no
 PortConnectorIsTypeC    : no
ConnectionIndex          : 0x02 (Port 2)
CompanionIndex           : 0
 CompanionHubSymLnk      : USB#VID_05E3&PID_0626#5&31036e8e&0&13#{f18a0e88-c30c-11d0-8815-00a0c906bed8}
 CompanionPortNumber     : 0x02 (Port 2)
 -> CompanionPortChain   : 1-13-2

图例如下:

                        物理世界
        ┌─────────────────────────────────────────┐
        │        USB 3.0 Type-A 连接器(1个)        │
        │   ┌──────────────┐  ┌──────────────┐    │
        │   │  USB 2.0 引脚 │  │ SuperSpeed 引脚│    │
        │   └──────┬───────┘  └──────┬───────┘    │
        └──────────┼─────────────────┼────────────┘
                   │                 │
                   │                 │
        ┌──────────▼───────┐  ┌──────▼────────────┐
        │  USB 2.0 HUB     │  │  USB 3.0 HUB      │
        │  (逻辑 HUB A)     │  │  (逻辑 HUB B)      │
        │                  │  │                   │
        │  Port 7  ◄───────┼──┼──► Port 3         │
        └──────────┬───────┘  └──────┬────────────┘
                   │                 │
                   │                 │
        ┌──────────▼─────────────────▼────────────┐
        │            Windows USB 栈                │
        │                                         │
        │  查询 HUB A 的 Port 7 时:                │
        │    ConnectionIndex            = 7       │
        │    CompanionPortNumber        = 3       │
        │    CompanionHubSymbolicLinkName         │
        │        ──► 指向 HUB B 的符号链接          │
        │                                         │
        │  查询 HUB B 的 Port 3 时:                │
        │    ConnectionIndex            = 3       │
        │    CompanionPortNumber        = 7       │
        │    CompanionHubSymbolicLinkName         │
        │        ──► 指向 HUB A 的符号链接          │
        └─────────────────────────────────────────┘

获取方式如下:

    UCHAR buff[512];
    PUSB_PORT_CONNECTOR_PROPERTIES props = (PUSB_PORT_CONNECTOR_PROPERTIES)buff;
    props->ConnectionIndex = PortIndex;
    props->CompanionIndex = 0;

    if (!DeviceIoControl(hDevice,
        IOCTL_USB_GET_PORT_CONNECTOR_PROPERTIES,
        buff, sizeof(buff),
        buff, sizeof(buff),
        &bytes, NULL))
    {
        return;
     }
本文链接为:http://www.usbzh.com/article/detail-1810.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

0 篇笔记 写笔记

USB 配对/伴随端口(Companion Port)
今天本站USB中文网的群内用户有人问了一个问题:- 请问usb tree view出现的Companion Port怎么翻译?有什么作用?我打开自己的USBtreeview发现没有这个信息,猜测是我的版本太低,重新下载了一个最新的,果然后到了这个信息。可以看到,当打开某些USB设备的时候,收现了如......
伴随端口CompanionPortNumber与伴随HUB链接名CompanionHubSymLnk
通过IOCTL_USB_GET_PORT_CONNECTOR_PROPERTIES获取的结构信息如下:typedef struct _USB_PORT_CONNECTOR_PROPERTIES { // one based port number ULONG Connection......
关注公众号
  • HID人机交互
  • Linux&USB
  • UAC音频
  • CDC
  • TYPE-C
  • USB规范
  • USB大容量存储
  • USB百科
  • USB周边
  • UVC摄像头
  • Windows系统USB
  • USB资源
  • 音视频博客
  • 取消
    感谢您的支持,我会继续努力的!
    扫码支持
    扫码打赏,你说多少就多少

    打开支付宝扫一扫,即可进行扫码打赏哦

    您的支持,是我们前进的动力!