Wiki
Clone wikiRVR CPP / ttyUSB0 Naming
Configure USB for Fixed Name
In Linux one of the issues using a USB to serial port converter is the name can change. The sequence of plugging in USB devices determines the names. There is a system called udev
that determines the names. It allows rules to be created that will provide a fixed name for devices. It is a challenge to create the rules. Here are some basics but they might not handle all situation, e.g. two serial devices from the same vendor.
First you need to determine the vendor and product identifiers for the device. With it plugged in run:
lsusb
Bus 002 Device 002: ID 8087:8000 Intel Corp. Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 002: ID 8087:8008 Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 036: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light Bus 003 Device 002: ID 047d:2048 Kensington Orbit Trackball with Scroll Ring Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
The identifies follow the ID
on the line for your device. Mine IDs are 10c4
and ea60
, for vendor and product. Use these exactly as the appear keeping the case of the text exactly the same, i.e. vendor 10c4 is not the same as 10C4.
Using your IDs create a file 80-rvr.rules
containing:
ACTION=="add", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE="0666", SYMLINK+="rvr"
etc/udev/rules.d/
and load the rule using the commands:
sudo cp 80-rvr.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules && sudo udevadm trigger
/dev
directory where all devices are listed using:
ll /dev
lrwxrwxrwx 1 root root 7 Nov 8 21:14 rvr -> ttyUSB0
tty*
devices depending on your system and the USB to serial converter being used. Some will be ttyUSB
as shown, some ttyACM
, and possibly others.
** Additional Information
You can get more information about your device with the command:
sudo udevadm info -q all -n ttyUSB0
Complex Rule
SUBSYSTEM=="usb", ATTRS{idVendor}=="1ffb", MODE="0666" KERNEL=="ttyACM*", SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1ffb", ATTRS{idProduct}=="008[0-f]", MODE="0666", PROGRAM="/bin/bash -c '/bin/echo %p | /bin/grep -c :1.0/tty'", RESULT=="1", SYMLINK+="polulu_servo_serial_$attr{serial}", GROUP="dialout" KERNEL=="ttyACM*", SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1ffb", ATTRS{idProduct}=="008[0-f]", MODE="0666", PROGRAM="/bin/bash -c '/bin/echo %p | /bin/grep -c :1.2/tty'", RESULT=="1", SYMLINK+="polulu_servo_ttl_$attr{serial}", GROUP="dialout" KERNEL=="ttyACM*", SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1ffb", ATTRS{idProduct}=="009[0-f]", MODE="0666", PROGRAM="/bin/bash -c '/bin/echo %p | /bin/grep -c :1.0/tty'", RESULT=="1", SYMLINK+="polulu_smc_$attr{serial}", GROUP="dialout"
Updated