1
votes

I'm using USB Modem with my Linux board, and Kernel is creating 4 Virtual(CDC-ACM) serial ports when i connect the modem. and the Serial port name asr like ttyUSB0 - ttyUSB3. But these assigned names are not always same. If i have connected some other USB CDC devices already, then Kernel is assigning a different set of names, like ttyUSB4-ttyUSB7. This behavior is affecting my program, I have to change the Port numbers each time.

So is there any way to assign user defined names to Modem USB CDC ports, based on the Device ID of the Modem?

2

2 Answers

0
votes

You can use an udev rule: Find the vendor and product id of your device (you can get it with the lsusb command) then create the file /etc/udev/rules.d./99-serial.rules with the rule (replace idVendor, idProduct and NAME accordingly):

SUBSYSTEM=="tty", ATTRS{idVendor}=="O123", ATTRS{idProduct}=="0123", NAME="chooseSomeName"

Unplug and plug the device again. It should now be accessible through /dev/chooseSomeName

0
votes

According to https://wiki.ubuntuusers.de/udev/ the method of Emilien is depreciated (at least on Ubuntu Version ≥ 13.10):

Die Vergabe von eigenen Namen mit NAME= ist nur für Netzwerkschnittstellen eth* sinnvoll. Bis Ubuntu 13.04 könnnen zwar auch andere Geräte noch umbenannt werden, dies führt aber zu Inkonsistenzen mit dem Kernel. Daher unterstützt Ubuntu ab 13.10 nur noch das das Umbenennen von eth*-Geräten.

sloppy translation:

The allocation of own names using NAME= is only reasonable for network interfaces eth*. Until Ubuntu 13.04 also other devices can be renamed, but this leads to inconsistencies with the kernel. Due to this reason Ubuntu 13.10 and later only allow the renaming of eth*-devices [using the NAME= tag]

Instead make use of the SYMLINK command, e.g.

SUBSYSTEM=="tty", ATTRS{idVendor}=="O123", ATTRS{idProduct}=="0123", SYMLINK="chooseSomeName"

which will produce a symlink to the device (also in the /dev/ folder).