Problems accessing serial ports via symlinks (on Linux)

1,794 views
Skip to first unread message

Ben Jones

unread,
Jul 4, 2013, 11:02:37 PM7/4/13
to ope...@googlegroups.com
I have been trying to setup udev rules for my various USB devices since each time I unplug them and reconnect they get assigned a different ttyUSB* name. 

For instance I have RFXCOM and ZWave USB devices with the following symlinks defined;

   /dev/rfxcom
   /dev/zwave

However when using these syslinks in my openHAB configuration file the bindings always fail to connect. Using the direct ttyUSB* device name works just fine.

After some digging I discovered this is a known issue with th RXTX library being used by openHAB (http://rxtx.qbang.org/wiki/index.php/FAQ).

Therefore by adding the following to the connection logic before attempting to open the port;

// work around to allow device symlinks to work in Linux
System.setProperty("gnu.io.rxtx.SerialPorts", device);

// get port identifier
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(device);

The bindings work with symlinks. I have tested this on the RFXCOM binding, but not ZWave as I don't have the latest code for that from Brian.

Can all bindings that use this RXTX library be updated to include this work-around so users like myself can use symlinks instead of having to update our config files every time we unplug a device?

Cheers,
Ben
Message has been deleted
Message has been deleted
Message has been deleted

Ben Jones

unread,
Jul 5, 2013, 9:44:59 PM7/5/13
to ope...@googlegroups.com
Ok - this didn't work as expected. Setting the system property in each binding is no good, since it is a 'system' property and each binding effectively overwrites the other! Therefore my RFXCOM binding was starting up ok, but ZWave was failing. After some more digging I have found that you either need to add a property to the java command line, or add the values to a properties file.

I have updated my startup script to include "-Dgnu.io.rxtx.SerialPorts=/dev/rfxcom:/dev/zwave" in the Java command line. Now everything is working as expected.

So ignore my first post about updating bindings - I think we leave the bindings as they are - and if you want to use symlinks with the RXTX library you need to set this gnu.io.rxtx.SerialPorts yourself - either as I have done in the command line args or in a properties file in the classpath (property file should be name gnu.io.rxtx.properties - see http://create-lab-commons.googlecode.com/svn/trunk/java/lib/rxtx/README.txt).

Kai Kreuzer

unread,
Jul 6, 2013, 4:45:03 PM7/6/13
to ope...@googlegroups.com
Thanks for this update, Ben!

Would be probably worth an entry in the tips&tricks section of the sample wiki (https://code.google.com/p/openhab-samples/wiki/Tricks), don't you think?

Regards,
Kai

--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ben Jones

unread,
Jul 6, 2013, 5:50:15 PM7/6/13
to ope...@googlegroups.com
Yep - good idea - done!
Reply all
Reply to author
Forward
0 new messages