[TriEmbed] best tool for automagic interaction with USB serial ports

Pete Soper pete at soper.us
Fri Mar 1 11:08:09 CST 2019


OK, first, sorry for the extra traffic and noise on the list: I didn't
properly read John's how-to for a silly long time. I'm still pondering
over how I didn't look that gift horse in the mouth because of a
preconceived idea of the inherent constraints on a Udev approach. Talk
about tunnel vision! If this was a 1980 Usenet list there would be a
smoking hole in the floor where I and my chair had once been. Thank you
for your patience.

Unfortunately, John's cook book rule doesn't "just work" for me, I'm
guessing 'cause Linux has gotten more strict.

If I  have a rule like this:

SUBSYSTEMS=="usb", ATTRS{serial}=="DO01TY7B", ATTRS{product}=="FT230X
Basic UART", ATTRS{idProduct}=="6015", ATTRS{idVendor}=="0403",
MODE="0666", GROUP="dialout", NAME="SW"

I get this in /var/log/syslog:

Mar  1 11:40:52 rick systemd-udevd[9209]: NAME="SW" ignored, kernel
device nodes cannot be renamed; please fix it in
/etc/udev/rules.d/22-apf-tr.rules:1

(The error is  displayed even if I leave off the mode and group
assignments that are not in John's example)

I can avoid this problem if I take the easy way out and make it a
symlink like this:

SUBSYSTEMS=="usb", ATTRS{serial}=="DO01TY7B", ATTRS{product}=="FT230X
Basic UART", ATTRS{idProduct}=="6015", ATTRS{idVendor}=="0403",
MODE="0666", GROUP="dialout", SYMLINK="SW"

Then I end up with this:

/etc/udev/rules.d$ ls -l /dev/SW
lrwxrwxrwx 1 root root 15 Mar  1 11:44 /dev/SW -> bus/usb/001/028

Notice the group id didn't get changed but the mode did (it defaults to
660).

But my terminal emulator of choice (a program called 'screen'), won't
connect, even if the group is changed to dialout. It will connect if
that change is made and the link is made to point to the device (in this
example, 'cause I have everything else disconnected, /dev/ttyUSB0).

The easy easy way out is to make the symlink point to the device, but it
isn't clear how to correlate the one to the other. I repeated the
experiment with two identical devices (except for their serial numbers
and of course one rule for each and got this:

lrwxrwxrwx 1 root root 15 Mar  1 11:51 /dev/SW1 -> bus/usb/001/032
lrwxrwxrwx 1 root root 15 Mar  1 11:51 /dev/SW2 -> bus/usb/001/031

Notice the leaf of the path has jumped from 028 to 031 or 032 for the
same device. I pulled one device to see what devices and symlinks are left:

ls -l /dev/SW*
lrwxrwxrwx 1 root root 15 Mar  1 11:51 /dev/SW2 -> bus/usb/001/031
/etc/udev/rules.d$ ls /dev/ttyUSB?
/dev/ttyUSB0

This suggests an ad hoc script would assign the lowest numbered device
to the lowest numbered leaf in the path. Presumably an ad hoc script or
Python program or the like could find the easy mapping between these
paths and the device in /dev but I suspect there's a better way just
sticking with Udev.

-Pete







More information about the TriEmbed mailing list