Skip to content
Advertisement

How to find out which USB-RS232 device is on which tty?

I have two different USB devices based on the same USB-RS232 chips. When I plug those in the USB they are mounted to /dev/ttyUSB0…3

My problem is how, inside a script, I can find out which one is on what tty?

Using lsusb I can differentiate them:

JavaScript

And using dmesg I can tell where they were mounted:

JavaScript

But “usb 4-1” does not seem to correspond to “Bus 004 Device 002”.

Can I assume that “Bus 004 Device 001” will always be an “USB root hub” and thus dmesg will count from 1 onwards and lsusb from 2 onwards?

Or do you have another suggestion on how to correlate device ID to mount point (inside a script)?

I’m using Ubuntu 10.04 LTS.

Advertisement

Answer

Find more info using sysfs:

JavaScript

Of course, the linked devices/… node contains a lot of information

Adding information based on the OP’s comment:

The device number keeps growing if devices are removed/inserted. lsusb -t can be used to correlate the device numbers with usb bus/port.

Then, ‘lsusb -d devID’ can determine what device is on which port. Finally ‘ls /sys/bus/usb-serial/devices/ -ltrah’ will list (by bus/port) where it was mounted.

Not very convenient, but it ‘works

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement