Serial binding on rpi

Hi,
Yeah am still a bit unsure how usb works on linux. But you need to add openhab to the dialout group: sudo adduser openhab dialout
However I am not sure how you can test if the user has been added.

Then the second thing you need to do is to assign your device to a static usb port.

this is stored in rules files, i think you need 1 tule file for each usb device and they to have the static usb name : 99-usb-serial.rules (from the mysensor wiki)
/etc/udev/rules.d/99-usb-serial.rules"

with your device info:
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A40360T2", SYMLINK+="ttyUSB99"

but from the dmx wiki on openhab it looks like this:

sudo nano /etc/udev/rules.d/30-ftdidmx.rules

ACTION=="add", BUS=="usb", SYSFS{idVendor}=="0403", SYSFS{idProduct}=="6001", GROUP:="dialout", MODE:="0660"

So I have no idea which method is the best, and what the two different method does…
to find out what device you have use this command: dmesg

and thenls tty to list out your usb port in use

Hope it helps a little bit.

Thanks for the reply, but a few things. My process is being run by user pi not openhab. I think this is because I manually installed. Pi is a member of dialout. I included in my post output from dmesg to show my two serial devices. I think your suggestion about adding the sim link only prevents having to change configuration when, after a reboot, devices change usb assignment (i.e. A device that was on ttyUSB0 is now on ttyUSB1). I get the value but I don’t think that is the problem I am having. But again, thanks for replying as I am pulling my hair out. It’s gotta be something dumb that I’ve done because this was working fine for two weeks.

So today I tried a different Raspberry Pi and just swapped SD cards and all is working now as it was before. So I’m pretty sure I have a bad USB port on the card.

In case @chris reads this. My problem was actually flip flopping between zwave and serial because after reboots the ttyUSB assignment would sometimes change. So also solves: Z-Wave ConverterHandler not initialised

If you want to make sure a certain user sees something use @username.

Cool. Thanks for the tip.

Hallo dear all!
I have the same issue by connecting with Arduino UNO R3. I running Ubuntu 16.04 arm64 and OpenHab 1.8.3 on [Odroid C2 board] (http://odroid.com/dokuwiki/doku.php?id=en:odroid-c2). My situation:

  1. Arduino port is defined at /dev/ttyACM0. Adruino IDE on Odroid works properly with this plate. A can upload, running sketch on it and open Serial Monitor.
  2. OpenHab manually installed in folder /home/odroid/Programs/openHAB.
  3. Addon org.openhab.binding.serial-1.8.3.jar is in addons folder.
  4. -Dgnu.io.rxtx.SerialPorts=/dev/ttyACM0 is added to /etc/init.d/openhab script.
  5. Script starts with root user and root and odroid is a members of dialout group.
  6. String Arduino "Eval arduino" { serial="/dev/ttyACM0" }. openhab.cfg is from previous installation on Cubieboard 2 board (with OpenHab 1.8.1), were same serial connection with the same Arduino board worked fine. Port ttyACM0 is not used by other process.
  7. Have tried with OpenJDK 8 and JRE 8.
  8. Have tried with OpenHab 1.8.1 and 1.8.3.
  9. Have tried with Arduino boards on CP1202 (/dev/ttyACM0) and CH341 (/dev/ttyUSB0) serial converters.
  10. OpenHab give the same error:
    [ERROR] [i.internal.GenericItemProvider] - 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/ttyACM0: Serial port ‘/dev/ttyACM0’ could not be found…

Can’t imagine what I have else to do. Please help! Thanks!

On Ubuntu the apt-get installation method is the preferred method.

Oracle Java is the preferred runtime. OpenJDK has known problems that causes errors in OH.

This implies that there is an error in the Item definition. “could not be parsed correctly” points at the Item file. I’ve not looked at the binding source so it is possible that this type of error gets thrown at other times but given this is the first error printed I would verify that there isn’t some hidden error in your .items file. Open it in Designer. Rewrite it. Comment out everything but the line you care about. For example, I’ve seen errant ‘\r’ characters cause havoc with Items files like this.

This could point at permission problem or a path problem. But given the first error it may have some other cause. It is hard to say.

Hi Rich! Thanks for reply.
OpenHab works fine for me as in OpenJDK as Oracle JRE except serial connection to Arduino board.
The item file is same from my previous OpenHab’s manual installation on Cubieboard 2 with Ubuntu-like Linux OS. I’ve rewrited my Arduino-item one more time
String Arduino "Eval arduino" { serial="/dev/ttyACM0" }
Error message is stay on.
I can see serial port wth
odroid@odroid64:~$ ls -l /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 Jul 12 21:50 /dev/ttyACM0

I will install OpenHab with apt-get and see what will happen.
Thanks in advice!

With the apt-get install, remember to add the openhab user to the dialout group so it has rw permission on /dev/ttyAMC0.

I’ve installed the OpenHab with apt-get - all exactly the same!
All works fine except
[ERROR] [i.internal.GenericItemProvider] - Binding configuration of type 'serial' of item \u2018Arduino\u2018 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.

This thing makes me crazy…
I’m better rolling back to manual installation. I like when all important files are in one place/folder.

Have you bumped up the logging for the serial binding to debug it trace? There might be more information there.

Here is it.
[ERROR] [i.internal.GenericItemProvider] - Binding configuration of type 'serial' of item \u2018Arduino\u2018 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:

    at org.openhab.binding.serial.internal.SerialBinding.processBindingConfiguration(SerialBinding.java:168) ~[na:na]
    at org.openhab.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:348) [org.openhab.model.item_1.8.3.jar:na]
    at org.openhab.model.item.internal.GenericItemProvider.dispatchBindingsPerType(GenericItemProvider.java:309) [org.openhab.model.item_1.8.3.jar:na]
    at org.openhab.model.item.internal.GenericItemProvider.addBindingConfigReader(GenericItemProvider.java:106) [org.openhab.model.item_1.8.3.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_91]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_91]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_91]
    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]

What are the log statements immediately before the error?

Before this error only
[INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'schedulers.rules'
wich schedules ON/OFF statement of some switches and have nothing with Arduino item.

I need all the lines that are related to GenericItemProvider and the Serial Binding. If you put the Serial Binding into TRACE or DEBUG logging mode there should be a ton of logging statements from the binding.

Ok. Here is DEBUG logs before error mesages.

2016-07-15 08:51:34.085 [DEBUG] [o.b.s.internal.SerialActivator] - Serial binding has been started.
2016-07-15 08:53:38.253 [DEBUG] [i.internal.GenericItemProvider] - Start processing binding configuration of Item 'Arduino (Type=StringItem, State=Uninitialized)' with 'SerialBinding' reader.
2016-07-15 08:53:38.430 [ERROR] [i.internal.GenericItemProvider] - Binding configuration of type 'serial' of item \u2018Arduino\u2018 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:
....

I’m really appreciate your help, Rich. Thanks!

Hello!
Have you got it to work?
I’m on the same issue!
Thanks!
Simon

Somehow I missed this. I’m afraid I don’t have any further advice. Just to make sure that /dev/ttyAMC0 exists, that the openhab user has read/write permission on it, and something else doesn’t have a lock on it.

The hardware I using ODROID C2 is a brand new with arm64 architecture. I think, this issue is somewhat about how a drivers is assigned for Arduino’s usb-serial converter and how Openhab using it.
I’ve tried write a rule in /etc/udev/rules.d/99-usb-serial.rules for permission 666 to ttyACM0: KERNEL=="ttyACM*", MODE:="0666"
After that it was no error message at Openhab start about ttyACM0 but however it cann’t connect to Arduino. Neither command sending and receiving.
At the same time the Arduino IDE can connect and transmitting messages to Arduino with no problem every time. Even when Openhab is running. Its mean that Openhab not really connected to serial ttyACM0 and not maked him busy for other processes.
I’ll try to use Openhab2 and see how it will working.

Finally I got it working!
As I mentioned, and its reported in topic 64 bit ARM serial, the issue is in serial driver library in Java JDK for arm64 architecture.
I’ve installed Java arm32 (as mentioned in topic above) and run Openhab on it and vualah! All is fine now!