[Xastir] writing udev rules

Jeremy Utley jerutley at gmail.com
Wed May 6 00:43:17 EDT 2009


On Tue, May 5, 2009 at 7:18 AM, Tony Hunt <wavetel at internode.on.net> wrote:
> Thanks to Jeremy for posting on this one originally. I found the udev rules
> very easy to make work and have tested it on Debian 5 and also Ubuntu 7.01
> so it should work on Ubuntu 9 .
>
> The web site with the info on writing udev rules was valuable and frankly
> there is still probably more I could get out of it.
>
> Interestingly my Debian 5 box seems to have issues and I am stuck with
> multiple USB devices for long periods after plugin/out . Currently I have
> /ttyUSB0 to /ttyUSB5 inclusive and yet there is only 1 USB port and 1 USB
> device being the TNC-X . The Devices just dont clear down for days perhaps
> until reboot. This is another issue but the udev rules kind of get around
> this.
>
> Its a persistant naming scheme that makes a symlink to a specified device
> when its seen.
> I think the file contents that follow explain it all. Most of the file
> consists of comments. I will look at forwarding this info to John Hansen
> maker of the TNC-X .
>
> Here are the contents of a rule file called 10-tnc-x.rules
> The 10 on the front of the file name is important but the rest of the name
> is not.
>
> # udev rules for TNC-X
> # This file is usually located at   /etc/udev/rules.d/   check your system
> to be sure.
> # Using the serial of the individual TNC-X FTDI USB device it is most likely
> possible to have
> # multiple TNC-X devices attached with individual persistant names.
> # Other attributes like product manufacturer idProduct are common
> identification attributes
> # not unique to a specific TNC-X
> # To find the attributes you will need use USBview (GTK Gui) or udevinfo
> from a console
> # I have even found the required attributes in the syslog after plugging in
> the device.
> # Usually a TNC-X shows as a device /dev/ttyUSB0 or similar before you
> install any udev rules
> # To check your udev rule is working for the TNC-X use   ls /dev/TNC*   from
> the console
> # If this lists your TNC-X then the udev rule is working.
> #
> SUBSYSTEMS=="usb", ATTRS{serial}=="FS2SIUJX", KERNEL=="ttyUSB*",
> SYMLINK+="TNC-X-0"
> # SUBSYSTEMS=="usb", ATTRS{product}=="TNC-X from W2FS", KERNEL=="ttyUSB*",
> SYMLINK+="TNC-X"
> # SUBSYSTEMS=="usb", ATTRS{manufacturer}=="W2FS", KERNEL=="ttyUSB*",
> SYMLINK+="TNC-X"
> # SUBSYSTEMS=="usb", ATTRS{idProduct}=="ebe0", KERNEL=="ttyUSB*",
> SYMLINK+="TNC-X"
>
> Tony Hunt  VK5AH

Tony, you could probably simplify this udev rule into a single line:

SUBSYSTEMS=="usb", ATTRS{serial}=="FS2SIUJX", NAME="tncx0"

If I'm right, this should assign the device entry /dev/tncx0 whenever
the TNC-X with serial number FS2SIUJX is plugged in - if it gets
unplugged and replugged, the existing device file wll simply be
replaced with the new entry for the device - with a rule like this,
you shouldn't even get a /dev/ttyUSB* entry when that TNC-X is plugged
in.  You'd probably also want to add in stuff for setting the user and
group ownership, as well as permissions.  For example, to make the
device owned by user root, group uucp (fairly common for serial
devices) and with user and group read/write privledges, you'd expand
this to be the following:

SUBSYSTEMS=="usb", ATTRS{serial}=="FS2SIUJX", NAME="tncx0",
OWNER="root", GROUP="uucp", MODE=0660

The key here is using NAME= rather than SYMLINK= - by doing so you're
actually telling udev to name the device with a special name, rather
than just creating a symlink.

Hope this helps!

Jeremy, N0YAX



More information about the Xastir mailing list