Naming devices under Linux
Thursday, November 28th, 2013 at 08:49pm
When I recently started monitoring temperature it involved a USB to RS-232 adapter connected to my Linux box. A few weeks later I plugged in a USB device to monitor power usage.
Temperature was via /dev/ttyUSB0
and power was via /dev/ttyUSB1
. Until an unscheduled reboot at which point they swapped around as that was the order the devices are detected at boot, not the order in which they were plugged in.
A quick search led me to discover that you can write rules for udev to give devices persistent names.
Relying heavily on Writing udev rules I muddled through enough to end up with these rules:
SUBSYSTEM=="tty", ATTRS{product}=="USB2.0-Serial", SYMLINK+="digitemp"
SUBSYSTEM=="tty", ATTRS{product}=="RFA-Z106*", SYMLINK+="raven"
The generic RS-232 adapter now comes up under /dev/digitemp
and the Raven comes up under /dev/raven
. Now my monitoring will survive a reboot.
Tagged with: home automation, linux, udev