Search code examples
linuxusbserialcdc

How to assign user defined name to USB CDC Serial ports?


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?


Solution

  • 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