Teensy 4.1 USB Triple Serial Linux Naming

Hello,

Background:
I'm trying to utilize the triple serial mode of USB on a Teensy 4.1 and I'm having issues with naming in Linux. There is another device that exists in the computer I'm connecting the Teensy to that generates a serial port that I cannot disable. This creates a problem because depending on the order on boot, if the Teensy is plugged in, sometimes the Teensy gets /dev/ttyACM0, ACM1, and ACM3 and then the internal device gets ACM2. Other times the Teensy gets ACM0, ACM2 and ACM3 and the internal device gets ACM1. The only way to guarantee the Teensy gets specific number ordering is to ensure the other internal device has started its serial port and gets ACM0 before plugging in the Teensy. This is unrealistic in my use-case because the computer is always remotely controlled through VNC and is physically hard to access so I want to be able to plug in the Teensy permanently and never have to touch it.

Question:
Is there a way to give specific names to specific serial ports on the Teensy? Can I choose the name it broadcasts to the computer?

Other ideas:
I have played a little bit with Udev rules but have not been able to figure out how to handle multiple serial ports that are specific enough to not include the other internal serial device. This leads me back to the idea of modifying the USB info that is broadcast to Linux.

Thanks!
 
All the serial device names in Linux are created via the udev rules subsystem. The standard rules for naming serial devices are given in /lib/udev/rules.d/60-serial.rules. If you look in here you see that usb serial devices as well as having names created directly under /dev also have links to those names created under /dev/serial/by-id and /dev/serial/by-path.

roger@dragon:/dev/serial$ ls -l by-id
total 0
lrwxrwxrwx 1 root root 13 Feb 21 18:44 usb-Teensyduino_Dual_Serial_12205920-if00 -> ../../ttyACM0
lrwxrwxrwx 1 root root 13 Feb 21 18:44 usb-Teensyduino_Dual_Serial_12205920-if02 -> ../../ttyACM1
roger@dragon:/dev/serial$ ls -l by-path
total 0
lrwxrwxrwx 1 root root 13 Feb 21 18:44 pci-0000:00:14.0-usb-0:11.2:1.0 -> ../../ttyACM0
lrwxrwxrwx 1 root root 13 Feb 21 18:44 pci-0000:00:14.0-usb-0:11.2:1.2 -> ../../ttyACM1

The last part of the by-id and by-path names encodes the USB CDC channel number which is fixed by by the Teensy core software.

The answer to your question is that the Teensy does not broadcast the names. It uses the standard usb bus protocol to communicate to the host . The host operating system then uses that information to set up its means of communicating with the device. In Linux this is udev. Udev "names" devices by creating nodes in the dev filesystem. Other system (e.g. windoze) use there own mechanisms. On Linux by writing your own udev rules you can create any device name you want.

I would strongly recommend NOT writing your own udev rules unless you have to! The standard ones I discussed above should suffice.
 
Back
Top