How to identify multiple USB-serial adapters under Ubuntu 10.1

后端 未结 7 1414
无人共我
无人共我 2020-12-29 13:54

I am reading data from multiple identical USB-serial adapters under Ubuntu 10.1.

On occasion, their /dev/tty path changes (eg if other USB devices are connected on s

7条回答
  •  清歌不尽
    2020-12-29 14:07

    I too was searching this topic for a way to find which physical USB device was assigned/connected to a logical /dev device name. So, after some trial and error, this is what worked best for me:

    See what logical ttyUSBx devices exist (where x is 0, 1, 2...):

    $ ls /dev
    

    Show bus and device numbers for all usb-serial adapters:

    $ lsusb 
    

    Finally, use:

    $ udevadm info --name=ttyUSBx --attribute-walk | grep num  
    

    Now inspect the udevadm output to match the logical device name to the actual physical device. Here my listing when I did it:

    $ lsusb
    Bus 002 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial     (UART) IC
    Bus 002 Device 004: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
    Bus 002 Device 002: ID 80ee:0021  
    Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    
    $ udevadm info --name=ttyUSB0 --attribute-walk | grep num
        ATTRS{port_number}=="0"
        ATTRS{urbnum}=="812"
        ATTRS{busnum}=="2"
        ATTRS{devnum}=="5"
        ATTRS{urbnum}=="115"
        ATTRS{busnum}=="2"
        ATTRS{devnum}=="1"
        ATTRS{numa_node}=="-1"
    
    $ udevadm info --name=ttyUSB1 --attribute-walk | grep num
        ATTRS{port_number}=="0"
        ATTRS{urbnum}=="465"
        ATTRS{busnum}=="2"
        ATTRS{devnum}=="4"
        ATTRS{urbnum}=="115"
        ATTRS{busnum}=="2"
        ATTRS{devnum}=="1"
        ATTRS{numa_node}=="-1"
    

    So, in my case, ttyUSB0 is associated with the device on bus2, device5, which is the Future Technology Devices International USB to Serial Adapter; and likewise, ttyUSB1 is associated with the device on bus2, device4, which is the Prolific Technology, Inc. USB to Serial adapter.

    And as has been pointed out, the command:

    $ usb-devices
    

    Will get you the same info in a one-line manner. I thought I'd post the details that helped me learn how the stuff worked behind the scenes...

    Hope that was helpful :)

提交回复
热议问题