如何确定Windows上的USB端口版本?

How to determine USB port version on Windows?

我 运行 Windows 7 和 Python 3.5。 连接 U 盘后,我的目标是确定它连接的端口版本(2.0、3.0、3.1)以及 U 盘支持的 USB 版本。 任何想法表示赞赏。

你应该看看微软的USBView

它使用Windows API 获取有关每个USB 端口和每个设备的信息并显示这些信息。此信息包括 USB 端口支持的速度和设备正在使用的速度。

您可以 运行 它作为 GUI,或者您可以 运行 它带有这样的参数以使其将其数据保存到文本文件:

usbview /saveall:usb.txt

下面是一段文本输出,其中显示了您对我的 USB 耳机感兴趣的信息:

Is Port User Connectable:         yes
Is Port Debug Capable:            no
Companion Port Number:            1
Companion Hub Symbolic Link Name: USB#VID_0451&PID_8046#5&16bdd27b&0&22#{f18a0e88-c30c-11d0-8815-00a0c906bed8}
Protocols Supported:
 USB 1.1:                         yes
 USB 2.0:                         yes
 USB 3.0:                         no

Device Power State:               PowerDeviceD0

       ---===>Device Information<===---
English product name: "Logitech G930 Headset"

ConnectionStatus:
Current Config Value:              0x01  -> Device Bus Speed: Full (is not SuperSpeed or higher capable)
Device Address:                    0x09
Open Pipes:                           1

USBView 是开源的,甚至还有一个 MSYS2 包,因此您无需编译任何东西即可试用。您也可以从 Microsoft 找到预编译的二进制文件。

最简单的方法可能是从您的 Python 程序到 运行 USBView 并解析其文本输出。另一种选择是查看 source code for USBView 并以某种方式将其转换为 Python 或对其进行 Python C 扩展。