Open denis-ftc-denisov opened 3 years ago
Hmm must be something with OpenSUSE since I think we have reports of having some sort of success with serial devices in OH3. Any theories why this is so?
If this change (workaround?) is indeed required for openSUSE, should this change live somewhere in openHAB core / nrjavaserial that all bindings benefit from this?
Hello!
It seems better to fix that inside nrjavaserial, but i don't know which version now openhab uses (so, where to send PR). This https://github.com/openhab/nrjavaserial looks like frozen repository.
I don't have working theory right now, because in nrjavaserial code (as eclipse shows it) there already is similar logic (in CommPortIdentifier.getPortIdentifier(String)
). Maybe my OpenHab version uses older version of nrjavaserial. I'll try to decompile that and take a look.
Hello!
I've investigated further, it seems that nrjavaserial-5.2.1
is used (despite having 3.12.0
in pom.xml
). So it should really call getPortIdentifiers()
when port is not found. My best guess is that some exception occurs inside getPortIdentifiers()
(in this case CommPortIndex will stay null).
Hello!
I was receiving a problem of OpenHAB being to unable to open COM port under OpenSUSE Linux (detailed explanation and what i've tried is here https://community.openhab.org/t/modbus-binding-does-not-see-serial-port/118527).
More exactly, there was these errors in logfiles:
After poking the code for some time it seems to me, that
CommPortIdentifier
class could return null for existing port if there was no call togetCommPortIdentifiers()
before callinggetCommPortIdentifier(String)
(that is because is has internal list of ports with head inCommPortIndex
variable and this list is filled only whengetCommPortIdentifiers()
is called).So, i'm suggesting a bit ugly but tiny workaround for that problem. I've tested it in my environment and it works after fix.