I have USB cellular modem attached to an ALIX 3d2 board running voyage linux (which is based on Debian Squeeze). The modem registers itself as a TTY device, and so by default, udev will create TTY devices named "ttyUSB0" through "ttyUSB3" in /dev. However, there may be other USB-to-Serial devices attached and I'd like to have a known reference to the modem. So, I wrote a simple udev rule to make a link from the modem to /dev/ttyModem{0-3} however, the only way I could find to automatically handle the numbering was through the %n variable in udev, which has the problem of creating /dev/ttyModem{4-7} if a four port USB-to-Serial adapter is enumerated before the modem. I found some references to a %e variable in old udev documentation that would do just what I need, but it appears to have been removed some time ago.

Luckily, there is a port number that can be referenced from the device for each tty device, so I should be able to handle the numbering manually. I can create a link based on the port number, but whenever I attempt to use both the port number and the USB vendorID+productID, the rule is no longer applied. I suspect that I might be violating the "one single parent device" rule somewhere, as these attributes are recognized in different devices according to udevadm info, but as far as I can tell, all attributes should be coming from one device and its parent.

Here are the rules I've applied:

This rule works, and is what I started with, but the number it generates may not start at 0.

And here is the output of udevadm info --attribute-walk for port0, port1, port2, port3. The second device from the top contains the port number, and the fourth device contains the identifying USB information.

I realize this is a bit of an XY problem, so if you know of a better way to give the modem a constant name, feel free to post that as your answer.

Also check if any of the existing symlinks in /dev/serial/by-id (helps if your modem has a unique serial number) or /dev/serial/by-path (works if you always plug in your modem in to the same USB port) would work for your purpose.

Unfortunately, that didn't work. I also tried the simplest form of that method I could think of ENV{ID_VENDOR_ID}=="1199" SYMLINK+="ttyPortNumber0", but even that didn't get triggered. I confirmed with udevadem info --query=all that the environment variable should be added, but I'm at a loss as to why it doesn't seem to recognize it in the rule. As for the other symlinks, This rule needs to work for any modem of the same model, and when it's plugged in to any USB port, so the only thing I would do with those is copy them and rename them, which is the whole point of using udev.
–
isidor3Jun 12 '13 at 16:10

I had a similar problem bringing a USB cellular modem online with consistent numbering in a system along with other USB tty devices vying for /dev/ttyUSB* numbers. In my case it was a EuroTech ReliaCELL 10-20-32 with the Telit chipset. I solved the problem using some ideas from here, ending up with the following excerpt in my .rules: