Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info

This tutorial shows you how to always assign the same alias to a particular /dev device, such as a mote.

Table of Contents

Problem description

...

Linux creates a special file when you connect USB devices. Those file are in the form /dev/ttyUSB0 for  for the first one you plug in, /dev/ttyUSB1 for  for the second, etc...

Those name are created dynamically and depends on the order devices are plugged in. 

It might me is sometimes useful to assign static name names to those devices, e.g. to always flash reflash the right mote.

udev allows  allows you to assign alias on certain devices depending on some of their properties. 

 

First let's find the serial number of each USB devices:

Code Block
$ udevadm info --attribute-walk -n /dev/ttyUSB5 | grep serial

...


SUBSYSTEMS=="usb-serial"

...


ATTRS{serial}=="AK004SL3"

...


ATTRS{serial}=="0000:00:14.0"

Repeat this step for all your devices, changing the /dev/ttyUSB to  to yours.

Once you have the mapping between the aliases you want to apply and the serial number of devices you can put them in a udev rules files  rules file like this one :

Code Block
$ cat /etc/udev/rules.d/10-local.rules

...

 
ACTION=="add", ATTRS{serial}=="A9040YRU", SYMLINK+="sniffer"

...


ACTION=="add", ATTRS{serial}=="AK004SL3", SYMLINK+="dr"

...


ACTION=="add", ATTRS{serial}=="AK004SL6", SYMLINK+="6n"

You can also see which device an alias points to by doing:

Code Block
$ ls -all /dev/sniffer

...


lrwxrwxrwx 1 root root 7 août 30 14:17 /dev/sniffer -> ttyUSB3

Related

...

Reference :