Serial port access from FreeBSD

I have openhab running in a freebsd jail. I have been unable to get my USB z-wave stick working. It comes up /dev/cuau0 but openhab keeps complaining that the device doesn’t exist.

I have been led to believe that this is a java issue, and that the rxtx library has something to do with it. As of yet I have been unable to figure out how to get java to recognize the device under bsd.
Has anyone else been able to overcome this?
Thanks.

Slight update:
I attempted to build a library from freebsd’s comms/rxtx port, substituted the resulting library with the one in the openhab source, and attempted to build openhab.
I got this:
[…] openhab-master/bundles/binding/org.openhab.binding.urtsi/src/main/xtend-gen/org/openhab/binding/urtsi/internal/UrtsiDevice.java:[126]
ERROR] RXTXPort _open = this.portId.open(“openHAB”, 2000);
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Type mismatch: cannot convert from CommPort to RXTXPort
[ERROR] 1 problem (1 error)

Not sure where to go from here.

I don’t have experience running openHAB on FreeBSD but on Linux, 99% of the time this error means that the openhab user doesn’t have permission to read/write to the device. It is unfortunate that almost all errors for reading and writing to the device are reported as the device not existing

Adding the openhab user to the dialout group usually does the trick. Assuming you haven’t done this already, look at permissions before spending a lot of time debugging libraries.

I wish it were that easy.
I attempted to add “-Dgnu.io.rxtx.SerialPorts=/dev/cuau0” but that threw a new exception altogether.
Just for laughs I have attempted to run openhab as root to eliminate the possibility of permission problems; still no luck.

All these things, pointing the library to the right place, changing permissions, linking to more common device names, they have fixed it for Ubuntu, Arch, Debian, Raspian all across multiple hardware architectures for me. It’s just this blasted FreeBSD that’s giving me trouble.

FreeBSD, so secure no one can use it. :stuck_out_tongue_winking_eye:

Hi Alex,

Not sure if this is still an issue for you. I’m having the same sort of problems with FreeBSD. The problem seems to be that openHAB uses nrjavaserial (a fork of rxtx) and it doesn’t support FreeBSD. The difference however is that nrjavaserial loads the native libraries directly from it’s own jar file. This means that substituting the rxtx libraries is not going to work.

Some googling produced a post by Jan-Willem Spuij who fixed nrjavaserial to support FreeBSD and somehow got this to work.

https://groups.google.com/forum/?pli=1#!topic/openhab/fLAs5NdLwpw

I’m still in the process of getting his patches to work, but at the moment replacing the org.openhab.io.transport.serial.XXX seems to get ignored. Using the original makes the zwave binding attempt to open the serial port, using the newly built one nothing happens. I’m not sure if OSGI verifies checksums, or sizes or something?

Maybe we can swap notes? Did you get any further with this problem?

Kind regards,
Marc van Kempen.

I found the same thing. Attempted the patches and wound up fighting the build processes for a few dependencies on top of it. In the end /I/ did not wind up persevering. I ultimately put openhab on an embedded device running Linux and haven’t needed to resolve fbsd issue.

If you do wind up coming up with a solution then please do share. Unfortunately I have nothing further to add.

Hi,

Good news!

I managed to get it to work with the 1.8.0 sources from yesterday. The trick to recompile, and this should really be documented somewhere, is to always make clean before rebuilding. This seems to be the case both on FreeBSD and Linux. I’m not sure how the openhab developers are not going crazy doing this (takes almost 10 minutes on my system to clean and rebuild everything), so I’m guessing/hoping! that there is some trick to it that I have not yet found.

Be that as it may, applying Jan-Willem Spuij’s patches, rebuilding nrjavaserial with it, copying the library to bundles/io/org.openhab.io.transport.serial/lib/ and then doing mvn clean package does rebuild everything and results in a working distribution.

I’ll now look into making this into a port so we don’t have to muck about with this every time a new release comes out. Or even better, get the nrjavaserial guys to accept the patches and support FreeBSD out of the box.

For now here are more detailed instructions to do this yourself:

  1. Get the openHAB sources -> extract them somewhere, say OHSRC
  2. Get the nrjavaserial sources
  3. Apply the patches from the thread https://groups.google.com/forum/?pli=1#!topic/openhab/fLAs5NdLwpw
  4. Build nrjavaserial (basically do ‘make freebsd’)
  5. Get the resulting library (for version 3.11.0) from build/libs/nrjavaserial-3.11.0.jar and copy it to $(OHSRC)/bundles/io/org.openhab.io.transport.serial/lib/
  6. Change the version number in $(OHSRC)/bundles/io/org.openhab.io.transport.serial/build.properties and $(OHSRC)/bundles/io/org.openhab.io.transport.serial/META-INF/MANIFEST.MF
  7. cd $(OHSRC)
  8. mvn clean
  9. mvn package
  10. wait 10 minutes
  11. The new distribution files are in $(OHSRC)/distribution/target

Cheers,
Marc.

@marcvk,
I’ve seen your contribution went into nrjavaserial-3.12.0, on which openHAB 2.0 is based.

Since the recompilation of nrjavaserial shouldn’t be needed, I think that 2.0.0 should work out of the box, except maybe the setting in the startup script for multicast.

Did someone already try to setup the new release on FreeBSD?

Hi,

I’ve played around with it and ran into some problems (it’s been a couple of weeks, I’m not sure about the details anymore) and ran out of time to look at it. If someone manages to fix it, I’d love to hear it.

Cheers,
Marc.

Marc van Kempen
BowTie Technology BV
http://www.bowtie.nl
marc@bowtie.nl
mob. +31631998581

I’ve just got to similar (mostly like) problem:

attempting to run modbus on OH1 under FreeBSD:

[ERROR] [pi.modbus.net.SerialConnection] - Could not get port identifier, maybe insufficient permissions. null
[ERROR] [dbusSlaveConnectionFactoryImpl] - connect try 1/3 error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection@58b0009f[portName=/dev/ttyU0.3,port=]. Endpoint ModbusSerialSlaveEndpoint@32a0c935[portName=/dev/ttyU0.3]

permissions on the port are ok, I can read port w/o any problems with libmodbus
I’am trying modbus binding from 1.9.0-SNAPSHOT build

what are the current status of problem, are solution described here still actual?