Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tackle serialPorts setting in menu entry (Razberry, ...) #33

Closed
palatia opened this issue Nov 5, 2016 · 29 comments
Closed

Tackle serialPorts setting in menu entry (Razberry, ...) #33

palatia opened this issue Nov 5, 2016 · 29 comments
Labels
help wanted Extra attention is needed

Comments

@palatia
Copy link

palatia commented Nov 5, 2016

The additions based on #18 are great but not fully working for me using Razberry.
i still needed to add manually to /usr/share/openhab2/runtime/karaf/bin/setenv
the port definition, e.q. -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0
so that openhab2 recognizes the port.

i have seen many people struggle with that in the community so why not just enhance openhabian to provide that setting right away or via a setting to configure it.

@ThomDietrich
Copy link
Member

ThomDietrich commented Nov 6, 2016

Hey palatia,
I've been waiting for you! ;) Yes I wanted to add this as a automatic step with openHABian. However in order to do that I need somebody with the right hardware and the needed overview to tell me a few more details. The discussions in the openHABian thread are rather vague regarding the topic.

I would like to tackle as many devices as possible, without being too aggressive or having to deal with unwanted side effects. Could you help to figure out these details:

  1. Is it really needed to disable Bluetooth on the RPi3 in order to use the Razberry? There are a lot of half baked discussion out there regarding that topic. Somebody would have to look into this. Do you own a RPi3?
  2. Your solution only addresses the port ttyAMA0. Could you please try the following to cover more ground: -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyS0:/dev/ttyAMA0:/dev/ttyAMC0
  3. Is /usr/share/openhab2/runtime/karaf/bin/setenv the right file for these modifications? I would expect an upgrade to overwrite this file, at least at some points where there is a change to it. Please test the option inside /etc/default/openhab2 as described here. This path is the systematically better choice as /etc is reserved for user specific changes...
  4. Is there an easy way to check if a Razberry is indeed active on /dev/ttyAMA0? Probably a command can be send over the serial connection to retrieve the board version?
  5. Which other Hardware is relying on these settings and should be considered and mentioned in the menu text?

After 2 and 3 are settled, I'd be okay to implement the needed additions.

@ThomDietrich ThomDietrich changed the title port still not available, so manual entries in setenv (Karaf) are still required Add serialPorts setting to menu entry (Razberry, ...) Nov 8, 2016
@ThomDietrich ThomDietrich changed the title Add serialPorts setting to menu entry (Razberry, ...) Tackle serialPorts setting in menu entry (Razberry, ...) Nov 8, 2016
@ThomDietrich
Copy link
Member

busware SCC: the device is already working without further changes. That's not remarkable as the openHAB homematic binding does not directly need to access the module but is connecting to the homegear service (recommended toolchain)

@ThomDietrich
Copy link
Member

@bodiroga wrote:

Hi Thomas!

As far as I know (I'm not an expert by all means), openHAB can read the /dev/ttyUSB0 or /dev/ttyACM0 ports being part of the dialout group because in Linux, serial ports mounted in /dev folder are owned by root under the dialout group. Here you have a link that talks about it:

http://askubuntu.com/questions/774541/what-is-dialout-group-in-ubuntu/774545

The problem with the "-Dgnu.io.rxtx.SerialPorts" parameter is that Java is not able to "see" serial ports with non-standard port names (/dev/ttyAMA0 or custom names such as /dev/zwave and /dev/rfxcomm) and in order to solve that you need specify the ports that you need to use manually in the -Dgnu parameter. (More information: http://angryelectron.com/rxtx-on-raspbian/). And I don't know what can be done to solve it... 😢

Perhaps, the best solution is to add an udev rule (there is an entry for that in the openHAB wiki: https://github.com/openhab/openhab/wiki/symlinks), create a list of most used devices (in the link you have the idVendor and idProduct of two ZWAVE usb dongles and the RFXcom transceiver, we could add the information about the Razberry), define a name for each device (/dev/zwave or /dev/USBzwave for all the ZWave devices, as it is very unlikely that someone will plug two ZWave controllers in the same device) and add those personal names to the -Dgnu.rxtx.SerialPorts parameter, instead of adding all possible ports combination (/dev/ttyS1, /dev/ttyS2, /dev/ttyAMA0, /dev/ttyAMA1,...).

How does it sound?

At least, at the binding configuration time, /dev/USBzwave is a much more meaningful name than /dev/ttyAMA0...

Thanks for your work as always and best regards,

Aitor

@ThomDietrich
Copy link
Member

ThomDietrich commented Nov 8, 2016

Regarding 1:

I looked into the z-wave.me install script and found more details regarding the problem that both Razberry and Bluetooth use the same UART pins 14 and 15. That's the reason why Bluetooth indeed needs to be disabled!

I'm not sure about the differences between these two solution but I would recommend the one used in the official installation script:

# Disable bluetooth Raspberry Pi 3
RPI_BOARD_REVISION=`grep Revision /proc/cpuinfo | cut -d: -f2 | tr -d " "`
if [[ $RPI_BOARD_REVISION ==  "a02082" || $RPI_BOARD_REVISION == "a22082" ]]
then
    echo "Raspberry Pi 3 Detected. Disabling Bluetooth"
    systemctl disable hciuart
    # Add "dtoverlay=pi3-miniuart-bt" to /boot/config.txt if needed
    if [[ ! `grep "dtoverlay=pi3-miniuart-bt" /boot/config.txt` ]]
    then
        echo "Adding 'dtoverlay=pi3-miniuart-bt' to /boot/config.txt"
        echo "dtoverlay=pi3-miniuart-bt" >> /boot/config.txt
    fi

    echo "!!! Update Raspberry Pi 3 Firmware for stability work with commands:"
    echo "sudo apt-get install rpi-update"
    echo "sudo rpi-update"
fi

Btw.: The "hciuart" service is disabled during the mentioned installation script.

Btw. 2: A "UZB" was mentioned and successfully tested without disabling Bluetooth (the above instructions). I'm too lazy too google what UZB is, I'll leave this here just for reference.

@ThomDietrich
Copy link
Member

@palatia any news?

@palatia
Copy link
Author

palatia commented Nov 13, 2016

@ThomDietrich , I thank you for all your effort and I am really sorry for my late reply. i am traveling and don't have access to my raspi.

regarding 1.) and RPi3
[palatia] "Sorry, i can't help with that test, i have only an older RPi."

regarding 2.) Your solution only addresses the port ttyAMA0. Could you please try the following to cover more ground: -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyS0:/dev/ttyAMA0:/dev/ttyAMC0
[palatia] "should work. i am using Mysensors serial gateway with a defined port ttyUSB0 like you wrote in setenv. "

regarding 3.)
Is /usr/share/openhab2/runtime/karaf/bin/setenv the right file for these modifications? I would expect an upgrade to overwrite this file, at least at some points where there is a change to it. Please test the option inside /etc/default/openhab2 as described here. This path is the syi stematically better choice as /etc is reserved for user specific changes...
[palatia] "i will run a quick test next weekend. "

regarding 4.)
Is there an easy way to check if a Razberry is indeed active on /dev/ttyAMA0? Probably a command can be send over the serial connection to retrieve the board version?
[palatia] "sorry, i have not idea, how that could be done."

@palatia
Copy link
Author

palatia commented Nov 16, 2016

HI Thomas,

Regarding 3.) My current configuration using /usr/share/openhab2/runtime/karaf/bin/setenv for adding the port.
Those are my log entries:

2016-11-16 21:20:12.259 [INFO ] [ing.zwave.handler.ZWaveSerialHandler] - Connecting to serial port '/dev/ttyAMA0'
2016-11-16 21:20:12.743 [INFO ] [ing.zwave.handler.ZWaveSerialHandler] - Serial port is initialized
2016-11-16 21:20:13.814 [INFO ] [mmandclass.ZWaveSecurityCommandClass] - Update networkKey
2016-11-16 21:20:14.843 [INFO ] [ve.internal.protocol.ZWaveController] - Starting ZWave controller
2016-11-16 21:20:14.876 [INFO ] [ve.internal.protocol.ZWaveController] - ZWave timeout is set to 5000ms. Soft reset is false.

Without setenv configuration only adding the port configuration to /etc/default/openhab2

"EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0"

From https://community.openhab.org/t/openhabian-hassle-free-rpi-image/13379/246

Those are my log entries:

2016-11-16 21:47:29.551 [INFO ] [ing.zwave.handler.ZWaveSerialHandler] - Connecting to serial port '/dev/ttyAMA0'
2016-11-16 21:50:35.166 [WARN ] [ding.zwave.handler.ZWaveThingHandler] - Controller handler not found. Cannot handle command without ZWave controller.
2016-11-16 21:50:37.590 [WARN ] [ding.zwave.handler.ZWaveThingHandler] - Controller handler not found. Cannot handle command without ZWave controller.
2016-11-16 21:50:55.749 [WARN ] [ding.zwave.handler.ZWaveThingHandler] - Controller handler not found. Cannot handle command without ZWave controller.

--> Razberry does not work.

please let me know, if i can help with further tests.
i am sorry that i am not really able to provide feedback and any further hints for resolution.

thank you and best regards,
palatia

@palatia palatia closed this as completed Nov 16, 2016
@palatia palatia reopened this Nov 23, 2016
@ThomDietrich
Copy link
Member

Changes to openHABian will come soon.

In the meantime, I've documented needed actions here: http://docs.openhab.org/installation/linux.html#privileges-for-common-peripherals

@ThomDietrich
Copy link
Member

ThomDietrich commented Dec 2, 2016

@palatia both files should work, /etc/default/openhab2 would be the preferred one. Could you try again!?
Besides that, everything seems clear now, this will soon be implemented.

@palatia
Copy link
Author

palatia commented Dec 4, 2016

@ThomDietrich , thanks for all you effort to create an easy all in one installer. it works like a charm and eases the overall installation of openhab2.

regarding the razberrry port. i have done again a test with just using /etc/default/openhab2 for the port definition. It does not work with my Razberry board and my Model B Rev 2 raspi.
I have still the same results. that the zwave controller is not available.
Sure, outside karaf is preferred but i really don't know how to get that done.

2016-12-04 09:06:54.247 [INFO ] [ing.zwave.handler.ZWaveSerialHandler] - Connecting to serial port '/dev/ttyAMA0'
2016-12-04 09:16:18.955 [WARN ] [ding.zwave.handler.ZWaveThingHandler] - Controller handler not found. Cannot handle command without ZWave controller.

image

@ThomDietrich
Copy link
Member

could you please show us the content of your /usr/share/openhab2/runtime/bin/setenv? The important line should like like this:

grafik

The last line is the important one. The information set in /etc/default/openhab2 is used.

@palatia
Copy link
Author

palatia commented Dec 4, 2016

sure,... here it is
image

@ThomDietrich
Copy link
Member

@BClark09 with your recent endeavors into init.d/systemd, maybe you can help. Do you know where /etc/default/openhab2 is actually sourced?

@BClark09
Copy link
Member

BClark09 commented Dec 5, 2016

Yes, before openHAB is launched, init.d runs the file as an expanded script and systemd runs the file as an environment path file. openHABian will use systemd.

This seems to suggest that you should remove the quotes so that your file /etc/default/openhab2 reads:

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

@ThomDietrich
Copy link
Member

Ah of course, there it is.

Thanks! @palatia would you try again?

@ThomDietrich
Copy link
Member

Configuration with quotes as suggested before is working: https://community.openhab.org/t/openhabian-hassle-free-rpi-image/13379/337

2016-12-06 11_44_47-openhabian hassle-free rpi image - hardware _ server - openhab community - pale

@tomekmbb
Copy link

tomekmbb commented Dec 8, 2016

@ThomDietrich I have RPi3 with Razberry if you want I can help with testing

@ThomDietrich
Copy link
Member

ThomDietrich commented Dec 13, 2016

Hey @palatia, Hey @tomekmbb,
I've just commited the needed changes as discussed. Please help testing.

What to expect:
I have enhanced the method behind sudo openhabian-config entry "Serial Port". It now does the following things:

  • Remove the serial console and login shell from /boot/cmdline.txt and /etc/inittab
  • Enable the serial port by adding "enable_uart=1" to /boot/config.txt
  • Disable Bluetooth on the RPi3 by adding 'dtoverlay=pi3-miniuart-bt' to /boot/config.txt
  • Add to file /etc/default/openhab2:
EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyS0:/dev/ttyAMA0"

I decided to work with quotes in etc/default/openhab2 and everything seems fine. Check the middle of the screenshot:
grafik

What you have to do:

  1. Execute sudo openhabian-config
  2. Select "Update", give him a sec to fetch all the latest commits
  3. Select "Basic Setup", not strictly needed but I've done a lot of improvements to the basic system files that might be useful
  4. Select "Serial Port"
  5. After it's finished exit openhabian-config, the output should look as follows
  6. Execute sudo rpi-update and sudo reboot as instructed
  7. Test your openHAB Razberry connection. Good luck!

grafik

@ThomDietrich
Copy link
Member

I've already found one problem. I own a Busware SCC myself, which is controlled not by openHAB directly but by an additional software on the same RPi. Executing the new steps broke this connection. Investigation needed. It's probably better to create a submenu to select which of the mentioned four steps you actually want to execute (which depends on your peripheral device).

This doesn't change the situation for the Razberry. You may still test the new functionality.

@palatia
Copy link
Author

palatia commented Dec 13, 2016

Hi Thomas,

Great stuff and good news. All works like charm. I am able to use the Razberry without messing around in setenv. Not sure, why my earlier test was not successful but now i am able to confirm that port confirmation in openhab2 is sufficient.

I followed your described steps. All work as you described it. i was updating from
OpenHABianPi 5.15.160729 to 5.21.161121

no entry in setenv
image

i have this in /etc/default/openhab2
image

The z-wave binding is able to use the port.
..
2016-12-13 20:04:00.123 [INFO ] [ing.zwave.handler.ZWaveSerialHandler] - Connecting to serial port '/dev/ttyAMA0'
2016-12-13 20:04:00.394 [INFO ] [ing.zwave.handler.ZWaveSerialHandler] - Serial port is initialized
2016-12-13 20:04:01.283 [INFO ] [mmandclass.ZWaveSecurityCommandClass] - Update networkKey
2016-12-13 20:04:03.048 [INFO ] [ve.internal.protocol.ZWaveController] - Starting ZWave controller
..

Thank a lot for getting this done. I am a big fan of OpenHABianPi and confident that many people will benefit from your contribution.

Regards,
Peter

@ThomDietrich
Copy link
Member

I have invested a few more minutes on this feature.

grafik

There is now a menu so you only select what you actually want. I realized that this is important as otherwise for example a SCC will not work anymore.
I've also added the other way around, deselecting an entry will undo the changes!

52cc420

@haroldh
Copy link

haroldh commented Mar 21, 2017

Today I found this thread, discussing exactly my situation.
Having a RBP3 and the Razberry add-on board, my setup qualifies for this thread.
However, I have also 2 additional serial connections to a P1 port (smart meter) and an RFXCOM. The USB-connections /dev/ttyUSB0 and ..1 are both connecting to OH2 after going through several internet searches in order to setup the RBP3. From your documentation I learned that I should have added the serial ports that I created using UDEV (/dev/ttyrfxcom and /dev/ttyp1) into the /etc/default/openhab2 file.
And finally I also connect my RBP3 to the Puck.js devices through Bluetooth Low Energy (BLE).
Before I started attaching the Razberry, I had the RFXCOM, P1 working in OpenHab. And I was able to connect to the Puck.js through NodeRed.

With the serial port configuration that the Openhabian-config provides, I lose the connection with my USB1 and Bluetooth attached devices.

I would appreciate a config that supports all available serial ports. Is that at all possible?

@ThomDietrich
Copy link
Member

ThomDietrich commented Mar 21, 2017

Hey,
admittedly the setup we provide is a bit harsh and does all that's needed to get any of many devices on the serial port working. It's not ideal for multiple devices. If you want these three to cooperate you'll probably do the following:

Good luck!

If you find out that you can in fact not use the Razberry and Bluetooth devices at the same time, one nice option would be to use the Razberry Pi Zero W as a slave only handling the Bluetooth devices. You can use openHABian to get it up and running quickly: https://community.openhab.org/t/openhabian-hassle-free-openhab-setup/13379/837

@jeess
Copy link

jeess commented Nov 25, 2017

How can I Remove manually the serial console and login shell from /boot/cmdline.txt and /etc/inittab?

@jeess
Copy link

jeess commented Nov 26, 2017

Finally I got it. In rpi3 model b the file /etc/inittab is not found. Instead, I wrote in the terminal:
sudo systemctl stop serial-getty@ttyAMA0.service
sudo systemctl disable serial-getty@ttyAMA0.service

Now the gen5 aeon labs usb is in the port / dev / ttyACM0 instead of / dev / ttyAMA0.
Change the serial port in the zwave serial controller and everything is correct.

@ThomDietrich
Copy link
Member

That is correct. The openhabian-config function tries to solve the issue for all Raspberry Pi models. The two lines you've posted are also part of that. Did the function not work for you?

What do you mean by "in the zwave serial controller"?

ThomDietrich pushed a commit that referenced this issue Nov 26, 2017
Signed-off-by: Thomas Dietrich <Thomas.Dietrich@tu-ilmenau.de>
@jeess
Copy link

jeess commented Nov 27, 2017

@ThomDietrich The function work for me. My problem was that zwave serial controller had an error "offline" and I had to change the port from AMA0 to ACN0 after making the changes in rbp3 model b.

@ThomDietrich
Copy link
Member

ThomDietrich commented Nov 27, 2017

@jeess wrong place to ask but I've created an issue in the right place to answer this ;)

openhab/openhab-docs#578

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants