I have a machine (Debian/Ubuntu/CentOS mostly) that works like a kiosk, and there a few devices connected to it, using serial and USB ports. The software of these devices should know the port numbers, meaning device A is connected to /dev/ttyUSB0, device B to /dev/ttyUSB1, device C to /dev/ttyS0 and so on. Can I be certain that after a restart or kernel update, etc., these port numbers won't change, or should I have some other method to determine what's where?
1 Answer
You need to write a udev rule to assign consistent names based on which USB port the USB serial port adapter is plugged in to or the adapter's serial number.
I'm on my phone at the moment but I'll update the answer when I get back to my laptop and can add an example.
/dev/serial/by-id/*
or/dev/serial/by-path/*
links instead of/dev/ttyUSB*
. Or create your own link based on the device's attributes via an udev rule. See eg. this but there are lot of other answers and tutorials.