How to set generic udev rules for devices with different serials?

I was using this rule sentence to set links for my devices:

echo -e "SUBSYSTEM==\"tty\",ATTRS{idVendor}==\"12d1\",ATTRS{idProduct}==\"1003\",SYMLINK+=\"ttyUSB.TRKCLVINN\"
SUBSYSTEM==\"tty\",ATTRS{idVendor}==\"1bc7\",ATTRS{idProduct}==\"0021\",ATTRS{serial}=="359658043541046",SYMLINK+=\"ttyACM.TELIT\"" 
> /etc/udev/rules.d/99-usb-serial.rules

In some of the systems VINN modem is present, in some of them TELIT modem is present.

Firstly I did not use the serial attribute. But then I noticed that in some of the systems with TELIT modems the link is addressed to -> ttyACM5 instead of ttyACM3. This disables my software to communicate with the modem. Thats why I added the serial attribute.

I used serial attribute for the TELIT modem since I want to communicate to only ttyACM3 interface:

# udevadm info -a -n /dev/ttyACM3 | grep '{serial}' | head -n1
    ATTRS{serial}=="359658043541046"

However now I notice that, serial attributes are specific to the device and varies from one to another.

For that reason, I checked the KERNELS attribute. For one system it says:

# udevadm info -a -n /dev/ttyACM3 | grep 'KERNELS' | head -n1
    KERNELS=="1-1.2:1.6"

And for another system it reports:

# udevadm info -a -n /dev/ttyACM3 | grep 'KERNELS' | head -n1
    KERNELS=="1-1.4:1.6"

These seem to be also different for each TELIT device.

Question is, what is the correct way to set this rule in order to cover every modem in the each system and make my software connect to the only ttyACM3 interface where available?

You can use a lot of different ATTRS to identify your usb device.

You need to find a common attribute to identify both TELIT modems correctly. Output of the udevadm info command will be helpful, look at these attributes first:

  • ATTRS{idProduct}
  • ATTRS{idVendor}
  • ATTRS{manufacturer}
  • ATTRS{product}