HowTo: fixed name for a udev device

noctis.de

Hi, Welcome to my site, please feel free to comment on my posts More »

HowTo: fixed name for a udev device

March 23. 2006 at 18:45
Posted by admin in Linux
Comments (0)
Trackbacks (0)
The basic problem with hotplugging USB devices is, that you never know the current device file name for use in configuration files. Linux' udev has a ruleset that provides you the feature to create a symlink whenever a certain device is plugged in, provided you can uniquely identify it.
based on this guide

First of all it's necessary to find the device's path:
# udevinfo -q path -n /dev/ttyUSB0
/class/tty/ttyUSB0

This isn't specifically helpful, but it lays the foundation for additional information:
# udevinfo -a -p /class/tty/ttyUSB0
[...]
ID=="1-1"
SYSFS{manufacturer}=="Matrix Orbital"
SYSFS{product}=="LK/VK204-24-USB"
SYSFS{serial}=="00000131"

The device in question is a LC display connected to some FTDI USB<->serial interface which provides (among other values) a manufacturer string, a product name and a serial number.

Now there's enough information to create a rule for udev. I chose to place it in etc/udev/rules.d/44-my-devices.rule with 44 being an arbitrary number which should be below the standard rules file. The name/directory of these files may differ on your system. From the standard rule file (/etc/udev/rules.d/50-udev.rules on my gentoo installation) I copied a template for my rule (namely the KERNEL, NAME, GROUP and MODE part) from the standard line for the USB to serial converters and added my identification information. The result is:
KERNEL=="ttyUSB[0-9]*", SYSFS{manufacturer}=="Matrix Orbital", NAME="%k", SYMLINK="USBdisplay%n", GROUP="tty", MODE="0660"

The added SYMLINK="USBdisplay%n" creates a symlink /dev/USBdisplay0 for the first display which points to whatever /dev/ttyUSB? device is assigned. The SYSFS{manufacturer}=="Matrix Orbital" does not identify this specific device, in case I ever get another one of these.

Possible Cavehat


It seems the number after USBdisplay is the same as that of the ttyUSB? node, instead of the excpected number of USBdisplays. So it might well be, that you end up with /dev/USBdisplay2 being the symlink for the first device. However I'm uncertain whether this is really true, but while testing (with another rule) I had this result (for the other rule). My workaround there: I locked the symlink to the very device and removed the number. Since that converter did not provide a serial number, I used the USB port that device is connected to as a unique identification:
KERNEL=="ttyUSB[0-9]*", ID=="1-2", SYSFS{manufacturer}=="Prolific Technology Inc.", NAME="%k", SYMLINK="USBrelaisBoard", GROUP="tty", MODE="0660"

In case I switch ports the relais board just won't get a symlink so the control software will complain about a non-existing device instead of risking that some random command turns everything off (or on). ;-)

Trackbacks
Trackback specific URI for this entry

No Trackbacks

Comments
Display comments as (Linear | Threaded)

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

BBCode format allowed
 
 
 

Quicksearch

Content

Impressum

Archives

September 2010
August 2010
July 2010
Recent...
Older...

Categories

  • XML Computer
  • XML Linux
  • XML Web
  • XML Personal


All categories

Syndicate This Blog

XML RSS 2.0 feed
ATOM/XML ATOM 1.0 feed

Blog Administration

Open login screen

Choose Language

 

Impressum | Contact | Login | Design by ceejay