Linux
如何找到某個 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)
經過更多的Google搜尋,一些想法和一些試驗和錯誤我想出了這個:
#!/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
如果 Debain
discover
軟體包可用,它將為您提供您正在尋找的資訊
# discover --vendor-id --model-id pci | grep USB