简体   繁体   中英

How can I link the result of lsusb devices to /dev/ttyUSB*

I have the vendor and product code of a USB product: 0403:6001

I would like to know how can I link easily the result of lsusb command with the determination of a device on /dev/ttyUSB*

lsusb give me

Bus 001 Device 004: ID 065a:a001 First device 

Bus 001 Device 003: ID 0403:6001 Second device FT232 USB-Serial (UART) 

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

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

How can I know if this device is on /dev/ttyUSB0 or 1 or 2 If I have several USB Devices on my PC

Thanks in advance

Background def: The configuration is not the same at everytime

The USB Device can be plugged or unplugged and others devices too...

Assuming you have udev:

shopt -s nullglob
for i in /dev/ttyUSB*; do 
  udevadm info -r -q all "$i" | awk -F= '
     /DEVNAME/{d=$2}
     /ID_VENDOR_ID/{v=$2}
     /ID_MODEL_ID/{m=$2}
     d&&v&&m{print d,v":"m;d=v=m=""}
  '
done

udevadm is the command to get all information about the usb device. The awk command just filters the USB path and class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM