2

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?

  • You should use the /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. – mosvy Feb 24 at 11:17
  • @mosvy Can I expect that /dev/serial/by-id/* would be accessible by all/most Linux distributions? – Ne Nenne Feb 25 at 14:17
  • Almost. Some Linux systems like OpenWRT or Android don't have it. But all the "generic" distros (including Raspbian, etc) do. – mosvy Feb 25 at 17:16
1

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 aerial 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.

https://askubuntu.com/q/49910/121219

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.