openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.58k forks source link

Bindings that do not use the serial transport crash the JVM when /dev/serial/ symlinks are used #15509

Open semkink opened 1 year ago

semkink commented 1 year ago

Hello! When I use /dev/serial/ symlinks for usb serial device in textual .things config file the OH restarting endless.

Example of using Bridge modbus:serial:Relay [ port="/dev/serial/by-id/usb-Silicon_Labs_CP2104_USB_to_UART_Bridge_Controller_013B3E17-if00-port0", id=57, baud=9600, stopBits="1.0", parity="none", dataBits="8",encoding="rtu", timeBetweenTransactionsMillis=35, connectMaxTries=1, receiveTimeoutMillis=500 ] {}

The OH falls in endless restarting loop after any pooler created.

Bridge poller PoolerRelay "Poller Relay 63" [ start=0, length=6, refresh=1000, type="coil" ]

wborn commented 1 year ago

Which OH version and OS do you use?

semkink commented 1 year ago

OH 4.0.2
Openhabian 1.8.b Release = Raspbian GNU/Linux 11 (bullseye) Kernel = Linux 6.1.21-v7+ Platform = Raspberry Pi 3 Model B Rev 1.2

wborn commented 1 year ago

The reason seems to be that the Modbus Binding is one of the few remaining bindings that do not use the OH serial transport. As a result it cannot use the workaround introduced in https://github.com/openhab/openhab-core/pull/3290 which prevents buffer overflows from happening in the nrjavaserial native code.

The Modbus Binding could also use the workaround if it is adapted to use the OH serial transport:

Another way would be to upgrade nrjavaserial to a version that has https://github.com/NeuronRobotics/nrjavaserial/pull/230. But there hasn't been a new release that contains this fix, so we would have to create our own.