2
votes

I am developing an embedded solution using C and I am working with two USB sensors. If I connect each sensor alone they take this names:

Device 1 (I do not know why it takes 6 names...)

  • /dev/ttyACM0
  • /dev/ttyACM1
  • /dev/ttyACM2
  • /dev/ttyACM3
  • /dev/ttyACM4
  • /dev/ttyACM5
  • /dev/ttyACM6

Device 2

  • /dev/ttyACM0

So when I start as an embedded system and both sensors are connected, the fastest one takes /dev/ACM0 but it not always the same. So, when I try to read device 2 I could be reading device 1...

I think that It would be great to change the default names of the sensors. I guess that it is going to be possible but I do not find anything.

1
Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask. Also see Where do I post questions about Dev Ops?jww
You probably want to boot with biosdevname=1 for stable names. It may or may not work. The discussion is better taken on other sites in the Stack Exchange network, like Unix & Linux Stack Exchange. Also see Consistent Network Device Naming in Linux.jww
I think you meant /dev/ttyACM0 instead of /dev/ACM0, etc.David Grayson
Yes, It's /dev/ttyACMXJulen Uranga

1 Answers

4
votes

You should try using the names in /dev/serial/by-id instead, since those names include the name of the device and should not depend on the order of connection.

By the way, it is also possible to write udev rules that make symbolic links for the serial ports depending on what device they belong to. I am not sure how that would work for a composite device with 6 serial ports, but there probably is a way to make it work.