Setting specifc USB ports by kernel number

I have a pretty specific problem for my use case, I have multiple USB RFID card readers that I am plugging into my RaspberryPi 4,

They each have the same vendor and product ID as well as the same serial number, so in order to know which is which I have resorted to using Kernel Symlinks, when I plug in the deskop reader into the top left port of the Pi, it reads /dev/ttyDesktopReader

This is how I solved it in a straight raspbian OS
KERNEL==“ttyUSB*”, KERNELS==“1-1.3”, SYMLINK+=“ttyDesktopReader”
KERNEL==“ttyUSB*”, KERNELS==“1-1.2”, SYMLINK+=“ttyDesktopReader2”
KERNEL==“ttyUSB*”, KERNELS==“1-1.1”, SYMLINK+=“ttyPrinterReader”

In the following folder - sudo nano /etc/udev/rules.d/serial-symlinks.rules

I have been trying to figure out how to dockerize this and use it in balena, specifically balenalib/rpi-node:10-stretch-run

Does anyone know if this is possible?

Hi there, handling udev rules is definitely possible, here’s a repo with some udev example settings: Give that a shot and let us know how it goes. Cheers!

1 Like

Thanks @sradevski,

I got it working by copying:
SUBSYSTEM=="tty", KERNELS=="1-1.1", SYMLINK+="ttyDesktopReader"
Into my /etc/udev/rules.d container folder
For anyone else stuck, this helped me understand the dev linking structure:
udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0)