Serial Binding: Port could not be found

Hi,

I’m trying to connect an arduino via Serial Protocol(Serialbinding 1.7.1) to openhab 1.7.1, running on raspberry pi (Linux raspberrypi 4.1.6+ #810 PREEMPT Tue Aug 18 15:19:58 BST 2015 armv6l GNU/Linux). But the connection fails with following exception:

Binding configuration of type ‘serial’ of item ‘Arduino‘ could not be parsed correctly.
org.openhab.model.item.binding.BindingConfigParseException: Could not open serial port /dev/ttyUSB0: Serial port ‘/dev/ttyUSB0’ could not be found. Available ports are:

    at org.openhab.binding.serial.internal.SerialBinding.processBindingConfiguration(SerialBinding.java:129) ~[na:na]
    at org.openhab.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:348) [org.openhab.model.item_1.7.1.jar:na]
    at org.openhab.model.item.internal.GenericItemProvider.dispatchBindingsPerType(GenericItemProvider.java:309) [org.openhab.model.item_1.7.1.jar:na]
    at org.openhab.model.item.internal.GenericItemProvider.addBindingConfigReader(GenericItemProvider.java:106) [org.openhab.model.item_1.7.1.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0]
    at org.eclipse.equinox.internal.ds.model.ComponentReference.bind(ComponentReference.java:376) [org.eclipse.equinox.ds_1.4.1.v20120926-201320.jar:na]
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.bindReference(ServiceComponentProp.java:444) [org.eclipse.equinox.ds_1.4.1.v20120926-201320.jar:na]
    at org.eclipse.equinox.internal.ds.InstanceProcess.dynamicBind(InstanceProcess.java:416) [org.eclipse.equinox.ds_1.4.1.v20120926-201320.jar:na]
    at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:334) [org.eclipse.equinox.ds_1.4.1.v20120926-201320.jar:na]
    at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222) [org.eclipse.equinox.ds_1.4.1.v20120926-201320.jar:na]
    at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.equinox.internal.ds.InstanceProcess.registerService(InstanceProcess.java:536) [org.eclipse.equinox.ds_1.4.1.v20120926-201320.jar:na]
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:260) [org.eclipse.equinox.ds_1.4.1.v20120926-201320.jar:na]
    at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473) [org.eclipse.equinox.ds_1.4.1.v20120926-201320.jar:na]
    at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217) [org.eclipse.equinox.ds_1.4.1.v20120926-201320.jar:na]
    at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816) [org.eclipse.equinox.ds_1.4.1.v20120926-201320.jar:na]
    at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783) [org.eclipse.equinox.ds_1.4.1.v20120926-201320.jar:na]
    at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89) [org.eclipse.equinox.ds_1.4.1.v20120926-201320.jar:na]
    at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70) [org.eclipse.equinox.util_1.0.400.v20120917-192807.jar:na]

I already added the java argument to the openhab start script in init.d and openhab/bin/ folder like so:

  # Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

DEBUG_ARGS="-Xdebug \
  -Xnoagent \
  -Djava.compiler=NONE \
  -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n \
  -Dlogback.configurationFile=${OPENHAB_CONF_DIR}/logback_debug.xml"

JAVA_ARGS_DEFAULT="-Dosgi.clean=true \
 -Declipse.ignoreApp=true \
 -Dosgi.noShutdown=true \
 -Djetty.port=${HTTP_PORT} \
 -Dopenhab.configfile="${OPENHAB_CONF_DIR}/configurations/openhab.cfg" \
 -Dopenhab.configdir="${OPENHAB_CONF_DIR}/configurations" \
 -Dopenhab.logdir="${OPENHAB_LOG_DIR}" \
 -Dsmarthome.userdata="${OPENHAB_USER_DATA_DIR}"
 -Djetty.home="${OPENHAB_DIR}" \
 -Djetty.port.ssl=${HTTPS_PORT} \
 -Djetty.config="${OPENHAB_CONF_DIR}/jetty" \
 -Djetty.logs="${OPENHAB_LOG_DIR}" \
 -Djetty.rundir="${OPENHAB_DIR}" \
 -Dfelix.fileinstall.dir="${OPENHAB_DIR}/addons" \
 -Dfelix.fileinstall.filter=.*\\.jar \
 -Djava.library.path="${OPENHAB_DIR}/lib" \
 -Djava.security.auth.login.config="${OPENHAB_CONF_DIR}/login.conf" \
 -Dorg.quartz.properties="${OPENHAB_CONF_DIR}/quartz.properties" \
 -Dequinox.ds.block_timeout=240000 \
 -Dequinox.scr.waitTimeOnBlock=60000 \
 -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0\
 -Dfelix.fileinstall.active.level=4 \
 -Djava.awt.headless=true \
 -jar ${LAUNCHER} \
 -configuration ${OPENHAB_WORKSPACE_DIR} \
 -data ${OPENHAB_WORKSPACE_DIR} \
 -console ${TELNET_PORT}"

if [ x"${JAVA_ARGS}" != x ]; then
	JAVA_ARGS_DEFAULT="${JAVA_ARGS} ${JAVA_ARGS_DEFAULT}"
fi

if [ x"${OPENHAB_ARGS}" != x ]; then
	JAVA_ARGS_DEFAULT="${JAVA_ARGS_DEFAULT} ${OPENHAB_ARGS}"
fi

if echo ${DEBUG} | grep -qi "^yes$"; then
	JAVA_ARGS_DEFAULT="${DEBUG_ARGS} ${JAVA_ARGS_DEFAULT}"
else
	JAVA_ARGS_DEFAULT="-Dlogback.configurationFile=${OPENHAB_CONF_DIR}/logback.xml ${JAVA_ARGS_DEFAULT}"
fi

case "$1" in
  start)
        log_daemon_msg "Starting $DESC" "$NAME"
		${OPENHAB_INST_DIR}/bin/setpermissions.sh > /dev/null
		if start-stop-daemon --start --quiet --pidfile $PIDFILE $EXTRA_ARGS \
			--oknodo --exec $JAVA -- $JAVA_ARGS_DEFAULT
		then
        	log_end_msg 0
        else
        	log_end_msg 1
		fi
        ;;

by the way: which way is right?
-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0\ or -Dgnu.io.rxtx.SerialPorts="/dev/ttyUSB0"
Nevertheless non of these ways worked for me.

items document:

String Arduino "Arduino" { serial="/dev/ttyUSB0@115200" }
Number          livingTemp01                             "Temperatur [%.1f °C]" <temperature> (Temperature,GF_Living)

Accessing to /dev/ttyUSB0, by for example screen, works without any problems.

EDIT:

When I start openhab with the start.sh file, it works without any problems.
So what’s different to the /init.d/openhab startup file?
The User? openhab vs root?

Can anybody help?

Thank you!

Hello there,

It would be nice to have an answer on that one.
I use openhab 1.7.1 (installed via apt-get), I copied the demo files on top of it and tuned them a bit to read a temperature via a serial binding (MySensors, which is the same as Peet I believe)

If I start openhab with “sudo /etc/init.d/openhab start” the website is up but the relevant Temperature item read “- °C”
If I start openhab with “sudo /usr/share/openhab/bin/start.sh” the temperature item gets the correct value…

One other thing, I change the group of all files and directories inside the “configurations” directory (the new group is my user so I can modify them without “sudo” (permitions set to 775 instead of 755).

Other info : It is running on an embedded linux like the raspberry but another one (hummingboard)

Thanks for the help, it is not very user friendly to have to keep an ssh terminal active (even with a detached screen :wink: )

have you tried adding user “openhab” to group “dialout”?

1 Like

Well I don’t have a user named openhab. Do you mean I should create one? Or should I add root or myusername to dialout ?

are you sure? I didn’t think I did, but apt-get created one for me…

Well I check with the command users which gave me only myuser as a result but openhab is listed in /etc/passwd so I’ll try :wink:

Ok that did half the trick.
Now the temperature item is correctly shown but not the humidity (which of course was working just fine with start.sh)
(As a new user, it seems I can’t have more then 3 replies on a topic … So I dont know how I’m going to reply to your next reply …

Ok, I added myuser and root to dialout, reboot and it worked !
Thanks Dan for this quick fix !!!

thank you! that worked for me as well!

Excellent! The same problem cost me two days earlier this week… I too was fooled by the fact that “users” doesn’t list the openhab user.

I’ve added it into the wiki

It would be good to add some information to the manual installation method to create and configure the openhab user. I did a manual installation and I’m having the same issues. At least I know which direction to investigate when I get home, so thanks for the info :smile:

FIXED:

I have installed Openhab 1.7.1 from apt-get, and I was getting the error:
[ERROR] [b.z.i.protocol.ZWaveController] - Serial Error: Port /dev/ttyAMA0 does not exist
( On a Razberry )

I had to add

-Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0 \

to /user/share/openhab/bin/openhab.sh (JAVA_ARGS_DEFAULT= section)

not to /etc/init.d/openhab

(this is in addition to adding the openhab user to the dialout group in /etc/groups)

I have the same problem but following all the instructions here I cannot get it working.

Here is my scenario: raspberrt pi 2
installed the MySensorsGateway serial onto the Pi (nrf24 radio connected on the pi)
using openhab 1.8.2 installed with apt-get
file /etc/init.d/openhab has line -Dgnu.io.rxtx.SerialPorts=/dev/ttyMySensorsGateway \ just after -Dosgi.noShutdown=true
the same was added for file /usr/share/openhab/bin/openhab.sh
when I run sudo service openhab start, I get the error and available ports are: (empty)
if I run sudo /usr/share/openhab/bin/openhab.sh then it works
I did add openhab to dialout, if I run groups openhab I get: openhab : openhab dialout

ttyMySensorsGateway is a soft device, actually a link
ls -l ttyMySensorsGateway gives lrwxrwxrwx 1 root root 10 date ttyMySensorsGateway -> /dev/pts/0
ls -l /dev/pts/0 gives crw-rw---- 1 root tty136, 0 date /dev/pts/0

Any ideas? I’m not very experienced with Linux so I might be doing a simple mistake

Edit: I finally got it working by adding the user openhab to group tty
Now I can’t get openhab service to start up at boot but that’s for another topic. Linux hates me.