I have openhab v2.3 running and Comfoair binding installed. The system is not productive yet.
In service/comfoair.cfg I have set the port /dev/ttyS4 to be used. That port is not existing it is created through a systemd service that calls socat
ExecStart=/usr/bin/socat pty,link=/dev/ttyS4,b9600,raw,echo=0 TCP:192.168.223.110:2021
---
root@orlando:/etc/openhab2/services# ls -l /dev/ttyS*
crw-rw---- 1 root dialout 4, 64 Aug 2 20:17 /dev/ttyS0
crw-rw---- 1 root dialout 4, 65 Aug 2 20:17 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 Aug 2 20:17 /dev/ttyS2
crw-rw---- 1 root dialout 4, 67 Aug 2 20:17 /dev/ttyS3
lrwxrwxrwx 1 root dialout 10 Aug 8 09:50 /dev/ttyS4 -> /dev/pts/1
I am able to establish a communication with minicom from the openhab host to the target serial port using a putty terminal attached.
the Comfoair binding reports anyway: 2018-08-08 09:54:39.722 [ERROR] [ng.comfoair.internal.ComfoAirBinding] - Serial port '/dev/ttyS4' could not be found. Available ports are:
How is the Binding using the defined interface?
Maybe the problem is with the socat command, but I’m really scatching my head whit shouldn’t be possible that way.
EDIT:
In reference to: “Serial port not recognized”, this was the solution. Thanks to Miika for bringing this in focus.
Thanks for that hint. Which I just tried out even with my personal expectation that it wouldn’t change anything.
The result is the same. Meanwhile I attached a USB to serial converter to the System. The output of openhab.log shows now:
2018-08-10 18:17:12.814 [ERROR] [ng.comfoair.internal.ComfoAirBinding] - Serial port '/dev/ttyS4' could not be found. Available ports are:
/dev/ttyUSB0
Which means that the binding is checking for physical presence of a serial port. Which is what I was hopeing to prevent with socat.
But the connection looks now as follows:
openHAB > USB-to-Serial → Serial-To-Ethernet Gateway → Ethernet-To-Serial Gateway > Serial Port to ComfoAir
I would appreciate for the future to extend the openHAB binding in that way, that i can directly communicate to an Ethernet-To-Serial Gateway or at least using a Virtual Serial Port connection (i.e. using socat).
Yes, i’ve checked that. Before I even started to play around with. I mean there is enough available on the internet. And the fact that a terminal to terminal connection worked nice shows that socat to Ethernet-To-Serial adapter is fine. Just the binding is not able to handle it.
Just for the fun. I have used port=TCP-ADDRESS:PORT instead of the /dev/tty?? the outcome of this was that the binding found the attached USB to serial adapter:
2018-08-09 19:00:15.799 [ERROR] [ng.comfoair.internal.ComfoAirBinding] - Serial port '192.168.223.110:2021' could not be found. Available ports are:
/dev/ttyUSB0
I also had a look at ser2net and tcpser, with no chance. And to my understanding ser2net’s operation mode is to provide a TCP Port to which i can connect with telnet and then it opens a Serial connection to an attached device. Please someone correct me if i’m wrong, but this is what I found in whatever guideline I went through.
tcpser even failed to startup with the configuration I tried as there was no serial device
2018-08-09 21:24:05:1365124864:ENTER_EXIT:Entering ctrl_thread function
2018-08-09 21:24:05:1365124864:FATAL:Could not obtain serial port status (Input/output error)
2018-08-09 21:24:05:1365124864:ENTER_EXIT:Exitting ctrl_thread function
Hmm I just remembered that I previously had a working setup like yours. I implemented serial interface to a binding and had rs485 -> rpi2+ser2net - > ethernet - > socat - > /dev/ttySx connection for testing purposes. Just can’t remember all the details. Is the symlink created by socat?
If you have that port added to extra_java_opts what does ps -aux | grep ttyS4 output?
Just to be sure. What platform and what is your java version?
Refering to your first post “I am able to establish a communication with minicom from the openhab host to the target serial port using a putty terminal attached.”
Yes, firstly I tried it as root which was working fine, later on I tested it as openhab user for what I had openhab to the dialout group first and it worked fine.
Please read here: Creating Addon: Could not find artifact com.sun🛠jar:1.8.0 This topic is about maven builds but as Hans-Jörg states there are known problems with OpenJDK. It affects wether you are running openhab or anything related.
Please switch to Oracle or Zulu java and try again.
} catch (NoSuchPortException e) {
StringBuilder sb = new StringBuilder();
@SuppressWarnings("rawtypes")
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
CommPortIdentifier id = (CommPortIdentifier) portList.nextElement();
if (id.getPortType() == CommPortIdentifier.PORT_SERIAL) {
sb.append(id.getName() + "\n");
}
}
throw new InitializationException(
"Serial port '" + port + "' could not be found. Available ports are:\n" + sb.toString());
}
So maybe this is because /dev/ttyS4 is not defined as PORT_SERIAL.
If changing from OpenJDK to Oracle or Zulu does not resolve the problem, I suggest you could try to install Eclipse IDE with all configuration for Binding development. Then try to start Comfoair Binding and if it is still not working, try to update the code in src/main/java/org/openhab/binding/comfoair/handling/ComfoAirConnector.java around line 108 to log all ports and their type.
# java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
Changed the port to be used to /dev/ttyS0 and adjusted the socat start command accordingly (i.e using existing and not create own one)
Same issue, openHAB still tells me:
2018-08-11 13:42:01.067 [ERROR] [ng.comfoair.internal.ComfoAirBinding] - Serial port '/dev/ttyS0' could not be found. Available ports are:
/dev/ttyUSB0
I also added the EXTRA_JAVA_OPTS param again, just for the fun of it. which results in the same message as shown above.
Did you restart OH after configuring extra_java_opts? And are you sure you have it configured correctly? Because grepping with ttyS0 it should display openhab process when you have -Dgnu.io.rxtx.SerialPorts=/dev/ttyS0 set up and picked up by java process when it’s starting.
Hi all,
I’m sorry to ask this again, while reading that the Issue seems to be solved,…
I’m better in german and total new in Linux/ Raspberry pi, but i hope you will halp me with my issue.
I try to select the correct port by serial ID like this:
port=/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0
But i get the same error as Stefan.
2020-01-23 15:29:31.698 [ERROR] [ng.comfoair.internal.ComfoAirBinding] - Serial port ‘/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0’ could not be found. Available ports are:
/dev/ttyUSB0
/dev/ttyAMA0
Can someone help me with an easy solution to fix the ports?
I always need to reconfigure that, when the pi restarts.
I wold be soooooooooooooooooooo happy if there is someone who like to help me out.
Thx a Lot,
Mark
First you have to run this command in terminal to see where your usb converter is linked to.
dmesg | grep tty
[17:44:42] openhabian@openhabian-server:~$ dmesg | grep tty
[ 0.000000] console [tty0] enabled
[ 1.411572] 00:01: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[ 1.432553] 00:02: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A
[ 1.491362] tty tty1: hash matches
[ 6.702787] usb 1-4: FTDI USB Serial Device converter now attached to ttyUSB0
[ 6.705346] usb 1-6: FTDI USB Serial Device converter now attached to ttyUSB1
Here you can see i have 2 usb converters ttyUSB0 and ttyUSB1
When you plug in 1 and run the command you can see where the usb converter is linked to.
When you reboot or plug the converter in or out, it is possible that it will change location.
you can create simlinks and then your usb converter is fixed to that port.
Here is a tutorial.