ttyUSB ordering

I am working on a project involving the development of a device that interfaces with multiple ttyUSB ports, specifically 16 of them.

It’s important to note that Linux handles ttyUSB ports differently from Windows. In Linux, ttyUSB ports are typically labeled in the order they are connected, which contrasts with Windows where each USB device consistently receives a specific and unchanging COM port number (e.g., COM7 always corresponds to the same USB device, regardless of reconnections or machine reboots).

My primary objective is to ensure that the ttyUSB port numbering in Linux remains consistent even after a device reboot. However, my experiments have shown that Linux does not assign ttyUSB ports in a specific order based on USB connections.

As an illustration, when examining the output of dmesg | grep tty, you can observe that usb 1-2 corresponds to ttyUSB0, and usb 1-1 starts from ttyUSB1. It’s worth mentioning that usb 1-1 and usb 1-3 represents a USB-to-serial adapter with multiple serial ports.

If you have any insights or suggestions on how to achieve consistent ttyUSB port numbering in Linux, I would greatly appreciate your input.

dmesg | grep tty
- [    0.241124] printk: console [tty0] enabled
- [   98.575723] 00:03: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
- [  107.645192] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB0
- [  107.647738] usb 1-1: Moschip 7840/7820 USB Serial Driver converter now attached to ttyUSB1
- [  107.703274] usb 1-4: FTDI USB Serial Device converter now attached to ttyUSB5
- [  107.718566] usb 1-1: Moschip 7840/7820 USB Serial Driver converter now attached to ttyUSB2
- [  107.734340] usb 1-1: Moschip 7840/7820 USB Serial Driver converter now attached to ttyUSB3
- [  107.736637] usb 1-1: Moschip 7840/7820 USB Serial Driver converter now attached to ttyUSB4
- [  107.778240] usb 1-3: Moschip 7840/7820 USB Serial Driver converter now attached to ttyUSB6
- [  107.831044] usb 1-3: Moschip 7840/7820 USB Serial Driver converter now attached to ttyUSB7
- [  107.832354] usb 1-3: Moschip 7840/7820 USB Serial Driver converter now attached to ttyUSB8
- [  107.850976] usb 1-3: Moschip 7840/7820 USB Serial Driver converter now attached to ttyUSB9
Asked By: Saman.K

||

Creating udev rules seem to be the way… but I still haven’t fully implemented it because I cannot specify the USBs with there serial numbers…

Here is a good tutorial.

https://www.youtube.com/watch?v=BOxWrMNXKpU

edit: I have managed to identify them from the port that they are connected to.

KERNEL=="ttyUSB*", KERNELS=="1-4.1", MODE:="0666", SYMLINK+="aUSB1"
Answered By: Saman.K