Zigbee Binding Ember EM35x NCP unable to open serial port

  • Platform information:
    • Hardware: iMx6DL
    • OS: Yocto (Linux Kernel version 4.9.88)
    • Java Runtime Environment: Zulu 8.46.0.225-CA-linux_aarch32hf
    • openHAB version: 2.5.5

Hi,
We have an MightyGecko Zigbee dongle placed in our iMX6DL board. I needs to bind that dongle to OpenHAB via Zigbee binding.
Here’s what I have done so far.
I downloaded OpenHAB stable runtime zip file from https://www.openhab.org/download/ and unzipped it in /media/openhab-2.5.5 directory.
Then I added user openhab with following command
useradd --system --no-create-home --shell /usr/sbin/nologin openhab
Then added user openhab to tty and dialout groups with following command
usermod -a -G dialout,tty openhab
I execute below command to make openhab directory belongs to openhab user
chown -hR openhab:openhab /media/openhab-2.5.5
Then I launched OpenHAB with following command
su -s /bin/bash -c ‘/media/openhab-2.5.5/start.sh’ openhab
Zigbee Dongle will be detected in board at /dev/ttymxc4
So I manually created /etc/default/openhab2 file and added following line in the file
EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttymxc4"
Then I tried to add zigbee dongle manually as a thing via Zigbee Binding -> Ember EM35x Coordinator
I got below error log in openhab.log.

2020-07-06 11:12:02.970 [ERROR] [zigbee.dongle.ember.ZigBeeDongleEzsp] - EZSP Dongle: Unable to open serial port
2020-07-06 11:12:02.988 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception:
java.lang.NullPointerException: null
at org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler.initialiseZigBee(ZigBeeCoordinatorHandler.java:425) ~[?:?]
at org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler.lambda$2(ZigBeeCoordinatorHandler.java:543) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_252]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_252]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_252]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:1.8.0_252]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
2020-07-06 11:12:03.996 [INFO ] [bee.handler.ZigBeeCoordinatorHandler] - ZigBee dongle inactivity timer. Reinitializing ZigBee

I am doubting there might be some permission issues causing this error. Can someone help me solve this issue.

Thanks,
Syed Ahmed M

Have you added anything to EXTRA_JAVA_OPTS as mentioned in the serial port documentation?

What is the output of the command sudo dmesg | grep -i tty ?

What serial port do you have selected for the binding?

Yes. I created /etc/default/openhab2 file and added below line
EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttymxc4"

root@imx6dlsabresd:/# dmesg | grep -i tty
[ 0.000000] Kernel command line: console=ttymxc0,115200 root=/dev/mmcblk3p2 rootwait rw
[ 0.521362] 2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 24, base_baud = 5000000) is a IMX
[ 1.132748] console [ttymxc0] enabled
[ 1.135990] 21ec000.serial: ttymxc2 at MMIO 0x21ec000 (irq = 67, base_baud = 5000000) is a IMX
[ 1.143910] 21f4000.serial: ttymxc4 at MMIO 0x21f4000 (irq = 68, base_baud = 5000000) is a IMX
[ 2.822075] Bluetooth: RFCOMM TTY layer initialized
root@imx6dlsabresd:/#

/dev/ttymxc4

To make sure that this environment variable is being used you need to start the openhab instance after modifying the file. You may have done it but it is not part of the steps you listed.
Also I am wondering why the file /etc/default/openhab2 was not already there. Please check if the file is being called/sourced fromthe startup routine. If that is not the case then the environment variable will not be set and not be used.

I think according to OpenHAB document, there is no equivalent file for Manual Installation. I can’t do package installation in my board. So I created manually. and I run the application after adding that file.

To make sure that environment variable is set, I manually exported that environment variable.

root@imx6dlsabresd:/# echo $EXTRA_JAVA_OPTS
-Dgnu.io.rxtx.SerialPorts=/dev/ttymxc4

What document did you follow for installation?
We need all this information in order to properly help you. You know how you set up your system ans what steps you tried. We do not know unless to decide to tell us.

I followed this link https://www.openhab.org/docs/installation/linux.html#manual-installation

I extracted openhab in /media folder instead of /opt. Rest I did as mentioned. Whatever steps I followed were mentioned in my post.

You missed this section of the document.

I saw that also. What conf I needs to do specially for Zigbee binding. I can do network binding without any issues. Only Zigbee binding had issue.

Ok, according to your answer the environment variable is set for the user root.
Does this mean your system sources /etc/default/openhab2 for all users ?
openhab service runs as user openhab is the environment variable also available for that user ?
This is why I asked if /etc/default/openhab2 is being sourced from the startup routine.
Alternativley I would like to ask you to open a karaf console and check if gnu.io.rxtx.SerialPorts is set.
So login to karaf console and execute the command:

env| grep -i Serial

this should show something like:

String          gnu.io.rxtx.SerialPorts /dev/ttymxc4

Do you mean like this

openhab> env | grep -i Serial
String gnu.io.rxtx.SerialPorts /dev/ttymxc4

IF that is in the openHAB config file you may not see it there. We know /etc/default/openhab2 is not the proper place according to the documentation. That is why it did not exist.
I highlighted the incorrect item. I see there is no default preconfiguraiton for that type of install.

I prefer installing the openHABian scripts for a debian based Linux install. It preconfigures many of these things for you.

Currently, with the ethernet connection in board, package repository installation is tougher. Is it possible to fix this issue in manual installation?

I was able to do a network binding, publish network binding thing’s state via mqtt broker, etc… Now i needs to publish this zigbee data through mqtt. For that, I needs to bind my dongle with OpenHAB.

Also, we can’t port to OpenHABian now.

@wborn has worked a lot with serial.

After adding the environment variable and restarting the openhab service you still get the error message “Unable to open serial port” or is it a different one now ?

2 Likes

I am getting same “unable to open serial port” error only.
Edit: This morning I launch openhab by following command with environment variable set. And its connected.
/media/openhab-2.5.5/start.sh
Will do further tests and update.

So, Here is what I did.

  • I removed earlier installed OpenHAB package.
  • Installed again by unzipping OpenHAB.zip.
  • Run Below Commands

useradd --system --no-create-home --shell /usr/sbin/nologin openhab
usermod -a -G dialout,tty openhab
chown -hR openhab:openhab /media/openhab-2.5.5
export EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttymxc4"
/media/openhab-2.5.5/start.sh

  • Connect to Zigbee Binding. Dongle gets Status Online.

For anyone who faces this issue, setting up that environment variable and add openhab user to tty,dialouts group will solve the issue.

Thanks @Wolfgang_S @Bruce_Osborne for your help.

2 Likes