Java Libraries to Use for Serial and USB Devices

openhab2
Tags: #<Tag:0x00007f1e56829b48>
(Burzin Sumariwalla) #1

Hello,

I’m attempting to write a binding for Openhab. There are two different bridges, and the the bridge devices for the binding connect to Openhab via either a RS232 port or a USB port. What Java serial and USB libraries should I use with my project?

Regards,
Burzin

0 Likes

(Łukasz Dywicki) #2

There is no consensus as Java miss support for sierial/USB ports in standard library. Each and every binding uses own way. General recommendation (I guess) is to use https://github.com/openhab/nrjavaserial which is bundled together with openhab.
It is available with esh-io-transport-serial-rxtx (<=2.5.0) or openhab-io-transport-serial-rxtx (>2.5.0) feature within openhab/karaf shell console.

0 Likes

(Hilbrand Bouwkamp) #3

For serial you should use not use the libraries directly but via the abstracted interface in openHAB via org.eclipse.smarthome.io.transport.serial.SerialPortManager.

1 Like

(Burzin Sumariwalla) #4

Thanks All

0 Likes

(Thomas Fischer) #5

I tried to use “org.eclipse.smarthome.io.transport.serial.SerialPortManager” on my Windows-Installation.

Unfortunately, the "getIdentifier(“COM3”) -call never succeeds, even this Serial-port exists (USB-Serial)

With “gnu.io.SerialPort” (or jssc) the same port works!!

What can be the reason?

Thanks for your support!

Regards
Thomas

0 Likes