Locate different arduinos in /dev


A rover has several arduinos controlling several motors and everything is controlled from a Linux computer.
The Linux computer needs to know which motor belongs to which Arduino nano.
The /dev/ttyUSBX names are random and a udev rule has to be created to create proper symlinks.

this is an example for the motor_left_wheel_2

iker@x220:~$ dmesg |tail
[132279.252955] ftdi_sio 3-1.2:1.0: device disconnected
[132280.729756] usb 3-1.2: new full-speed USB device number 16 using ehci-pci
[132280.829889] usb 3-1.2: New USB device found, idVendor=0403, idProduct=6001
[132280.829899] usb 3-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[132280.829905] usb 3-1.2: Product: FT232R USB UART
[132280.829910] usb 3-1.2: Manufacturer: FTDI
[132280.829914] usb 3-1.2: SerialNumber: A4001IE3
[132280.832971] ftdi_sio 3-1.2:1.0: FTDI USB Serial Device converter detected
[132280.833049] usb 3-1.2: Detected FT232RL
[132280.833866] usb 3-1.2: FTDI USB Serial Device converter now attached to ttyUSB0

All FTDI chips have the same idVendor=0403, idProduct=6001 but the SerialNumber is different. (if it is not different is a counterfeit chip)

The serial number and udev attribute for a ttyUSB0 device can be seen like this:

iker@x220:~$ udevadm info --attribute-walk -n /dev/ttyUSB0 | grep '{serial}' | head -n1

iker@x220:~$ cat /etc/udev/rules.d/42-robot.rules

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A4001IE3", SYMLINK+="motor_left_wheel_2"

iker@x220:~$ sudo udevadm control --reload-rules

this will create a /dev/motor_left_wheel_2 each time an arduino with that serial number is connected.

iker@x220:$ ls -l /dev/motor_left_wheel_2
lrwxrwxrwx 1 root root 7 ene 16 22:23 /dev/motor_left_wheel_2 -> ttyUSB0



Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s