Hi,

It took me half a morning to figure out how to get persistent naming of
several USB-serial devices. Google finds lots of information but
unfortunately a lot of it is outdated. Here's my way, let's hope Google
indexes it.

Problem: I got a new computer without legacy serial ports. In order to
connect my UPS and Wacom Intuos I got two USB-serial converters. When
the computer boots, the UPS is connected to ttyUSB0 and the Intuos to
ttyUSB1. However, when the computer boots while my phone is connected,
all USB serial devices shift name. In order to get persistent names, I
need symlinks to the serial devices.

It would have been nice if the serial devices got a serial number so we
could use the ATTRS{serial} in a udev rule, but apparently it was
cheaper to print a serial number on a label than to put the number in
an e2prom in the device itself. Therefore the only way to distinguish
them is the place in the USB device tree. Several webpages suggest to
use PLACE in a udev rule for that, but that doesn't work anymore.
Fortunately the place can be encoded in a KERNELS statement. If you
query the udev information for the device you get:

[EMAIL PROTECTED]:~ > udevinfo -a -n /dev/ttyUSB0 

  looking at device '/class/tty/ttyUSB0':
    KERNEL=="ttyUSB0"
    SUBSYSTEM=="tty"
    DRIVER==""
    ATTR{dev}=="188:0"

  looking at parent device 
'/devices/pci0000:00/0000:00:1a.1/usb4/4-1/4-1:1.0/ttyUSB0':
    KERNELS=="ttyUSB0"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="pl2303"
    ATTRS{port_number}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:1a.1/usb4/4-1/4-1:1.0':
    KERNELS=="4-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="pl2303"
    ATTRS{bInterfaceNumber}=="00"
    [...]

So the USB-serial devices lives on USB host 4 port 1 on something
called 1.0 (I guess that is the first serial port in the usb-serial
converter, there are usb-serial converters with multiple ports). The
two udev rules now become:

SUBSYSTEMS=="usb", KERNELS=="4-1:1.0", KERNEL=="ttyUSB*", SYMLINK+="ups"
SUBSYSTEMS=="usb", KERNELS=="4-2:1.0", KERNEL=="ttyUSB*", SYMLINK+="wacom"

And now I can tell nut to use /dev/ups and Xorg to use /dev/wacom.


HTH,
Erik

-- 
Erik Mouw -- [EMAIL PROTECTED]

Attachment: signature.asc
Description: Digital signature

Reply via email to