I have a Neato XV-* lidar unit, connected with a Sparkfun FTDI chip, and an Arduino Uno. They show up as /dev/ttyUSB0
and /dev/ttyUSB1
, unpredictably unassigned.
So, I wrote /etc/udev/rules.d/80-arduinouno.rules
:
SUBSYSTEM=="tty",
ATTRS{idProduct}=="7523", ATTRS{idVendor}=="1a86",
MODE="0666",
OWNER="pi", GROUP="pi",
SYMLINK+="arduinouno"
... and /etc/udev/rules.d/90-neatolidar.rules
:
SUBSYSTEM=="tty", ENV(ID_SERIAL_SHORT)=="AL01OTZS",
ATTRS{idProduct}=="6001", ATTRS{idVendor}=="0403", ATTRS{serial}=="AL01OTZS",
MODE="0666", OWNER="pi", GROUP="pi",
SYMLINK+="neatolidar"
idProduct
and idVendor
were taken from the first line of
udevadm info --attribute-walk --name=/dev/ttyUSB1 | grep idProduct
and
udevadm info --attribute-walk --name=/dev/ttyUSB1 | grep idVendor
respectively, cross-referenced with the output of lsusb
. IS_SERIAL_SHORT
was taken from the output of
udevadm info -q all -n /dev/ttyUSB0 | grep ID_SERIAL
or
udevadm info --attribute-walk --name=/dev/ttyUSB0 | grep {serial}
but, while this command worked for the FTDI/lidar, it only gave an ID_SERIAL
, not an ID_SERIAL_SHORT
, for the Arduino.
When I do a sudo service udev restart
, then try plugging and unplugging the devices while monitoring watch 'ls -lah /dev | grep ">"'
, I see symlinks appearing for both arduinouno
and neatolidar
to whichever ttyUSB*
was plugged in last. That is, at the moment, I see both arduinouno -> ttyUSB1
and neatolidar -> ttyUSB1
. But if I unplug and replug ttyUSB0
, both will switch to that.
How can I get my udev rules to distinguish these two devices, and only fire when the correct device is detected?
If it matters, this is on a Raspberry Pi 3 running Raspbian Jessie. The Arduino is connected directly to the RPi, while the FTDI is connected to a cheap yellow EagleTec 4-port USB hub.