unchanging USB port names? (Linux)

I have two Arduinos now used by my Panda program.
SInce I’m on Linux and new to Linux, the port isn’t static, like “com3” and “com6”, I think it’s “ttyUSB0” for the first Arduino which is connected, and “ttyUSB1” for the second and so on. But since both are connected when the OS boots, can I be certain that the port names will remain the same? Or is there some other way to access ports by name (name is used by PySerial)?

Right, USB-to-serial devices don’t use the fixed serial port assignments on the computer.

I read that recent udev versions have a feature where you can access the devices by ID and by path. Try one of these:

ls -lAh /dev/serial/by-id/
ls -lAh /dev/serial/by-path/

If that lists device symlinks, you can then just open it with the path /dev/serial/by-id/usb-Something-Serial-Controller-if00-port0 where you would have otherwise used /dev/ttyUSB0.

An alternate solution would be to configure udev to assign the same device identifier for that particular device:
hintshop.ludvig.co.nz/show/persi … l-devices/

For a quick and simple hack, you can just use something like glob.glob("/dev/ttyUSB*")[0] to just grab the first device name in /dev that starts with ttyUSB.

What exactly will be in the place of “by-id/usb-Something-Serial-Controller-if00-port0”?
“by-id” I guess would be given by “s -lAh /dev/serial/by-id/” ,but not sure about the rest.
The udev thing is really confusing to me.
Thanks for the help, man.

I wouldn’t mind doing this. But if I have two Arduinos, I can’t really choose which one the first one in the list will be, right? Seems the exact same as referencing them by ttyUSB0 and ttyUSB1 and hoping to get in right order.

What is the output of these commands if you type it into the terminal?

ls -lAh /dev/serial/by-id/
ls -lAh /dev/serial/by-path/

It’s “No such file or directory”.