You may be able to do it with a udev rule if the devices have different serial numbers.
To find the serial numbers, plug in the devices and do this
Code: Select all
pi@raspberrypi:~$ sudo udevadm info --query=property --name=/dev/ttyUSB0 | grep SERIAL
ID_SERIAL=Generic_USB_to_Serial_Converter_OCB6NCRD
ID_SERIAL_SHORT=OCB6NCRD
Do the same for ttyUSB1.
Now create a rules file:
Code: Select all
pi@raspberrypi:~$ sudo nano /etc/udev/rules.d/99-usbserial.rules
(add these lines)
ACTION=="add",ENV{ID_BUS}=="usb",ENV{ID_SERIAL_SHORT}=="OCB6NCRD",SYMLINK+="ttyUSBPort1"
ACTION=="add",ENV{ID_BUS}=="usb",ENV{ID_SERIAL_SHORT}=="JHG7GJFF",SYMLINK+="ttyUSBPort2"
(save and exit)
(Put in the serial numbers that you get from the above info command).
Now when you plug in the USB devices they will still get ttyUSB0 and ttyUSB1 seemingly randomly, but they will also get ttyUSBPort1 and ttyUSBPort2 which will always be assigned to that particular device.
You may need a "sudo udevadm control --reload-rules" to get the new rule to be read, but I've never needed that.