Sorry but I can't solve the usb symlinks issue

Platform = Raspberry Pi 2 Model B Rev 1.1
Release = Raspbian GNU/Linux 11 (bullseye)
openHAB 3.4.4 - Release Build
java -version
openjdk version “11.0.18” 2023-01-17
OpenJDK Runtime Environment (build 11.0.18+10-post-Raspbian-1deb11u1)
OpenJDK Server VM (build 11.0.18+10-post-Raspbian-1deb11u1, mixed mode)

Because I want to run 2 different modbus with different parity i need 2 usb ports.
until now I’ve used /dev/ttyusb0 and /dev/ttyusb1 that works until i reboot or powerdown.
So the solution is ( i think) to use symlinks)
Got all the info on the to usb-devices:
see print
SUBSYSTEM==“tty”, ATTRS{idVendor}==“0403”, ATTRS{idProduct}==“6001”, ATTRS{serial}==“AQ00IBOK”, SYMLINK+=“ttyUSBwhite”
SUBSYSTEM==“tty”, ATTRS{idVendor}==“10c4”, ATTRS{idProduct}==“ea60”, ATTRS{serial}==“0118528B”,SYMLINK+=“ttyUSBblack3”

EXTRA_JAVA_OPTS=“-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyUSB1:/dev/ttyUSBwhite:/dev/ttyUSBblack3”

output openhabian @openhabian:~ $ ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Jun 15 14:22 /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 1 Jun 15 14:22 /dev/ttyUSB1
lrwxrwxrwx 1 root root 7 Jun 15 12:18 /dev/ttyUSBblack3 → ttyUSB1
lrwxrwxrwx 1 root root 7 Jun 15 12:18 /dev/ttyUSBwhite → ttyUSB0

The two symlinks are there but openhab return error when i change the things.
the two symlinks appear in blue, the rest in yellow in the putty window.

error print from the log:
2023-06-15 14:30:35.348 [WARN ] [ing.ModbusSlaveConnectionFactoryImpl] - Connect reached max tries 1, throwing last error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection [m_SerialPort=null, m_Parameters.getPortName()=/dev/ttyUSBblack3]. Endpoint ModbusSerialSlaveEndpoint [getPortName()=/dev/ttyUSBblack3]

Googled for hours , i’ve done everything over again but no solution?
Can anyone help, point me in the right direction?

you have to create udev rules for that job.

SUBSYSTEM==“tty”, ATTRS{idVendor}==“0403”, ATTRS{idProduct}==“6001”, ATTRS{serial}==“AQ00IBOK”, GROUP=“dailout”, SYMLINK+=“ttyUSBwhite”
SUBSYSTEM==“tty”, ATTRS{idVendor}==“10c4”, ATTRS{idProduct}==“ea60”, ATTRS{serial}==“0118528B”, GROUP=“dailout”, SYMLINK+=“ttyUSBblack3”

This is what i put in the /etc/udev/rules.d/99-usb-serial.rules; just added the Group but that does not change anything.

Not sure if it matters, but don’t you want “dialout”, not “dailout”?

1 Like

oeps, thanks for pointing out my mistake.
Changed it now but it does not seem to make a difference.
I’ll do a restart and come back if it has solved the problem.

Found an other conversation with similar problem, learned that you can not have two EXTRA_JAVA_OPTS lines in /etc/default/openhab.
So put them in one line, but the problem is remains.

If there is some doubt, you can check if the java process is really launched with the EXTRA_JAVA_OPTS
ps -edf | grep openhab | grep java | grep --color=auto EXTRA_JAVA

Also, not really a solution, but openHAB 4 (and only 4) can directly use the symlinks that are automatically created in /dev/serial/by-id/ (so, IN THEORY, with the next version you shouldn’t have to worry anymore about udev rules or the gnu.io.rxtx.SerialPorts configuration parameter)

1 Like

Thanks,
I run the system now by resetting the things modbus serial each time to the correct /dev/ttyUSB0 or 1
ps -edf | grep openhab | grep java | grep --color=auto EXTRA_JAVA
returns nothing ? But i don’t understand the command so does not know what it means.
Thus this point to a possible mistake in my setup?

It means nothing because I made a mistake, sorry :sweat_smile:
It was :

ps -edf | grep openhab | grep java | grep --color=auto gnu.io.rxtx

And it’s just to check that the correct parameter is really used in the resulting daemon command line.
As you found out previously, it’s easy to mess it up.
If the grep command returns the process running openHAB with the extra options passed as a environnment parameter, then it’s good.