Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Can't run CUL Transport Binding with Baudrate of 38400 #3910

Closed
Gugiman opened this issue Jan 28, 2016 · 33 comments
Closed

Can't run CUL Transport Binding with Baudrate of 38400 #3910

Gugiman opened this issue Jan 28, 2016 · 33 comments

Comments

@Gugiman
Copy link

Gugiman commented Jan 28, 2016

Hi Guys,

I'm having some trouble configuring my nanoCUL to send Intertechno Codes.
As I read in other forums, changing the hardcoded baudrate and parity fixes the problem.

But after change the baudrate to 38400 in /bundles/io/org.openhab.io.transport.cul/src/main/java/org/openhab/io/transport/cul/internal/CULSerialHandlerImpl.java like this:

//private Integer baudRate = 9600; private Integer baudRate = 38400; //private Integer parityMode = SerialPort.PARITY_EVEN; private Integer parityMode = SerialPort.PARITY_NONE;

My openhab.log sais:

2016-01-28 19:13:12.519 [ERROR] [.o.b.i.i.CULIntertechnoBinding] - Can't open CUL org.openhab.io.transport.cul.CULDeviceException: gnu.io.UnsupportedCommOperationException: Invalid Parameter at org.openhab.io.transport.cul.internal.CULSerialHandlerImpl.openHardware(CULSerialHandlerImpl.java:269) ~[na:na] at org.openhab.io.transport.cul.internal.AbstractCULHandler.open(AbstractCULHandler.java:152) ~[na:na] at org.openhab.io.transport.cul.CULManager.createNewHandler(CULManager.java:171) ~[bundlefile:na] at org.openhab.io.transport.cul.CULManager.getOpenCULHandler(CULManager.java:88) ~[bundlefile:na] at org.openhab.io.transport.cul.CULManager.getOpenCULHandler(CULManager.java:52) ~[bundlefile:na] at org.openhab.binding.intertechno.internal.CULIntertechnoBinding.bindCULHandler(CULIntertechnoBinding.java:99) [bundlefile:na] at org.openhab.binding.intertechno.internal.CULIntertechnoBinding.setNewDeviceName(CULIntertechnoBinding.java:92) [bundlefile:na] at org.openhab.binding.intertechno.internal.CULIntertechnoBinding.updated(CULIntertechnoBinding.java:201) [bundlefile:na] at org.eclipse.equinox.internal.cm.ManagedServiceTracker$1.run(ManagedServiceTracker.java:183) [org.eclipse.equinox.cm_1.0.400.v20120522-1841.jar:na] at org.eclipse.equinox.internal.cm.SerializedTaskQueue$1.run(SerializedTaskQueue.java:36) [org.eclipse.equinox.cm_1.0.400.v20120522-1841.jar:na] Caused by: gnu.io.UnsupportedCommOperationException: Invalid Parameter at gnu.io.RXTXPort.setSerialPortParams(RXTXPort.java:212) ~[na:na] at org.openhab.io.transport.cul.internal.CULSerialHandlerImpl.openHardware(CULSerialHandlerImpl.java:252) ~[na:na] ... 9 common frames omitte

@tarioch
Copy link
Contributor

tarioch commented Feb 6, 2016

I'm in the same boat as you (nanoCul). I refactored the code in that area and have it fixed that it's possible to configure the baud rate for any cul binding.

See #3885

@Gugiman
Copy link
Author

Gugiman commented Feb 8, 2016

Glad to hear that! I'm looking forward for the 1.9 milestone.
Is any timeline given for this?

@tarioch
Copy link
Contributor

tarioch commented Feb 8, 2016

If I understood it right this will be the switch to openhab2 as a base. If you want I can provide the two jars, they work with 1.8.1

@teichsta
Copy link
Member

teichsta commented Feb 8, 2016

Once the mentioned PR is merged you'll find the binaries also in the nightly snapshot build

@tarioch
Copy link
Contributor

tarioch commented Feb 8, 2016

Yes but as the pr has not yet merged I would need to upload my jars with the merged fix

@tarioch
Copy link
Contributor

tarioch commented Feb 8, 2016

Ignore my last comment

@teichsta
Copy link
Member

teichsta commented Feb 8, 2016

:-) @Gugiman it would be great if you could beta test @tarioch changes and comment if it works for you …

@tarioch
Copy link
Contributor

tarioch commented Feb 8, 2016

I made a release here: https://github.com/tarioch/openhab/releases/tag/untagged-bac31677f9265162782d

Configure it like this:

culintertechno:baudrate=38400
culintertechno:parity=NONE
culintertechno:device=serial:/dev/ttyUSB0

@Gugiman
Copy link
Author

Gugiman commented Feb 8, 2016

@tarioch Link calls a 404 ;)

Nevertheless I will definitely give it a try sometime within this week after fixing.

@Gugiman
Copy link
Author

Gugiman commented Feb 11, 2016

@tarioch As I mentioned before the Link answers with a 404

Just need a source for testing otherwise I'm not very sure in which repo your changes are already made (not THAT expert in Github logics ^^ )

@tarioch
Copy link
Contributor

tarioch commented Feb 11, 2016

Hm, link works fine for me. Otherwise go to
https://github.com/tarioch/openhab/releases and should be the top release
called Test Jars

@tarioch
Copy link
Contributor

tarioch commented Feb 11, 2016

@tarioch
Copy link
Contributor

tarioch commented Feb 15, 2016

@Gugiman did the link work and did you have time to test?

@Gugiman
Copy link
Author

Gugiman commented Feb 16, 2016

I've tried but got another error.

The configuration in openhab.cfg is like you mentioned.

culintertechno:baudrate=38400
culintertechno:parity=NONE
culintertechno:device=serial:/dev/ttyUSB0

These are my /dev permissions after manually chmod and chown:
ls -alh /dev/ttyUSB0
crwxrwxrwt 1 openhab openhab 188, 0 Feb 16 18:15 /dev/ttyUSB0

When I run
sudo screen /dev/ttyUSB0 38400

I can switch my device from ON and OFF by typing:

is00000FFF0FFF

But after starting openhab this error appears:

2016-02-16 18:17:44.740 [ERROR] [.o.b.i.i.CULIntertechnoBinding] - Can't open CUL
org.openhab.io.transport.cul.CULDeviceException: gnu.io.NoSuchPortException
at org.openhab.io.transport.cul.internal.CULSerialHandlerImpl.openHardware(CULSerialHandlerImpl.java:257) ~[na:na]
at org.openhab.io.transport.cul.internal.AbstractCULHandler.open(AbstractCULHandler.java:152) ~[na:na]
at org.openhab.io.transport.cul.CULManager.createNewHandler(CULManager.java:171) ~[bundlefile:na]
at org.openhab.io.transport.cul.CULManager.getOpenCULHandler(CULManager.java:88) ~[bundlefile:na]
at org.openhab.io.transport.cul.CULManager.getOpenCULHandler(CULManager.java:52) ~[bundlefile:na]
at org.openhab.binding.intertechno.internal.CULIntertechnoBinding.bindCULHandler(CULIntertechnoBinding.java:99) [bundlefile:na]
at org.openhab.binding.intertechno.internal.CULIntertechnoBinding.setNewDeviceName(CULIntertechnoBinding.java:92) [bundlefile:na]
at org.openhab.binding.intertechno.internal.CULIntertechnoBinding.updated(CULIntertechnoBinding.java:201) [bundlefile:na]
at org.eclipse.equinox.internal.cm.ManagedServiceTracker$1.run(ManagedServiceTracker.java:183) [org.eclipse.equinox.cm_1.0.400.v20120522-1841.jar:na]
at org.eclipse.equinox.internal.cm.SerializedTaskQueue$1.run(SerializedTaskQueue.java:36) [org.eclipse.equinox.cm_1.0.400.v20120522-1841.jar:na]
Caused by: gnu.io.NoSuchPortException: null
at gnu.io.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:273) ~[na:na]
at org.openhab.io.transport.cul.internal.CULSerialHandlerImpl.openHardware(CULSerialHandlerImpl.java:236) ~[na:na]
... 9 common frames omitted

Is it my fault or what might be the Problem?

@tarioch
Copy link
Contributor

tarioch commented Feb 16, 2016

Hm, that's strange. Can you make sure there is no additional character after serial:/dev/ttyUSB0
I think right now there's no trimming of empty (space) characters. Also would you mind setting the log level for this to debug by adding
<logger name="org.openhab.binding.intertechno" level="DEBUG"/> <logger name="org.openhab.io.transport.cul" level="DEBUG"/>
to your logback.xml

@Gugiman
Copy link
Author

Gugiman commented Feb 16, 2016

There are no additional characters...

But the after inserting the additional loggers I got the following:

2016-02-16 19:58:07.134 [DEBUG] [.b.i.i.CULIntertechnoActivator] - CULIntertechno binding has been started.
2016-02-16 19:58:07.347 [DEBUG] [.io.transport.cul.CULActivator] - CUL transport has been started.
2016-02-16 19:58:07.520 [DEBUG] [.o.io.transport.cul.CULManager] - Registering class org.openhab.io.transport.cul.internal.CULSerialHandlerImpl for device type serial
2016-02-16 19:58:07.527 [DEBUG] [.o.io.transport.cul.CULManager] - Registering class org.openhab.io.transport.cul.internal.CULNetworkHandlerImpl for device type network
2016-02-16 19:58:07.610 [DEBUG] [.o.io.transport.cul.CULManager] - Trying to open device serial:/dev/ttyUSB0 in mode SLOW_RF
2016-02-16 19:58:07.614 [DEBUG] [.o.io.transport.cul.CULManager] - Searching class for device type serial
2016-02-16 19:58:07.699 [DEBUG] [o.i.t.c.i.CULSerialHandlerImpl] - Opening serial CUL connection for /dev/ttyUSB0
2016-02-16 19:58:08.000 [ERROR] [.o.b.i.i.CULIntertechnoBinding] - Can't open CUL
org.openhab.io.transport.cul.CULDeviceException: gnu.io.NoSuchPortException
at org.openhab.io.transport.cul.internal.CULSerialHandlerImpl.openHardware(CULSerialHandlerImpl.java:257) ~[na:na]
at org.openhab.io.transport.cul.internal.AbstractCULHandler.open(AbstractCULHandler.java:152) ~[na:na]
at org.openhab.io.transport.cul.CULManager.createNewHandler(CULManager.java:171) ~[bundlefile:na]
at org.openhab.io.transport.cul.CULManager.getOpenCULHandler(CULManager.java:88) ~[bundlefile:na]
at org.openhab.io.transport.cul.CULManager.getOpenCULHandler(CULManager.java:52) ~[bundlefile:na]
at org.openhab.binding.intertechno.internal.CULIntertechnoBinding.bindCULHandler(CULIntertechnoBinding.java:99) [bundlefile:na]
at org.openhab.binding.intertechno.internal.CULIntertechnoBinding.setNewDeviceName(CULIntertechnoBinding.java:92) [bundlefile:na]
at org.openhab.binding.intertechno.internal.CULIntertechnoBinding.updated(CULIntertechnoBinding.java:201) [bundlefile:na]
at org.eclipse.equinox.internal.cm.ManagedServiceTracker$1.run(ManagedServiceTracker.java:183) [org.eclipse.equinox.cm_1.0.400.v20120522-1841.jar:na]
at org.eclipse.equinox.internal.cm.SerializedTaskQueue$1.run(SerializedTaskQueue.java:36) [org.eclipse.equinox.cm_1.0.400.v20120522-1841.jar:na]
Caused by: gnu.io.NoSuchPortException: null
at gnu.io.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:273) ~[na:na]
at org.openhab.io.transport.cul.internal.CULSerialHandlerImpl.openHardware(CULSerialHandlerImpl.java:236) ~[na:na]
... 9 common frames omitted
2016-02-16 19:58:08.016 [INFO ] [.service.AbstractActiveService] - CULIntertechno Refresh Service has been started
2016-02-16 19:58:08.019 [DEBUG] [.o.b.i.i.CULIntertechnoBinding] - execute() method is called!
2016-02-16 19:59:08.023 [DEBUG] [.o.b.i.i.CULIntertechnoBinding] - execute() method is called!
2016-02-16 20:00:08.026 [DEBUG] [.o.b.i.i.CULIntertechnoBinding] - execute() method is called!
2016-02-16 20:01:08.030 [DEBUG] [.o.b.i.i.CULIntertechnoBinding] - execute() method is called!

@tarioch
Copy link
Contributor

tarioch commented Feb 16, 2016

Can you try to add
-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0 to the startup of openhab

@Gugiman
Copy link
Author

Gugiman commented Feb 16, 2016

Forgot to mention.

In /etc/init.d/openhab
I already added
-Djava.library.path=/usr/lib/jni
-Dgnu.io.rxtx.SerialPorts=/dev/USB0 \

Sure it's the bindings fault? Maybe it's in my (arduino-compatible) Board...

I'm using the a-culfw firmware (https://github.com/heliflieger/a-culfw)

Maybe the Problem is somewhere else...?

@tarioch
Copy link
Contributor

tarioch commented Feb 16, 2016

I'm using the same firmware with my homebuilt nanocul and it works fine. I don't specify any arguments for openhab, maybe you ca try removing it as well.

@tarioch
Copy link
Contributor

tarioch commented Feb 16, 2016

Try leaving away both the library path and the serial port define.

@Gugiman
Copy link
Author

Gugiman commented Feb 18, 2016

Unfortunately nothing changed... Got the "Invalid Parameter" Error again.

Am I thinking the right when screen is able to send the right code it must be openhabs fault?

@tarioch
Copy link
Contributor

tarioch commented Feb 18, 2016

Yes, looks that way. Now let's try to narrow this down (as it works fine for me).

Which version of java are you using? Is it openjdk or sun/oracle? What's the platform you're trying to run this? Normal pc or raspberry or something like that?

My (working) setup is currently like this:
-Ubuntu on an amd64 architecture
-Sun/Oracle Java 1.8
-Openhab 1.8.1 installed from repository (except cul and intertechno bindings)
-openhab user added to dialout group
-Nothing special configured for port or in startup script

@Gugiman
Copy link
Author

Gugiman commented Feb 19, 2016

Alright here are my specs (as much as I think to be relevant):

java -showversion

shows:

java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode)

I'm using openhab 1.8.1 from Repository on a Raspberry rev1 B with Raspbian Wheezy and Kernel 4.1.13+ #826

Installed bindings are intertechno and CUL (from your Test Release) and serial binding from repo.
The openhab.cfg is untouched except of this at the end:

culintertechno:baudrate=38400
culintertechno:parity=NONE
culintertechno:device=serial:/dev/ttyUSB0

The /etc/init.d/openhab script is now free of any selfmade changes.
The item is defined as:

Switch stecker1cul "Lampe CUL" {culintertechno="type=raw;address=00000FFFF0;commandOn=FF;commandOff=F0"}

openhab user is member of the dialout group

groups openhab

shows

openhab : openhab dialout

As I can see, openhab is able to create a LOCK file for ttyUSB0 /var/lock/LCK..ttyUSB0

In raspi-config I enabled SPI, I2C and Serial (as I heard it might be necessary)

I got the Arduino-Compatible Board from here and build it like this tutorial here with the a-culfw firmware (nanoCUL) from here

@Gugiman
Copy link
Author

Gugiman commented Feb 19, 2016

UPDATE:

I installed openhab on my Linux Mint Desktop Laptop (don't know why I didn't come up with this idea earlier) and everything works like a charm!
No errors or anything else. Just installed Runtime and Bindings.

So there is an error on Openhab on Raspberry (Core or bindings idk)

@tarioch
Copy link
Contributor

tarioch commented Feb 19, 2016

Can you check if on your raspy librxtx-java is NOT installed? I think that could make problems.

@Gugiman
Copy link
Author

Gugiman commented Feb 19, 2016

It's definitly installed. APT sais so.

Interesting: On my Desktop librxtx-java is NOT installed and it works...

@tarioch
Copy link
Contributor

tarioch commented Feb 19, 2016

Yes, that's what I am hoping. Please uninstall it and try again.

@Gugiman
Copy link
Author

Gugiman commented Feb 19, 2016

Unfortunately no change on raspberry...

@Gugiman
Copy link
Author

Gugiman commented Feb 20, 2016

Next step is to reinstall raspbian os and try exactly the same as on my laptop.

@Gugiman
Copy link
Author

Gugiman commented Feb 20, 2016

Ok so I installed fresh Raspbian Jessie on Rpi

Installed Java
sudo apt-get install oracle-java8-jdk

Add openhab to dialout group and installed your two bindings with the openhab.cfg changes.

Still got the "Invalid Parameter" error

@tarioch
Copy link
Contributor

tarioch commented Feb 20, 2016

I think you're not alone and it's not related to my changes: https://community.openhab.org/t/replace-nrjavaserial-with-rxtxcomm/5867/4

@tarioch
Copy link
Contributor

tarioch commented Feb 20, 2016

So I think that issue you're having on your raspberry is the same as #3257 and actual the root issue being NeuronRobotics/nrjavaserial#60

@Gugiman
Copy link
Author

Gugiman commented Feb 20, 2016

Ok than i will look futher in this direction.

@teichsta Since the bindings works perfectly on my Linux Mint desktop and the error seems to be not related to the changes by @tarioch I approve the changes :)

Thank you all guys and keep up the great work :)

@Gugiman Gugiman closed this as completed Feb 23, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants