Re: MtxOrb device

Dave Platt <[email protected]> Tue, 21 Jan 2014 13:23:48 -0800
Newsgroups gmane.comp.sysutils.lcdproc
Message-ID <[email protected]>
>> 1. Is it possible to assign a fixed device instead of "/dev/ttyUSB0"?
> 
> You might want to read a bit on udev. It can rename devices based on
> rules. This way, you can access the display via /dev/MtxOrb or whatever
> you prefer.

Yup.  It's quite useful.

The trickiest part is figuring out which attributes of the device (or
its controller) to use for matching in the udev rule.  The documentation
of the necessary lore isn't all that straightforward or easy to find.

Here's a way to go about it.

With the device plugged in, chant

	udevadm info --name=/dev/ttyUSB0 --attribute-walk

Look at what it tells you.

What you'll need to do, most commonly, is pick a set of one or more of
the ATTRS{} entries which uniquely identifies this particular device.
If you need to use more than one ATTRS{} entry to distinguish this
device from others on your system, you have to choose *all* of the
ATTRS{} from the same level of "parent" (you can't combine ATTRS{}
entries from different parents in a single rule).

If you've got only one device from a particular manufacturer on your
system, the problem is a fairly simple one... use the ATTRS{idVendor}.
If you've got two or more device from the same manufacturer, but they're
of different types, use ATTRS{idVendor} and ATTRS{idProduct} together.

The tricky part is if you have two or more devices of the same type and
manufacturer, and they don't include unique device serial numbers (the
Prolofic PL2303 USB-to-serial chips and their clones are a common case
of this).  In this case you may have to look for some obscure attribute
which is different between them and is predictable (turns out to be the
same on each reboot), such as the bus number, quirks, or ???.

Put the necessary ruleset in a file in /etc/udev/rules.d/?????.conf - I
recommend matching the attributes, and then using the "SYMLINK+="
feature to add a symbolic link from the name you want, to the underlying
device.

Here's what I have as a ruleset for one such adapter, as
/etc/udev/rules.d/x10.conf

# Prolific USB-to-serial adapter, driving the X10 interface.
# Unfortunately most Prolific devices have no serial number and are not
individually
# identifiable.
SUBSYSTEM=="tty", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303",
SYMLINK+="x10", RUN+="/bin/stty -F /dev/%k clocal -crtscts -ixon -ixoff
hupcl"

This creates a /dev/x10 symlink to /dev/ttyUSB???, and also runs a
command when the device is recognized.

Here's one I use for an FTDI USB-to-serial adapter... it matches the
vendor, product, and serial-number attributes.  With this approach, I
could install any number of FTDI adapters of the same model, and be
confident that each would be given the correct symbolic name... each
device has a guaranteed-unique serial number to match against.

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001",
ATTRS{serial}=="FTQ8RNAJ", SYMLINK+="tnc", RUN+="/bin/stty -F /dev/%k
clocal -crtscts -ixon -ixoff hupcl"