0

Faced with:

root@conserver01:/home/owen# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M
        |__ Port 1: Dev 3, If 0, Class=Hub, Driver=hub/4p, 5000M
        |__ Port 2: Dev 4, If 0, Class=Hub, Driver=hub/4p, 5000M
        |__ Port 3: Dev 5, If 0, Class=Hub, Driver=hub/4p, 5000M
        |__ Port 4: Dev 6, If 0, Class=Hub, Driver=hub/4p, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M
            |__ Port 1: Dev 4, If 0, Class=Hub, Driver=hub/4p, 480M
                |__ Port 3: Dev 13, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 12M
                |__ Port 1: Dev 6, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 12M
                |__ Port 4: Dev 15, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 12M
                |__ Port 2: Dev 9, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 12M
            |__ Port 2: Dev 5, If 0, Class=Hub, Driver=hub/4p, 480M
                |__ Port 4: Dev 16, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 12M
                |__ Port 2: Dev 12, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 12M
                |__ Port 3: Dev 14, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 12M
                |__ Port 1: Dev 8, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 12M
            |__ Port 3: Dev 7, If 0, Class=Hub, Driver=hub/4p, 480M
                |__ Port 1: Dev 11, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 12M
            |__ Port 4: Dev 10, If 0, Class=Hub, Driver=hub/4p, 480M

And:

root@conserver01:/home/owen# ls -al /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Jun 17 03:49 /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 1 Jun 17 03:50 /dev/ttyUSB1
crw-rw---- 1 root dialout 188, 2 Jun 17 03:51 /dev/ttyUSB2
crw-rw---- 1 root dialout 188, 3 Jun 17 03:54 /dev/ttyUSB3
crw-rw---- 1 root dialout 188, 4 Jun 17 03:54 /dev/ttyUSB4
crw-rw---- 1 root dialout 188, 5 Jun 17 03:55 /dev/ttyUSB5
crw-rw---- 1 root dialout 188, 6 Jun 14 20:20 /dev/ttyUSB6
crw-rw---- 1 root dialout 188, 7 Jun 14 20:20 /dev/ttyUSB7
crw-rw---- 1 root dialout 188, 8 Jun 14 20:20 /dev/ttyUSB8

I'd like to accomplish two things:

  1. A way to match the lsusb output line to the /dev entry.
  2. A way to create a consistent relationship between a port on the USB hub (or the particular FTDI adapter, either is acceptable/useful) and the /dev/ entry.

Any help much appreciated. I know this is similar to at least one other previously posted question, but the question was vague and the answers look like they approach, but don't quite achieve what I want. I'm hoping that my question is more clear.

Please note, also, I'm not opposed to answers that use Linux resources outside of lsusb to achieve this, that's just the tool I'm most familiar with. The non-FTDI devices are included for completeness, but they are plugged into a 16 port Genesys Logic hub which appears to be implemented as 5 4-port Genesys Logic hubs stacked together internally.

3
  • Assuming your ftdi adapters have different serial numbers, it's easy to write a udev rule to create a fixed name symlink to the device with that serial number. lsusb -v will list the serial numbers.
    – user10489
    Jun 17 at 5:06
  • This might help: raspberrypi.stackexchange.com/questions/135927/…
    – user10489
    Jun 17 at 5:40
  • Do you not have some /dev/serial/by-{id,path...} on your system. Jun 17 at 5:50

2 Answers 2

1

readlink -f /sys/class/tty/ttyUSB0/device should give you something like:

/sys/devices/pci0000:00/0000:00:12.2/usb1/1-4/1-4.3/1-4.3.1/1-4.3.1:1.0/ttyUSB0

With full hardware path.

On most systems, I'd expect udev would also create some /dev/serial/by-path/<device-hardware-path> and /dev/serial/by-id/<device-id>:

$ readlink -f /dev/serial/by-path/pci-0000:00:12.2-usb-0:4.3.1:1.0-port0
/dev/ttyUSB0

udevadm info --name=ttyUSB0 should also give you plenty of information including that path.

1

Turns out that the solution is to have custom uDEV rules that create even more symlinks and then use the symlinks.

In my case, I chose to use the Device Serial Number from the manufacturer which is available (from FTDI devices at least) to the udev rules as "ID_SERIAL_SHORT". The uDEV rule I created is as follows: /etc/udev/rules.d/60-usb-serial.rules

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001",SYMLINK+="tty.FTDI.%E{ID_SERIAL_SHORT}"
EOT

Product 6001 Vendor 0403 is the FTDI serial adapters I am using.

This makes all the terminals available at /dev/tty.FTDI.:

root@conserver01:/home/owen# ls -la /dev/tty.FTDI*
lrwxrwxrwx 1 root root 7 Sep 19 23:06 /dev/tty.FTDI.A95VS8DR -> ttyUSB6
lrwxrwxrwx 1 root root 7 Sep 19 23:06 /dev/tty.FTDI.A9G9Q4LI -> ttyUSB3
lrwxrwxrwx 1 root root 7 Sep 19 23:06 /dev/tty.FTDI.A9SS5W0V -> ttyUSB4
lrwxrwxrwx 1 root root 7 Sep 19 23:06 /dev/tty.FTDI.A9TYJTXQ -> ttyUSB1
lrwxrwxrwx 1 root root 7 Sep 19 23:06 /dev/tty.FTDI.A9VSKAKD -> ttyUSB7
lrwxrwxrwx 1 root root 7 Sep 19 23:06 /dev/tty.FTDI.A9X5K7PH -> ttyUSB0
lrwxrwxrwx 1 root root 7 Sep 19 23:06 /dev/tty.FTDI.AQ017QQB -> ttyUSB2
lrwxrwxrwx 1 root root 7 Sep 19 23:06 /dev/tty.FTDI.AQ017USH -> ttyUSB5

Whenever I reboot, the associations at the end of the symlink tend to change, but I don't care because my /etc/conserver/conserver.cf file references the FTDI names and those get consistently connected to the correct device by its serial number.

This has the added advantage that I no longer need to worry about which port the device is connected to on which hub, I just need to keep the RJ-45 end of the cable plugged into the device I expect or modify conserver.cf when I move it to a different device.

Thanks for the pointers that were provided. They did help me find the solution even though they didn't get me all the way there. Hopefully some other conserver user finds this useful.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .