Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new Serial Transport based on jSerialComm #3982

Open
mvalla opened this issue Dec 30, 2023 · 20 comments
Open

Add new Serial Transport based on jSerialComm #3982

mvalla opened this issue Dec 30, 2023 · 20 comments
Labels
enhancement An enhancement or new feature of the Core

Comments

@mvalla
Copy link
Contributor

mvalla commented Dec 30, 2023

Add a new OH Serial Transport bundle org.openhab.core.io.transport.serial.jserialcomm based on https://fazecast.github.io/jSerialComm/.

From website: jSerialComm is a Java library designed to provide a platform-independent way to access standard serial ports without requiring external libraries, native code, or any other tools. It is meant as an alternative to RxTx and the (deprecated) Java Communications API, with increased ease-of-use, an enhanced support for timeouts, and the ability to open multiple ports simultaneously.

The library seems actively maintained, it supports Apple Silicon, has no dependecies, and also supports LISTENING_EVENT_PORT_DISCONNECTED events (supported by NRJavaSerial and not by Pure Java Comm), useful nowdays that Serial ports devices are via USB and therefore can be unplugged.
The library has also support for USB specific info (productID/serialNumber/vendorID/product description) when available.
It's double licensed LGPL 3.0 and Apache 2.0.

There is already another OH binding using jSerialComm: ProteusEcoMeter (not using OH Serial Transport).

Before starting implementation on a new PR, I would like to have opinion of @openhab/core-maintainers on this issue.

See also mvalla/openwebnet4j#34 (comment)

@mvalla mvalla added the enhancement An enhancement or new feature of the Core label Dec 30, 2023
@wborn
Copy link
Member

wborn commented Dec 30, 2023

I think it is useful to have alternative implementations besides nrjavaserial to also support platforms that aren't supported or don't work well with nrjavaserial.

jSerialComm seems to have been considered earlier but because it used LGPL the Kura serial implementation was added to Eclipse SmartHome. Which is still there but probably unused.

If jSerialComm has better features, works well and is more maintained it may also be preferred to #3632.

@mvalla
Copy link
Contributor Author

mvalla commented Dec 30, 2023

jSerialComm seems to have been considered openhab/openhab-addons#2246 (comment) but because it used LGPL

It seems now jSerialComm it's double licensed LGPL 3.0 and Apache 2.0.

@realPyR3X
Copy link

@mvalla how does this work with, for example, the Zigbee Binding? I have a Sonoff Zigbee Dongle I'd like to use with openHAB on OpenBSD. RXTX is unsupported on OpenBSD so I'd love to swap this in and give it a test.

@mvalla
Copy link
Contributor Author

mvalla commented Mar 14, 2024

Which Sonoff Zigbee Dongle you have exactly?
Is it supported by openHAB in general?
Link to product ?

@realPyR3X
Copy link

SONOFF Zigbee 3.0 USB Dongle Plus V2 (ZBDongle-E)
Serial Interface Protocol: EmberZNet (EZSP)
Supported in openHAB

OpenBSD dmesg:

umodem0 at uhub2 port 3 configuration 1 interface 0 "ITEAD SONOFF Zigbee 3.0 USB Dongle Plus V2" rev 1.10/4.42 addr 2
umodem0: data interface 1, has no CM over data, has no break

https://sonoff.tech/product/gateway-and-sensors/sonoff-zigbee-3-0-usb-dongle-plus-p/

@realPyR3X
Copy link

@mvalla any thoughts? I'd love to test this

@mvalla
Copy link
Contributor Author

mvalla commented Apr 17, 2024

Feel free to try it: support of serial communication using jSerialComm is not 100% complete but maybe what is missing can be added thanks to some testing

@realPyR3X
Copy link

Is there a packaged jar or kar I can deploy to test?

@mvalla
Copy link
Contributor Author

mvalla commented Apr 18, 2024

here you are:

you should remove .TXT from the file names, copy the jars to the addons folder of OH and from the OH Karaf console you now should be able to see these budles as Active:

  178|Active     |    1|openHAB Core :: Bundles :: Serial Transport (4.2.0.202404150308)|4.2.0.202404150308
  179|Active     |    1|openHAB Core :: Bundles :: Serial Transport for RXTX (4.2.0.202404150309)|4.2.0.202404150309
...
  183|Active     |    1|jSerialComm (2.11.0)|2.11.0
  184|Active     |    1|openHAB Core :: Bundles :: Serial Transport for jSerialComm (4.2.0.202404182122)|4.2.0.202404182122

then to make sure only the new bundle is used, again from Karaf you should de-activate this bundle:
bundle:stop 179 (where 179 in my case is the bundle id for "Serial Transport for RXTX" bundle, the default one)

From now on any use of the serial port in OH should use the new library.

Let me know!

@mvalla
Copy link
Contributor Author

mvalla commented May 10, 2024

@realPyR3X did you have time to test it?

@realPyR3X
Copy link

@mvalla I somehow missed this response from you 3 weeks ago. I was able to get "purejavacomm" working in the interim. by doing the same approach with stopping rxtx. I will swap that out for this and give it a test.

@realPyR3X
Copy link

@mvalla org.openhab.core.io.transport.serial.jserialcomm-4.2.0-SNAPSHOT.jar is not deploying from addons. The jSerialComm deploys but obviously doesn't start because it's missing the imports from the transport package:

    org.openhab.core.io.transport.serial;
            version="[4.2,5)",
    org.openhab.core.io.transport.serial.jserialcomm

@mvalla
Copy link
Contributor Author

mvalla commented May 10, 2024

The jSerialComm deploys but obviously doesn't start because it's missing the imports from the transport package:

that is because this jserialcomm addon is meant to be run on a OH 4.2 branch..
You could use one of the Milestone releases if you want

@realPyR3X
Copy link

@mvalla actually I said that wrong jSerialcomm deploys but your transport doesn't It appears your are importing:

org.openhab.core.io.transport.serial;version="[4.2,5)"

This isn't resolving the version should probably be 4.1 are you on a dev branch?

The transport serial exports:

Export-Package =
org.openhab.core.io.transport.serial;version=4.1.2

@realPyR3X
Copy link

lol we commented at the same time. Can I just edit the manifest for now or does it have to be on a milestone

@mvalla
Copy link
Contributor Author

mvalla commented May 10, 2024

I think editing the manifest should do the trick:
org.openhab.core.io.transport.serial;version="[4.2,5)" -> "[4.1,5)"

@realPyR3X
Copy link

@mvalla I set it to 4.1.2 to match the others. The bundle is active. Unfortunately my zigbee ember chipset can't open the serial devices.

@mvalla
Copy link
Contributor Author

mvalla commented May 10, 2024

ok, if you set log level to DEBUG for org.openhab.core.io.transport.serial.jserialcomm and copy here the log when you try to open the serial device, that would help to solve incompatibility

@realPyR3X
Copy link

@mvalla it works! I had an error in the manifest I edited. The chipset is online.

@realPyR3X
Copy link

@mvalla what will it take to get this to replace rxtx as the default serial transport? If not the default, what will be the process to enable it? i.e. disable rxtx through console and start the feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

No branches or pull requests

3 participants