Persistent device naming

A category for tips and tricks or off-topic things
Post Reply
jeanmarc
Posts: 1866
Joined: Thu Aug 29, 2013 7:16 am

Persistent device naming

Post by jeanmarc » Wed Oct 16, 2019 12:13 pm

Hello,

Many of us use several converters to access their inverters and meters. It may also lead to problem if a com port is named "ttyUSB0" and after ttyUSB1.
So, it's wiser to set a persistent naming.
Let's say it's used for an inverter : Get device details with udevadm info -a -n /dev/ttyUSB0
You can assign a name via attibutes : SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="solar"
Or more conveniently via the physical place of the converter udevadm info -a -n /dev/ttyUSB0 | grep KERNELS. Obviously, you should keep the converter in the same USB port place.

Now create a rules file /etc/udev/rules.d/99-ttyUSB.rules

Code: Select all

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="solar"
SUBSYSTEM=="tty", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="8036", SYMLINK+="arduino"
SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", SYMLINK+="uno"
SUBSYSTEM=="tty", KERNELS=="1-1.2", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", SYMLINK+="sdm"
udevadm control --reload then udevadm trigger
You can now call /dev/solar or /dev/whatever ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest