Running 3.3 release, the USB serial adapter ports of my Raspi vanished from openHAB after a reboot.
Things to use them remain offline claiming “No such port /dev/ttyUSB2”.
But the ports ARE there from the OS perspective. 3 adapter with a CH341 chipset if that matters.
I’ve already selectively restarted the serial related bundles, and explicitly started java with -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyUSB1:/dev/ttyUSB2:..... but no luck.
Debugging of serial transport tells me:
2022-09-22 11:16:42.646 [DEBUG] [ort.serial.internal.RxTxPortProvider] - No SerialPortIdentifier found for: /dev/ttyUSB2
2022-09-22 11:16:42.953 [DEBUG] [ort.serial.internal.RxTxPortProvider] - No SerialPortIdentifier found for: /dev/ttyUSB1
2022-09-22 11:16:43.048 [DEBUG] [ort.serial.internal.RxTxPortProvider] - No SerialPortIdentifier found for: /dev/ttyUSB0
The rxtx (nrjavaserial) ships its own locking mechanism based on files to guarantee exclusive access to serial port. Sometimes these locks are not being released thus serial port can not be opened. I think @fwolter can elaborate a bit more about cause.
@fwolter would it make sense to unconditionally remove /var/lock/LCK..tty* on openHAB start ?
EDIT: limited to ttyUSB* ttyACM0 ttyAMA0 if started in openHABian (not OH on every platform)
There should not be any other software running in openHABian that is locking serial ports.
IIRC, nrjavaserial is smart enough to detect stale lock files and remove them upon start. I don’t think the two problems you had are connected.
There was a bug preventing gnu.io.rxtx.SerialPorts to be processed, when OH was started manually. It’s an old one, but maybe your shell scripts weren’t updated for some reason?
IIRC nrjavaserial only removes stale locks if the PID in them no longer exists. So if another process is running with the old PID that openHAB had before it starts it will not remove the lock files and you might run into this issue.
Usually your OS already takes care of removing these temporary files on bootup. On Debian based distros this is done using tmpfiles.d (e.g. /usr/lib/tmpfiles.d/legacy.conf).
@mstormi same error here: after upgrade to OpenHAB 4 I cannot start openhab anymore
journalctl -xe says
Aug 07 15:32:47 openHABianPi rm[3663]: /usr/bin/rm: das Entfernen von '/var/lock/LCK..ttyAMA0' ist nicht möglich: Datei oder Verzeichnis nicht gefunden
Aug 07 15:32:47 openHABianPi rm[3663]: /usr/bin/rm: das Entfernen von '/var/lock/LCK..ttyACM0' ist nicht möglich: Datei oder Verzeichnis nicht gefunden
Aug 07 15:32:47 openHABianPi systemd[1]: openhab.service: Control process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited