Modbus identifying serial ports
-
I'm working on a data acquisition system wchich should work on linux laptop and i am using Modbus4J and have implemented my own serial port wrapper which will by default ask for port-name(String) which is usually (/dev/ttyUSB1, /dev/ttyUSB2, etc)
But to my surprise the dev path to USB aren't constant and keeps changing in the order of connection.
when I connect two serial port converts to two USD ports the first connected ones take /dev/ttyUSB0 and the later /dev/ttyUSB1. This is an issue.
How is should have been done actually?
-
Hi vijay,
There may be more than one solution, but we have solved this on our MangoES product for instance by using udev rules to create a symlink with a consistent name. In our case, we used the attributes identifying which USB port the device was connected to. You may find this stack exchange thread helpful: https://unix.stackexchange.com/questions/66901/how-to-bind-usb-device-under-a-static-name
You'll need to use udevadm to find the attributes to identify the port by, and then a /etc/udev/rules.d/ rule to
SYMLINK+="ttyNewSymlinkName"