ttyUSB ports are getting changed after reboot

we are using Quectel EC200A modem in our project .when board boots ttyUSB ports are coming up as ttyUSB0,ttyUSB1,ttyUSB2.but when we reboot modem to switch sim ttyUSB ports are getting changed as ttyUSB0,ttyUSB2,ttyUSB3.
can you please suggest how can we avoid this.
This same issue we are facing even with EC25E modems also

The device names of the modules are not fixed. If no other USB serial device is connected to user’s system, the device names of the modules start from /dev/ttyUSB0 as shown above; If another USB serial device is connected to the user’s system, the device names of the modules are determined by the number of device nodes generated by the USB serial device. For example, if a USB serial device is connected to user’s system and generates one device node, /dev/ttyUSB0 is occupied by USB serial device, then the device name of current module starts from /dev/ttyUSB1

So what should we do is we need to close the ttyUSB in time.
Otherwise you need to find the right usb interface to choose the right ttyUSB to enter AT command.

Actually we don’t have any other serial device other than quectel modem

Hi @Sriram_R,

on Linux there are sysfs entries for each serial driver, e.g. /sys/bus/usb-serial/drivers/option1/ which contain symlinks which include the the interface number after the last ., e.g.

# ls -l /sys/bus/usb-serial/drivers/option1/
total 0
lrwxrwxrwx 1 root root    0 May 11 05:34 module -> ../../../../module/option
-rw-r--r-- 1 root root 4096 May 11 05:34 new_id
lrwxrwxrwx 1 root root    0 May 23 16:35 ttyUSB16 -> ../../../../devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.2/2-1.2:1.0/ttyUSB16
lrwxrwxrwx 1 root root    0 May 23 16:35 ttyUSB17 -> ../../../../devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.2/2-1.2:1.3/ttyUSB17
lrwxrwxrwx 1 root root    0 May 23 16:35 ttyUSB18 -> ../../../../devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.2/2-1.2:1.4/ttyUSB18
lrwxrwxrwx 1 root root    0 May 23 16:35 ttyUSB19 -> ../../../../devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.2/2-1.2:1.5/ttyUSB19
lrwxrwxrwx 1 root root    0 May 23 16:35 ttyUSB20 -> ../../../../devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.2/2-1.2:1.6/ttyUSB20
--w------- 1 root root 4096 May 11 05:34 uevent

which should allow you to map the /dev/ttyUSB* to the corresponding interface function.

Regards,
Reinhard

Create a udev rule that will map the USB interface number to a static user defined name.

Here is an example to find the ttyUSB port.

Quectel auto find the ttyUSB and interface
Find /sys/bus/usb/devices/1-3 idVendor=0x2c7c idProduct=0x6026, bus=0x001, dev=0x053
Auto find ttyUSB port = /dev/ttyUSB3
Find /sys/bus/usb/devices/1-3 idVendor=0x2c7c idProduct=0x6026, bus=0x001, dev=0x053
Auto find ttyUSB port = /dev/ttyUSB4