serial binding not seeing al serial ports

2,547 views
Skip to first unread message

Koen De Voegt

unread,
Sep 19, 2011, 6:14:31 PM9/19/11
to openhab
Hey,

Your project looks great and looks like right what I need! Thx,

Some issues remain doh. I'm trying to use the serial binding tool. I'm
trying to interface openHAB to an Arduino UNO. OpenHAB appearently
onliy sees serial ports in the form /dev/ttyX and /dev/ttyUSBX but
not /dev/ttyAMX. Which is strange because both the Arduino IDE and
openHAB are using the same lib to communicate with serial. (Version
2.1-7) Error pasted below.


23:53:20.870 ERROR o.o.m.i.i.GenericItemProvider[:193] - Binding
information of type 'serial' for item ‘AVR‘ could not be parsed
correctly.
org.openhab.model.item.binding.BindingConfigParseException: Could not
open serial port /dev/ttyACM0: Serial port '/dev/ttyACM0' could not be
found. Available ports are:
/dev/ttyUSB0
/dev/ttyS1
/dev/ttyS0

at
org.openhab.binding.serial.internal.SerialBinding.processBindingConfiguration(SerialBinding.java:
132)
at
org.openhab.model.item.internal.GenericItemProvider.dispatchBindings(GenericItemProvider.java:
191)
at
org.openhab.model.item.internal.GenericItemProvider.getItems(GenericItemProvider.java:
168)
at
org.openhab.core.internal.items.ItemRegistryImpl.allItemsChanged(ItemRegistryImpl.java:
184)
at
org.openhab.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:
237)
at
org.openhab.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:
169)
at
org.openhab.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:
98)
at
org.openhab.model.core.internal.folder.FolderObserver.checkFolder(FolderObserver.java:
157)
at
org.openhab.model.core.internal.folder.FolderObserver.run(FolderObserver.java:
114)



BTW How to set the baudrate for the serial binding?

Kai Kreuzer

unread,
Sep 20, 2011, 2:51:33 PM9/20/11
to ope...@googlegroups.com
Hi!

> Your project looks great and looks like right what I need! Thx,

Thanks, nice to hear that you like it!

> OpenHAB appearently
> onliy sees serial ports in the form /dev/ttyX and /dev/ttyUSBX but
> not /dev/ttyAMX. Which is strange because both the Arduino IDE and
> openHAB are using the same lib to communicate with serial. (Version
> 2.1-7) Error pasted below.

This is indeed strange and I don't have any explanation for this. For retrieving the list of available serial ports, I am calling

gnu.io.CommPortIdentifier.getPortIdentifiers()

I would have expected that this returns an exhaustive list. Maybe you could address this in the RXTX discussion group as it seems to be an issue with this library?

> BTW How to set the baudrate for the serial binding?

This is not yet supported, it always uses 9600 baud. It should be easy to add a configurable baudrate, so if you require it, please feel free to enter a feature request in the issue tracker.

Best regards,
Kai

Adam K.

unread,
Nov 15, 2011, 4:44:46 AM11/15/11
to openhab
Hello.

Try to add java parameter:
-Dgnu.io.rxtx.SerialPorts=/dev/ttyACM0:/dev/ttyACM1

I've done this in openhab start.sh and it works for me (I had exactly
the same problem).

br,
Adam

jan.g...@googlemail.com

unread,
Dec 17, 2012, 5:29:38 PM12/17/12
to ope...@googlegroups.com
I have the same problem on my RPi. The fix does not work.
 
Experimental:  JNI_OnLoad called.
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
23:21:34.855 ERROR o.o.m.i.i.GenericItemProvider[:226] - Binding information of type 'serial' for item ‘AVR‘ could not be parsed correctly.
org.openhab.model.item.binding.BindingConfigParseException: Could not open serial port /dev/ttyAMA0: Serial port '/dev/ttyAMA0' could not be found. Available ports are:
        at org.openhab.binding.serial.internal.SerialBinding.processBindingConfiguration(SerialBinding.java:141)
My start.sh looks like this:
 
java -Dosgi.clean=true -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Djetty.port=$HTTP_PORT -Djetty.port.ssl=$HTTPS_PORT -Djetty.home=. -Dlogback.configurationFile=configurations/logback.xml -Dfelix.fileinstall.dir=addons -Djava.library.path=lib -Djava.security.auth.login.config=./etc/login.conf -Dorg.quartz.properties=./etc/quartz.properties -Dequinox.ds.block_timeout=240000 -Dequinox.scr.waitTimeOnBlock=60000 -Djava.awt.headless=true -jar $cp $* -console -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0
 
Distribution is Raspian. Openhab Version is 1.1.0.
 
java version "1.7.0_07"
OpenJDK Runtime Environment (IcedTea7 2.3.2) (7u7-2.3.2a-1+rpi1)
OpenJDK Zero VM (build 22.0-b10, mixed mode)
Any ideas?

daka

unread,
Dec 23, 2012, 10:59:14 AM12/23/12
to ope...@googlegroups.com
Hi Jan,

You can try to put the additional parameter (-Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0) at another place in the start string. The -console can be added with a parameter (i.e. port).
I think this will work:
java -Dosgi.clean=true -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0 -Djetty.port=$HTTP_PORT -Djetty.port.ssl=$HTTPS_PORT -Djetty.home=. -Dlogback.configurationFile=configurations/logback.xml -Dfelix.fileinstall.dir=addons -Djava.library.path=lib -Djava.security.auth.login.config=./etc/login.conf -Dorg.quartz.properties=./etc/quartz.properties -Dequinox.ds.block_timeout=240000 -Dequinox.scr.waitTimeOnBlock=60000 -Djava.awt.headless=true -jar $cp $* -console

It worked for me. I'm using socat as a nice tool to create a virtual serial port. Very usefull for inbound messages into openHAB. Socat creates virtual ports like /dev/pts/1. Without the extra parameter in the start script I couldn't see the port either. Now it works.

Cheerio,
David

Jan Gatzke

unread,
Dec 23, 2012, 12:40:17 PM12/23/12
to ope...@googlegroups.com
It works. Thanks!
 
What exactly do you do with the virtual serial Ports? Can you post some example rules?
 
Greetings,
 
Jan

daka

unread,
Dec 26, 2012, 6:08:00 AM12/26/12
to ope...@googlegroups.com
Hi Jan,

Socat is a command line based utility that establishes two bidirectional byte streams and transfers data between them. I wanted to monitor the open files in my plug computer. So I created a shell script that reads the openfiles and outputs it to a serial port (/dev/pts/1). This script can be executed with the exec binding. openHAB is listening on the other serial port and reads the number of openfiles. Socat can also be used to reroute TCP connections to a serial port. This makes inbound traffic possible. Google is your friend to find some examples.

Regards,
David


Op zondag 23 december 2012 18:40:17 UTC+1 schreef Jan Gatzke het volgende:

Rob B

unread,
Apr 27, 2014, 5:08:45 AM4/27/14
to ope...@googlegroups.com
Thanks for posting this. I had this parameter at the end of line in ignorance and your post has fixed my issue. Now I can start to troubleshoot my first pass configuration.

karsten.k...@gmail.com

unread,
Jun 23, 2014, 10:39:03 AM6/23/14
to ope...@googlegroups.com
had a similar issue - have updated the serial binding wiki to prevent people searching for this.

@Kai/ Thomas - i opened an issue on this one. mayby a config section is worth to look at in the openhab.cfg:

https://github.com/openhab/openhab/issues/1175

Cheers
Karsten

Markus Rathgeb

unread,
Jun 24, 2014, 4:51:44 PM6/24/14
to ope...@googlegroups.com
That could already be found in the openHAB wiki.
Just to know where to look at.

https://github.com/openhab/openhab/wiki/Samples-Tricks#how-to-configure-openhab-to-connect-to-device-symlinks-on-linux

I am using a script, that reads my openhab.cfg, adds the serial ports for Z-Wave and EnOcean to the start.sh (to a copy of) and starts it.

Ervin Sirk

unread,
Dec 8, 2014, 6:28:42 AM12/8/14
to ope...@googlegroups.com
Hello,

I would like to add a bit to this topic. 
I'm trying to make my raspberry pi work with two serial ports. 
One port is connected to the gpio rx/tx and the other is a usb-to-serial adapter.
Maybe this post can save some nerves of someone else trying to do the same.

I added the well noted commandline parameter -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0 to my start.sh
Maybe its only my configuration, but after that I lost access to /dev/ttyUSB0 port from openhab.
So after lots-and-lots of experiments and research, I solved the problem with this:
-Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0:/dev/ttyUSB0
It seems to me that the -Dgnu.io.rxtx.SerialPorts= parameter overrides all default configuration of /dev/ttyUSBx & /dev/ttySx, so all serialports must be redefined (and separated with a colon).
Someone correct me if I'm wrong, but that made my ports work.

Another thing that I'm troubled with is the baudrate.
I understand that it is set to default speed of 9600.
I can change the speed with this command in raspian console:
stty -F /dev/ttyUSB0 4800 and stty -F /dev/ttyAMA0 4800
to set baudrates to 4800 (which is the speed that I need) on  both ports.
I added these lines to my startup script (start.sh):

echo "Setting Serial Ports Baud Rates to 4800"
#UART on GPIO
sudo stty -F /dev/ttyAMA0 4800
echo -n "Speed of GPIO UART is: "
stty -F /dev/ttyAMA0 speed

#USB UART
if [ -e /dev/ttyUSB0 ]; then
sudo stty -F /dev/ttyUSB0 4800
echo -n "Speed of USB0 UART is: "
stty -F /dev/ttyUSB0 speed
fi

But openhab changes baudrates back to 9600 once it has loaded the up all. 
I can change baudrates manually with stty command after openhab has loaded.
But I would like to make it happen automatically. My openhab runtime starts automatically on boot.

I could add a startup rule with executeCommandline action, but maybe there is a more sophisticated method for that? 


Best Regards,
Ervin

Reply all
Reply to author
Forward
0 new messages