Posts: 2
Joined: Fri Dec 09, 2016 1:26 am

Multiple USB for Serial Communication

Tue Dec 13, 2016 2:04 pm

Dear All,

I have some issue on how to bind the physical USB port to the ttyUSB number, it seems like the ttyUSB0 will always be assigned to the first detected USB device (here it is a USB to RS485 converter), and ttyUSB1 goes the second detected and so on. Thus, there is no guarantee that the device on the first port (assuming it is top row next to the RJ45 port) will be given ttyUSB0 when reboot. How to bind this port to be ttyUSB0 and the bottom row to be ttyUSB1?

Thank you in advance.

Posts: 42
Joined: Sat Mar 05, 2016 4:19 pm

Re: Multiple USB for Serial Communication

Tue Dec 13, 2016 4:23 pm

I fix the serial device names based on the USB port used with symlink and udev rather than trying to fix the name. To do similar you'll need to find what to search for by plugging them in one at a time and using udevadm to find the information to use.

Code: Select all

udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0)|less
You should see towards the top of the output a line with a "KERNELS==" like this
looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0':
Create/edit a udev file (say /etc/udev/rules.d/90-usb-serial.rules) and put the "KERNELS==..." part in there with the name you want to symlink to it.
KERNELS=="1-1.4:1.0" SYMLINK+="ttyTopRight"
Unplug/Replug and you should have a /dev/ttyTopRight link to the real USB device file which depends on the USB port it's plugged into rather than the order they're picked up in.

You can then use /dev/ttyTopRight in minicom/etc.

Return to “Beginners”