π
2010-06-17 01:01
in Linux, Linuxha
So, if you have more than one USB to serial adapter, you might have issues with which order they load in, causing the serial port numbers (/dev/ttyUSB0 .. x) to change pseudo randomly at boot, it's pretty annoying.
In my case, I picked up an 8 port ftdi usb to serial converter for only $15 on Ebay (woot!) but even its ports may not come up in sequence at boot time if other modules are loaded at the same time (a race condition can cause the pl2303 port to be in between one of the 8 ports from the ftdi hub).
Turns out there is a solution to this problem with udev, iff your usb to serial adapters have serial numbers (my ftdi ones did, but my pl2303 ones did not), or if you only have one serial adapter of each brand (like ftdi, pl2303, keyspan).
In my case, I have (don't laugh), 11 serial devices on my server:
Server serial console
1-wire serial adapter
Insteon PLM
APC ups
W800 X10RF and X10sec gateway
X10 MR26a X10RF gateway
First ECM 1240 power meter
Second ECM 1240 power meter
Brand One Meter serial adapter
HAI thermostats (2 on one line)
Rfxcom 433.92Mhz (433.92Mhz RF gateway for Oregon Scientific Weather Sensors)
This is what you do with udev:
gargamel:~# cat /etc/udev/rules.d/50-local-usb-serial.rules
# /etc/udev/rules.d/50-local-usb-serial.rules
# http://www.reactivated.net/writing_udev_rules.html#udevinfo
# was udevinfo -a -p /class/tty/ttyUSB0
# now udevadm info --attribute-walk -p /class/tty/ttyUSB0
SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvN", SYMLINK+="usb-serial-ftdi-8_1"
SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvO", SYMLINK+="usb-serial-ftdi-8_2"
SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvP", SYMLINK+="usb-serial-ftdi-8_3"
SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvR", SYMLINK+="usb-serial-ftdi-8_4"
SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvQ", SYMLINK+="usb-serial-ftdi-8_5"
SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvS", SYMLINK+="usb-serial-ftdi-8_6"
SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvT", SYMLINK+="usb-serial-ftdi-8_7"
SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvU", SYMLINK+="usb-serial-ftdi-8_8"
SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A800dMFk", SYMLINK+="rfxcom"
SUBSYSTEMS=="usb", ATTRS{product}=="USB-Serial Controller", ATTRS{manufacturer}=="Prolific Technology Inc.", SYMLINK+="usb-serial-pl2303"
After making a change udevadm trigger will update symlinks. |