连接到 HUB 的 USB 设备的 KERNELS 路径
时间: 2024-02-11 08:04:49 浏览: 106
USB设备连接
4星 · 用户满意度95%
连接到HUB的USB设备的KERNELS路径通常可以通过以下步骤找到:
1. 运行`lsusb`命令,查看USB设备的Vendor ID和Product ID。例如,假设我们要查找连接到HUB上的USB鼠标设备,可以运行以下命令:
```
$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 001 Device 005: ID 05e3:0612 Genesys Logic, Inc. Hub
Bus 001 Device 004: ID 05e3:0745 Genesys Logic, Inc. Logilink CR0012
Bus 001 Device 002: ID 05e3:0610 Genesys Logic, Inc. 4-port hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
```
从输出中可以看到,该鼠标设备的Vendor ID为046d,Product ID为c077。
2. 进入/sys/bus/usb/devices目录,查找对应的USB设备节点。例如,在上面的输出中,该鼠标设备连接到了Bus 001的Device 006,因此我们可以进入/sys/bus/usb/devices/1-3目录,查看该设备的KERNELS路径:
```
$ cd /sys/bus/usb/devices/1-3
$ ls -l
total 0
drwxr-xr-x. 4 root root 0 Apr 20 17:20 1-3:1.0
lrwxrwxrwx. 1 root root 0 Apr 20 17:20 bDeviceClass -> ../../../../../../../class/input/
lrwxrwxrwx. 1 root root 0 Apr 20 17:20 bDeviceProtocol -> ../../../../../../../class/input/mouse0/protocol
lrwxrwxrwx. 1 root root 0 Apr 20 17:20 bDeviceSubClass -> ../../../../../../../class/input/
lrwxrwxrwx. 1 root root 0 Apr 20 17:20 bcdDevice -> ../../../../../../../class/input/mouse0/version
lrwxrwxrwx. 1 root root 0 Apr 20 17:20 bus -> ../../../../../../../bus/usb/
lrwxrwxrwx. 1 root root 0 Apr 20 17:20 configuration -> ../../../../../../../usb1/1-3/1-3:1.0/configuration
-rw-r--r--. 1 root root 4.0K Apr 20 17:20 descriptors
-rw-r--r--. 1 root root 4.0K Apr 20 17:20 devnum
lrwxrwxrwx. 1 root root 0 Apr 20 17:20 device -> ../../../../../../../usb1/1-3/
-rw-r--r--. 1 root root 4.0K Apr 20 17:20 idProduct
-rw-r--r--. 1 root root 4.0K Apr 20 17:20 idVendor
-rw-r--r--. 1 root root 4.0K Apr 20 17:20 maxchild
drwxr-xr-x. 2 root root 0 Apr 20 17:20 power
lrwxrwxrwx. 1 root root 0 Apr 20 17:20 product -> ../../../../../../../usb1/1-3/1-3:1.0/product
-r--r--r--. 1 root root 4.0K Apr 20 17:20 quirks
-rw-r--r--. 1 root root 4.0K Apr 20 17:20 speed
lrwxrwxrwx. 1 root root 0 Apr 20 17:20 subsystem -> ../../../../../../../bus/usb/
-rw-r--r--. 1 root root 4.0K Apr 20 17:20 uevent
lrwxrwxrwx. 1 root root 0 Apr 20 17:20 usb_device -> ../../../../../../../usb1/1-3/
```
从输出中可以看到,该鼠标设备的KERNELS路径为1-3:1.0。
因此,连接到HUB的USB设备的KERNELS路径通常是/sys/bus/usb/devices/<Bus>-<Device>:<Interface>,其中Bus和Device是通过`lsusb`命令获得的,Interface通常为0或1。
阅读全文