如何查找某个USB设备插入的端口的PCI_ID

如何查找某个USB设备插入的端口的PCI_ID

Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p我想在下面的输出中找到 pci_id 。

/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 5, If 0, Class=Hub, Driver=hub/4p, 480M
            |__ Port 2: Dev 7, If 0, Class=Hub, Driver=hub/4p, 480M
                |__ Port 1: Dev 10, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 12M

我似乎找不到任何方法将其映射到这三个中的任何一个:

lspci -nn | grep USB
00:14.0 USB controller [0c03]: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI [8086:8c31] (rev 05)
00:1a.0 USB controller [0c03]: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 [8086:8c2d] (rev 05)
00:1d.0 USB controller [0c03]: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 [8086:8c26] (rev 05)

答案1

如果 Debaindiscover软件包可用,它将为您提供您正在寻找的信息

# discover --vendor-id --model-id pci | grep USB

答案2

经过更多的谷歌搜索、一些思考和一些尝试和错误后,我想出了这个:

#!/bin/bash
[ -h /sys/class/tty/ttyUSB0 ] || exit 1
pci_id=$( /usr/bin/realpath /sys/class/tty/ttyUSB0 | awk -F'/' '{print gensub(/....:(.*)/, "\\1","1",$5)}' )
usb_id=$( lspci -n| awk -v id=$pci_id '$0 ~ id {print $3}' )

运行时,它会为我提供上述场景所需的结果:

./get_usb.sh
8086:8c26

相关内容