Modbus Binding not working on OH3

@lampy Thank you, this was very useful.

It seems that it is stuck opening the serial port… This gives further indication where the problem is and how to resolve it

“OH-modbusManagerPollerThreadPool-3” Id=223 in TIMED_WAITING

at java.base@11.0.9/java.lang.Thread.sleep(Native Method)

at gnu.io.RXTXPort.waitForTheNativeCodeSilly(RXTXPort.java:958)

at gnu.io.RXTXPort.<init>(RXTXPort.java:180)

at gnu.io.RXTXCommDriver.getCommPort(RXTXCommDriver.java:983)

Looking at the relevant code (assuming openhab uses fresh version)

/**
 *	Give the native code a chance to start listening to the hardware
 *	or should we say give the native code control of the issue.
 *
 *	This is important for applications that flicker the Monitor
 *	thread while keeping the port open.
 *	In worst case test cases this loops once or twice every time.
 */

protected void waitForTheNativeCodeSilly()
{
	while( MonitorThreadLock )
	{
		try {
			Thread.sleep(5);
		} catch( Exception e ) {}
	}
}

This seems to indicate that locking is somehow buggy with the serial library (nrjavaserial) used by the openHAB.

Potential up stream issue initialise_event_info_struct: initialise failed! · Issue #111 · NeuronRobotics/nrjavaserial · GitHub (I guess @fwolter found this already)

@fwolter does this look familiar?

1 Like