/
Assign static /dev identifiers to USB devices

Assign static /dev identifiers to USB devices

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

Problem description

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

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

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

udev 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:

$ 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 /dev/ttyUSB 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 file like this one :

$ 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:

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

Related

 

Related content

How to gather your app data from your mote on your own
How to gather your app data from your mote on your own
More like this
Remote control your mote through raspberry pi
Remote control your mote through raspberry pi
More like this
Sniffers
Sniffers
More like this
Trigger remotely 6P packets over serial port, openvisualizer and ZMQ
Trigger remotely 6P packets over serial port, openvisualizer and ZMQ
More like this
EUI64 Numbering Convention
EUI64 Numbering Convention
More like this
OpenMoteCC2538
OpenMoteCC2538
More like this