Have 2 Teensy's on an RPi, need toi dentify on boot and assign to specific /dev/ttyX

TopNotchRally

New member
I am running a Raspberry Pi (Rasbian) with 2 Teensy 4.0 (3x CAN boards) attached on USB. On boot up they are randomly assigned /dev/ttyACM0 and /dev/ttyACM1.

I need to specify which one is ACM0 and ACM1. I found info about udevadm but for it to work there has to be uniquely identifiable tags in udevadm info -a -n /dev/ttyACM0 and there is not (that I could find).

To be clear on boot up I need to assign Teensy0 to /dev/ttyACM0 and Teensy1 to /dev/ttyACM1

Please assist is solving this issue. Thanks.

Here's is the output from udevadm info -a -n /dev/ttyACM0 for each /dev/

https://jimster.ca/files/acm0.txt
https://jimster.ca/files/acm1.txt
 
Last edited:
Not sure if there is any better answer, or if this helps, but this "serial" is unique to the Teensy
Code:
  looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2':
...
    ATTRS{serial}=="12508710"

Both attached files are ACM1.txt with same "serial" #
 
I fixed the links in the post, so both files are there. (cut paste error)

You are right the serial is unique! Thanks! I didn't see that. I will try again to make a rule to assign them to a specific /dev

Screen Shot 2023-11-02 at 11.12.09 AM.png
 
For anyone else facing this. I ended using the below instructions which worked perfectly. This is the line that goes in the .rules file

SUBSYSTEM=="tty", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="0483", SYMLINK+="ttyTSY%E{ID_SERIAL_SHORT}"
Each teensy then becomes /dev/ttyTSY0123456 where 0123456 is the serial number.
 
I ran into this using a PI to drive an HDMI touchscreen and two teensy's collecting data in our Airstream RV... Had the python code on the Pi. I simply had two different messages being sent - and let the serial decoder put the data based on the message received. Now it became serial number agnostic. If I had the code for the water and AC on a teensy, it sent those messages and the Pi put that data where it belonged. If it came from the power system, it put that data where it needed to go on the display. It then also knew which teensy was which for sending commands back to the teensies.
 
Being Debian-based and given RaspberryPi.org's attention to standards compliance and accessibility, it almost certainly supports Linux-standard hot swap device nomenclature.

I have several "serial" devices and use the system's default "/dev/serial/by-id/..." directory to name them. My workstation is Xubuntu-20.04. I use the "by-id" trick in Ubuntu 18.04 systems at work as well, it's been available in many Linux distributions for years.

This workstation has an FTDI serial port, a RaspberryPi Pico running microPython, a two-port SiLabs home automation dongle and a Teensy 3.x. This setup shows how useful the by-id method can be.

Code:
$ ls -l /dev/serial/by-id/*
lrwxrwxrwx 1 root root 13 Nov 22 19:51 /dev/serial/by-id/usb-FTDI_Single_RS232-HS-if00-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Nov 24 22:32 /dev/serial/by-id/usb-MicroPython_Board_in_FS_mode_e66038b7135db337-if00 -> ../../ttyACM1
lrwxrwxrwx 1 root root 13 Nov 22 19:51 /dev/serial/by-id/usb-Silicon_Labs_HubZ_Smart_Home_Controller_51501949-if00-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Nov 22 19:51 /dev/serial/by-id/usb-Silicon_Labs_HubZ_Smart_Home_Controller_51501949-if01-port0 -> ../../ttyUSB2
lrwxrwxrwx 1 root root 13 Nov 24 22:14 /dev/serial/by-id/usb-Teensyduino_USB_Serial_155740-if00 -> ../../ttyACM0
$
 
I know that there are many up here who do a whole lot more stuff on Linux than I do!


So for what it is worth, when I was doing Robotics stuff on Raspberry PIs (or BBK or Edison or Odroid, UP..) and
would like my code to talk to specific devices, like to whatever device I am using to talk to Dynamixel servos.

I do something to similar to:
SUBSYSTEM=="tty", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="0483", SYMLINK+="ttyTSY%E{ID_SERIAL_SHORT}"
Each teensy then becomes /dev/ttyTSY0123456 where 0123456 is the serial number.
I have my Dynamixel code first look for a specific device: /dev/ttyDXL... It has fallbacks if not found.

I then typically use udev rules setup to make that symbolic link to the specific actual device.
Something like:
Code:
SUBSYSTEM=="tty", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="06a7", ATTRS{serial}=="74031303437351D02210", SYMLINK+="ttyDXL"

I often would have another link setup for /dev/ttyXBEE and the like.

Good luck
 
I've been using Linux since 0.98 in the fall of 1992 at 2400 Baud. So cool seeing what you are doing with it and the tricks to get it to do what you want - I guess it's not tricks - these all look like pretty awesome features that are way over my head in some ways... I'm just an old school mechanical engineer... hahahaaa... I'm going to have to get smart on some of this some day. (Linux has been my primary machines all of these years - I despise windows)
 
Back
Top