简体   繁体   English

如何将 lsusb 设备的结果链接到 /dev/ttyUSB*

[英]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我有 USB 产品的供应商和产品代码: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 命令的结果与/dev/ttyUSB*上设备的确定联系起来

lsusb give me lsusb给我

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如果我的 PC 上有多个 USB 设备,我怎么知道这个设备是在/dev/ttyUSB0还是 1 或 2 上

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... USB 设备可以插入或拔出,其他设备也可以...

Assuming you have udev:假设你有 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. udevadm是获取有关 usb 设备的所有信息的命令。 The awk command just filters the USB path and class. awk 命令只过滤 USB 路径和 class。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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