0
votes

I Have two usb->serial adapters, both ftdi, lets name them ftdiA, and ftdiB. The device (in this case raspberry pi but it is kind of irrelevant) has 2 USB ports, let's name them 'top' and 'bottom'.

Is there a way to create udev rule so, that no matter which adapter is used in top port it gets name for example /dev/ttyUSBTop

I would like to name them based on the port where they were plugged in. Even if there is a ftdiC adapter plugged in top port its name should be /dev/ttyUSBTop

Is it possible for xxxxA device that is not ftdi, but moschip, pl2013, or some other manufacturer that also creates /dev/ttyUSBX device, to get the same name based on connection -> /dev/ttuUSBTop or /dev/ttyUSBBottom?

I cant find similar request, all point to opposite requirement, they all want /dev/ttyUSBftdiA no matter where it is plugged in.

1

1 Answers

1
votes

There is already a rules file (60-persistent-serial.rules) that creates pretty paths in /dev/serial/by-path/ that match the port. For example, when my USB serial device got inserted in a USB 3.0 port:

$ ls -l serial/by-path/
total 0
lrwxrwxrwx 1 root root 13 Apr  2 22:20 pci-0000:02:00.0-usb-0:1:1.0-port0 -> ../../ttyUSB0

And when the same device is connected to a different USB 2.0 port:

$ ls -l /dev/serial/by-path/
total 0
lrwxrwxrwx 1 root root 13 Apr  2 22:20 pci-0000:00:1d.0-usb-0:1.2:1.0-port0 -> ../../ttyUSB0