USB device file names not consistent

Topics about the Hardware of Revolution Pi
Post Reply
mats-olov_rustad
Posts: 17
Joined: 01 Apr 2020, 11:40
Answers: 0

USB device file names not consistent

Post by mats-olov_rustad »

We have an application where we connect one type of sensor to a external USB-RS485-adapter and another type of sensor connected to the RS485-port of our Connect+ module.

Our problem is that the device file names representing the ports doesn't stay the same at all system boots. Most of the time is the external USB-adapter represented by the device file name ttyUSB2 but sometimes it is represented by ttyUSB0 instead. The RS485 port is usually represented by the device file name ttyRS485 which is a symbolic link to the device file ttyUSB0. When the external USB adapter is represented by ttyUSB0 is the RS485 port represented by ttyRS485 which links to ttyUSB1.

It seems to me that the device file names are assigned in the order the USB devices are configured. Is there a way to avoid this race condition and ensure that the USB devices always are represented with the same device file names?

With regards,
/Mats-Olov Rustad
Application Developer
ASFT Industries AB
User avatar
dirk
KUNBUS
Posts: 1926
Joined: 15 Dec 2016, 13:19
Answers: 4

Re: USB device file names not consistent

Post by dirk »

Hi mats-olov_rustad, USB device enumeration does not provide constant paths, I know. Therefore you can use udev rules.
Have a look at this discussion which is in German but maybe you can translate it.
viewtopic.php?f=8&t=2353&p=8762&hilit=udev#p8667
mats-olov_rustad
Posts: 17
Joined: 01 Apr 2020, 11:40
Answers: 0

Re: USB device file names not consistent

Post by mats-olov_rustad »

Thank you Dirk. I will take a look at it and see if my seconday school German is good enough to understand the thread.

With regards,
/Mats-Olov Rustad
Application Developer
ASFT Industries AB
mats-olov_rustad
Posts: 17
Joined: 01 Apr 2020, 11:40
Answers: 0

Re: USB device file names not consistent

Post by mats-olov_rustad »

A couple of udev rules made a difference. Now we can rely on static symbolic links to the required serial devices regardless of how the Linux kernel assigns device names.

With regards,
/Mats-Olov Rustad
Application Developer
ASFT Industries AB
User avatar
dirk
KUNBUS
Posts: 1926
Joined: 15 Dec 2016, 13:19
Answers: 4

Re: USB device file names not consistent

Post by dirk »

Hi thank you for your positive reply.
Post Reply