Connection to RFXCOM controller failed

I have seen all previous posts about this and tried everything but nothing seems to have worked.
When openhab is starting it fails to connect to my RFXCOM and I get the following log message…

2016-05-02 16:56:51.948 [INFO ] [.b.r.internal.RFXComConnection] - Connecting to RFXCOM [serialPort='/dev/ttyUSB0' ].
2016-05-02 16:56:52.048 [ERROR] [.b.r.internal.RFXComConnection] - Connection to RFXCOM controller failed.
gnu.io.NoSuchPortException: null
    at gnu.io.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:273) ~[na:na]
    at org.openhab.binding.rfxcom.internal.connector.RFXComSerialConnector.connect(RFXComSerialConnector.java:60) ~[na:na]
    at org.openhab.binding.rfxcom.internal.RFXComConnection.connect(RFXComConnection.java:118) ~[na:na]
    at org.openhab.binding.rfxcom.internal.RFXComConnection.updated(RFXComConnection.java:103) ~[na:na]

My config…

################################ RFXCOM Binding #######################################
#
# Serial port of RFXCOM interface
# Valid values are e.g. COM1 for Windows and /dev/ttyS0 or /dev/ttyUSB0 for Linux
rfxcom:serialPort = /dev/ttyUSB0

# Set mode command for controller (optional)
# E.g. rfxcom:setMode=0D000000035300000C2F00000000
#rfxcom:setMode =

Start Script…

#!/bin/sh

cd `dirname $0`

# set path to eclipse folder. If local folder, use '.'; otherwise, use /path/to/eclipse/
eclipsehome="server";

# set ports for HTTP(S) server
HTTP_PORT=8080
HTTPS_PORT=8443
DAEMON_USER=root
DAEMON_NAME=openhab
# get path to equinox jar inside $eclipsehome folder
cp=$(find $eclipsehome -name "org.eclipse.equinox.launcher_*.jar" | sort | tail -1);

echo Launching the openHAB runtime...
java \
    -Dosgi.clean=true \
    -Declipse.ignoreApp=true \
    -Dosgi.noShutdown=true  \
    -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0 \
    -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0 \
    -Djetty.port=$HTTP_PORT  \
    -Djetty.port.ssl=$HTTPS_PORT \
    -Djetty.home=.  \
    -Dlogback.configurationFile=configurations/logback.xml \
    -Dfelix.fileinstall.dir=addons -Dfelix.fileinstall.filter=.*\\.jar \
    -Djava.library.path=lib \
    -Djava.security.auth.login.config=./etc/login.conf \
    -Dorg.quartz.properties=./etc/quartz.properties \
    -Dequinox.ds.block_timeout=240000 \
    -Dequinox.scr.waitTimeOnBlock=60000 \
    -Dfelix.fileinstall.active.level=4 \
    -Djava.awt.headless=true \
    -jar $cp $* \
    -console

I have also tried creating a SYMLINK which doesnt work either. I simply get the same connection failed message.

Hi,

Maybe you can try to put serial ports on only one line:
-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyAMA0

I’m not sure it is able to handle several lines of same parameter…

Great! That seems to have done the trick.

Solving one problem and doing a clean install on my Pi has created another! Now suddenly AMA0 isn’t accessible at all!

It seems to not be part of the dialout group anymore…

crw--w---- 1 root tty       4, 62 May 11 10:49 /dev/tty62
crw--w---- 1 root tty       4, 63 May 11 10:49 /dev/tty63
crw--w---- 1 root tty       4,  7 May 11 10:49 /dev/tty7
crw--w---- 1 root tty       4,  8 May 11 10:49 /dev/tty8
crw--w---- 1 root tty       4,  9 May 11 10:49 /dev/tty9
crw--w---- 1 root tty     204, 64 May 11 10:57 /dev/ttyAMA0
crw------- 1 root root      5,  3 May 11 10:49 /dev/ttyprintk
crw-rw---- 1 root dialout 188,  0 May 11 10:49 /dev/ttyUSB0

I have tried adding the openhab user to the tty group but this still didn’t work.

$ groups openhab
openhab : openhab tty dialout

I still get the dreaded…

Serial Error: Port /dev/ttyAMA0 does not exist

Ok. Solved it. Kinda.

I set

A6      Serial     "Enable/Disable shell and kernel messages on the serial connection"

in raspi-config to “Disabled”.

This put ttyAMA0 back into the dialout group. I then ensured the openhab user was in this group.
However it still didn’t work.

I went back to my original manual install of openhab instead of using apt-get, ran openhab as Pi and everything is now working.

Some permission setting somewhere was stopping the openhab user from accessing the serial port but keeping my hair was more important than finding where!

Hope this helps someone.