3

So, the question is, is the content of /dev/serial/by-id unique?

Essentially the issue is I want to connect several (two or more) arduinos (potentially of different types, but they may all end up being leonardos) to the Raspberry Pi for the purposes of an automation system.

I'll be using the serial interfaces to communicate between the Raspberry Pi in Python and the Arduinos. I've run this on one of the leonardos (at present I only have one):

udevadm info -a -n /dev/ttyACM0| grep serial  
0000:00:1d.0

Is this a unique serial for my serial connection to the Pi? Can I rely on this to create a UDEV rule to assign a particular mount point, or does a unique and reliable mount point get already created in /dev/serial/by-id/, which I can use instead of hacked-udev rules?

jvc26
  • 6,363
  • 6
  • 46
  • 75

3 Answers3

2

It's NOT ALWAYS unique. In my experience, if you bought a cheap arduino clone from China, they mostly didn't bother to generate unique ID for every devices. The same applies for every devices. If the manufacturer didn't bother, then the devices will be identical. I ended up just using the by-path and symlink it.

1

In my experience using /dev/serial/by-id with USB devices has been unique. That is true as long as the manufacturer follows "the rules" about giving each device a unique serial number.

I just make symlinks to those long names in /dev/serial/by-id and use my symlinks as the handles for my serial devices in scripts. No muss, no fuss, NO UDEV.

guitarpicva
  • 432
  • 3
  • 10
  • 1
    If you run `sudo lsusb -v | grep iSerial` you can see all the serial IDs. Some vendors are good, some are lazy, and some are downright dodgy... – snake_case Aug 17 '22 at 03:24
  • That is sadly quite true. In the case where you are in complete control of the situation, and the hardware, and where the serial device name is user configurable, there is no harm in doing things the simpler way. Some programs also enumerate those /dev/serial/by-id names for the user configuration to choose from. That has been quite helpful to me over the years. – guitarpicva Oct 21 '22 at 14:45
1

The rules for the naming are in

/lib/udev/rules.d/60-persistent-serial.rules
Mark Lakata
  • 19,989
  • 5
  • 106
  • 123