How to determine which physical port is connected to which tty path?

I have a device (An NVIDIA Jetson Nano) with four USB ports. How can I tell which /dev/tty* locations are mapped to each of these?

I have gone through many similar questions here and on askUbuntu. I have been trying lsusb, dmesg | grep tty, usb-devices, but quite frankly I don't have a clue what I'm doing with this information.

lsusb was the only command I could vaguely understand. By moving a USB dongle from port to port I thought I could determine the bus and device numbers. Until I got to the last port, whereupon I swapped the dongle who's ID I knew with the keyboard that had been in that port for the first three tests, and realized that the device numbers aren't even static. The keyboard had been Bus 001 Device 005 for the first three tests but the same port was Bus 001 Device 010 now that it had the dongle (and the port that had held the dongle had been 009 and was now 011 with the keyboard, so it seemed to just be incrementing). So I don't see how this information is at all useful. Plus, I wouldn't know how to get a device path from the device number even if I trusted these numbers.

dmesg | grep tty just lists a few of the available serial ports and does not change when I change the ports that devices are plugged into, so I can't see how to use that to learn anything. I tried repeating this command after playing around with lsusb, using the same method of moving the dongle around to the different ports, and now it outputs nothing, even when run as root.

usb-devices lists a ton of devices, way more than there's room for physically, and once again does not change its output when the state of the physical port changes.

Overall I really just don't know what I'm doing, so I apologize if I've misused any technical terms here and hope what I'm saying is clear from context. The Device/Port/Adapter/Bus distinctions elude me, so that might be part of why I'm having difficulty googling this. Thanks for any help!

8

1 Answer

First of all, confirm that your cables are functional. It's surprisingly common for a USB cable to fail at data transmission and you won't be able to tell unless you test it, so don't make assumptions. I went through 4 cables I thought were good before finding one that actually transmitted data in addition to power.

Second, I don't know if this is the most elegant solution, but what I ended up getting working was basically a combination of ls and diff to determine when a new file appeared in /dev.

Start with your device unplugged by using ls /dev > device_names.txt (or any filepath of your choice instead of device_names.txt) to write all the device names currently available to a file. Next, plug in your device to the port you care about and use ls /dev | diff - device_names.txt to get the differences between the current list of device names and the list prior to plugging in your device.

In my case, this revealed my device took ttyACM0 on that port. I still don't know if this is determined entirely by the device and has nothing to do with the physical port... if this is the case, then the original question makes no sense, but oh well.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like