openhab / openhab-addons

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

Replace gnu.io dependency of add-ons with serial transport #7573

Open wborn opened 4 years ago

wborn commented 4 years ago

There are still add-ons which depend on gnu.io for their serial communications. By using the serial transport we can switch between serial implementations (rxtx, javacomm) without having to change any add-on code. It also allows for using RFC2217 ports.

These bundles still depend on gnu.io:

lolodomo commented 4 years ago

The rotelra1x binding is supposed to be removed in OH 3.0 as it was replaced by the rotel binding. We kept it in 2.5 to let the time to users to move to the new binding.

wborn commented 4 years ago

Great! I've updated the list so we won't spend any time on migrating that one. :+1:

gnlpfjh commented 4 years ago

With #6447 phc binding uses serial transport.

wborn commented 4 years ago

Very nice! I even see you updated the POM for the import that was added in https://github.com/openhab/openhab-addons/pull/7589. :+1:

mvalla commented 4 years ago

What is to be done in case of a transitive dependency from a library that uses nrjavaserial (like in the case of KNX) ?

bodiroga commented 4 years ago

This should be pinned again, I think that @jsjames has unpinned it unintentionally :wink:

wborn commented 4 years ago

Yes all 3 issues were unpinned by @jsjames. :neutral_face:

wborn commented 4 years ago

What is to be done in case of a transitive dependency from a library that uses nrjavaserial (like in the case of KNX) ?

It depends on the library implementation. In case of KNX it might be possible to remove the calimero-rxtx dependency and instead reimplement RxtxAdapter by using the serial transport instead.

If it's named tuwien.auto.calimero.serial.RxtxAdapter it will be used instead by the LibraryAdapter, see

holgerfriedrich commented 2 years ago

@wborn I could need some advice on how to proceed with KNX binding (Calimero library). We could easily remove the calimero-rxtx library, but the would also remove the KNX over serial interfacte feature. So this is not an option. Rewriting the RxtxAdapter class as suggested could be an option, but we would need to do it in the context ""tuwien.auto.calimero.serial", as a class lookup is hard coded in the calimero-core library as follows: src/tuwien/auto/calimero/serial/LibraryAdapter.java: final Class<?> c = Class.forName("tuwien.auto.calimero.serial.RxtxAdapter"); Not sure if this is a good idea (technically). Reusing the source code for RxtxAdapter might be a problem as well, as we might run into issues with incompatible licenses (Calimero is GPL2 with classpath exception, openHab EPL2).

kaikreuzer commented 2 years ago

@wborn Do you have any good idea wrt @holgerfriedrich's question on how to best proceed for KNX?

holgerfriedrich commented 2 years ago

@kaikreuzer Calimero 2.5.1 release branch has just been created a few hours ago; the code for serial port has changed..... let's see....

wborn commented 2 years ago

Yes it looks like you can now create your own SerialCom implementation and use that instead of the calimero-rxtx dependency. It will create/use a SerialCom instance based on the class name in META-INF/services/tuwien.auto.calimero.serial.spi.SerialCom, see: https://github.com/calimero-project/calimero-rxtx/commit/1e74d815b05ef1a14268095df2b512e760305d09

lsiepel commented 1 year ago

Work for the Pentair binding is on the way as @jsjames filed a PR for it: https://github.com/openhab/openhab-addons/pull/13485

holgerfriedrich commented 1 year ago

@wborn I created our own SerialCom implementation. In principle this seems to work, but there is a problem once the framework reloads the KNX plugin. ServiceLoader does not find the implementation anymore (or I have not yet found a way to properly push it), so I need to restart openHAB to properly reload. If you have any suggestion, please comment in #14051.

openhab-bot commented 1 year ago

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/usb-port-conflict-zigbee2mqtt-and-modbus/143448/8

mvalla commented 9 months ago

For [openwebnet] just sbmitted a new PR that makes the binding independent from gnu.io. See #16376.