我有一个设备连接到我的 Debian Linux 机器,lsusb 说:
Bus 002 Device 005: ID 0525:a4a7 Netchip Technology, Inc. Linux-USB Serial Gadget (CDC ACM mode)
在
/sys/bus/usb/devices/
我有
drwxr-xr-x 4 root root 0 Sep 7 14:27 ..
lrwxrwxrwx 1 root root 0 Sep 7 14:27 1-0:1.0 -> ../../../devices/pci0000:00/0000:00:1a.7/usb1/1-0:1.0
lrwxrwxrwx 1 root root 0 Sep 7 14:27 2-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-0:1.0
lrwxrwxrwx 1 root root 0 Sep 13 08:32 2-3 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-3
lrwxrwxrwx 1 root root 0 Sep 13 08:32 2-3:2.0 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-3/2-3:2.0
lrwxrwxrwx 1 root root 0 Sep 13 08:32 2-3:2.1 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-3/2-3:2.1
lrwxrwxrwx 1 root root 0 Sep 7 14:27 3-0:1.0 -> ../../../devices/pci0000:00/0000:00:1a.0/usb3/3-0:1.0
lrwxrwxrwx 1 root root 0 Sep 7 14:27 4-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.0/usb4/4-0:1.0
lrwxrwxrwx 1 root root 0 Sep 7 14:27 5-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.1/usb5/5-0:1.0
lrwxrwxrwx 1 root root 0 Sep 7 14:27 6-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.2/usb6/6-0:1.0
lrwxrwxrwx 1 root root 0 Sep 7 14:27 usb1 -> ../../../devices/pci0000:00/0000:00:1a.7/usb1
lrwxrwxrwx 1 root root 0 Sep 7 14:27 usb2 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2
lrwxrwxrwx 1 root root 0 Sep 7 14:27 usb3 -> ../../../devices/pci0000:00/0000:00:1a.0/usb3
lrwxrwxrwx 1 root root 0 Sep 7 14:27 usb4 -> ../../../devices/pci0000:00/0000:00:1d.0/usb4
lrwxrwxrwx 1 root root 0 Sep 7 14:27 usb5 -> ../../../devices/pci0000:00/0000:00:1d.1/usb5
lrwxrwxrwx 1 root root 0 Sep 7 14:27 usb6 -> ../../../devices/pci0000:00/0000:00:1d.2/usb6
如何找出这是哪个设备?
答案1
我找到/修改了一个脚本来/sys
根据lsusb
输出获取设备。
#!/bin/bash
#
# usb2sys - find lsusb device in /sys file system
#
die()
{
echo "$@"
exit 1
}
[[ $# -lt 1 ]] && die "need vendor and product ids (from lsusb) as dddd:dddd"
vendor=${1%:*}
product=${1##*:}
sys=/sys/bus/usb/devices/
cd $sys
for d in *; do
path=$sys$d
if [ -f $path/idProduct ]; then
prod=$( cat $path/idProduct )
vend=$( cat $path/idVendor )
if [ $prod = $product -a $vend = $vendor ]; then
echo prod = $prod
echo vend = $vend
echo /sys device is $path
fi
fi
done
这个想法是获取字符串1d6b:0002
并再次检查哪个是一idProduct:idVendor
对并将其与现有的进行usb
比较/sys
你可以像这样使用脚本
lsusb | cut -d ' ' -f 6 | xargs -L 1 ./usb2sys
输出结果如下
prod = 0002
vend = 1d6b
/sys device is /sys/bus/usb/devices/usb1
答案2
使用cat /sys/bus/usb/devices/2*/manufacturer
并逐步向2*
部分添加数字..例如2-3:*
,2-3:2.*
直到您可以匹配名称,或者使用idProduct
或idVendor
代替manufacturer
。