Many usb-serial devices appear as /dev/ttyUSBX or /dev/ttyACMX in the system, the link changing every time several of these devices are plugged in. This is unsatisfying if you want to access these devices from a script. One solution is to use a UDEV ruleset to make a symbolic link for each device. Here is how to do it.
Determine vendor and product id of the usb-serial device:
1 2 3 4 5 6 |
lsusb Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 004: ID <strong>0403:6001</strong> Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC Bus 002 Device 003: ID 0bda:0724 Realtek Semiconductor Corp. Bus 002 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub |
Determine serial number of the device:
1 2 |
udevadm info -a -n /dev/ttyUSB0 | grep '{serial}' | head -n1 ATTRS{serial}=="<strong>DAE0011W</strong>" |
Create a UDEV ruleset that makes a symbolic link for each device:
1 |
sudo nano /etc/udev/rules.d/99-usb-serial.rules
1 |
and add and adapt to your needs:
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="DAE0011W", SYMLINK+="1wire"
after replugging the device, there will be a symbolic link ‚1wire‘ be created for your device.