Thursday, April 14, 2011

udev and USB serial devices

We have a number of secure serial device servers (from http://www.vscom.de/) where I work.  One the Linux server where they are connected, they show up at different /dev/ttyUSB locations after each boot.  No particular surprise as I've seen the same things with disks.  What I wanted to do was create symlinks that remained constant.  So, one starts by profiling the devices via
udevinfo -a -p /class/tty/ttyUSBXX
A lot of info spews out.  For these particular devices, there are two ttyUSBXX entries, one number apart.  They differ in only one regard
29c29
<     SYSFS{bInterfaceNumber}=="00"
---
>     SYSFS{bInterfaceNumber}=="01"
So, one has to create udev rules to differentiate the two.  I created a file '/etc/udev/rules.d/97-pdu.rules' the looks like
kernel=="ttyUSB*", SYSFS{bInterfaceNumber}=="00", SYSFS{../serial}=="FT123456", 
SYSFS{../product}=="USB FAST SERIAL ADAPTER", SYSFS{../manufacturer}=="FTDI", SY
MLINK+="PDU44"

kernel=="ttyUSB*", SYSFS{bInterfaceNumber}=="01", SYSFS{../serial}=="FT123456", 
SYSFS{../product}=="USB FAST SERIAL ADAPTER", SYSFS{../manufacturer}=="FTDI", SY
MLINK+="PDU45"
Did a 'udevtest /class/tty/ttyUSBXX' to make sure the correct symlinks would be created, and then did a '/sbin/udevtrigger' to make it happen the first time.  All was good after that.

No comments: