Please help me to troubleshoot / tune serial binding / communication!

Hi,

I have a problem. The history of it can be found in this thread. But long story shorter here.

I’m running Openhab for 1.5 years and generally satisfied. Nothing too fancy (to my mind): a few sensors and actuators based on MySensors project communicating via serial plus a few Milight controlled bulbs. A few month again I decided to hook it up with my home controller via modbus (over serial interface). Some problems on the way, but I got it working.

Until just recently when I tried to hook it up also with my DSC system via DSC binding (and Envisalink module). I succeeded with DSC. Then I needed to activate one more modbus slave in order to elaborate on the new DSC features. That broke the serial communication. I (think I) have reverted the system to state as it was before I started with DSC, but serial communication for modbus I can’t get back working.

I’m out of ideas, looking for help how to troubleshoot.

I’m on OH 1.8.3 on Ubuntu server 16.04. The actual symptom why I suspect serial problem is that when I activate second serial (ttyUSB1) interface, the first serial interface one trows this (dmesg):

[   31.390695] ttyUSB0: 1 input overrun(s)

Both are serial-to-USB converters, ttyUSB0 being 1-2 and ttyUSB1 being 1-4:

$ lsusb
Bus 003 Device 002: ID 8087:8001 Intel Corp. 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 8087:0a2a Intel Corp. 
Bus 001 Device 004: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 003: ID 0835:1601 Action Star Enterprise Co., Ltd 
Bus 001 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I’m not a Linux engineer, but have basic understanding. Please help to troubleshoot!

I wonder if there is some confusion/crossover between serial ports. See note 5 at bottom of serial binding Wiki


hinting that they can get swapped.

The overrun error indicates incoming data that isn’t getting handled, maybe it is unexpected or maybe the host binding isn’t processing it. Could be noise on the line,

I think in your other thread it is already mentioned that you must use Modbus binding 1.9.0 for any hope of multi slave serial.

Confident in the hardware? e.g. for Modbus serial - using twisted pair cable, terminators, pullups (line idles high).

Have you a laptop or somesuch you could use as a serial line monitor, confirm where that overrun comes from?

Thanks for looking into this!

I wonder if there is some confusion/crossover between serial ports. See note 5 at bottom of serial binding Wiki hinting that they can get swapped.

I have the same feeling, but lack knowledge to troubleshoot.

I have noticed that ports were swapped sometimes. Kept rebooting until they came back in the right sequence :slight_smile: Thanks for pointing to the note 5, I did not notice that when installed serial binding in 2015.

I tried note 5, but did not succeed.

First problem is that one of devices does not have manufacturer’s serial number (cheep pl2303 chip converter). Trying to use serial of the parent device from usb device tree does not work, symlink is not created. Is there any workaround to that?

Second problem. Symlink for the other device is created:

lrwxrwxrwx 1 root root 7 jan 18 22:11 ttyMySensors -> ttyUSB1

But it is not recognised by OH as a serial port. openhab.log says:

2017-01-18 22:11:48.791 [ERROR] [i.internal.GenericItemProvider] - Binding configuration of type 'serial' of item ‘Arduino‘ could not be parsed correctly.
org.openhab.model.item.binding.BindingConfigParseException: Could not open serial port /dev/ttyMySensors: Serial port '/dev/ttyMySensors' could not be found. Available ports are:
/dev/ttyUSB1
/dev/ttyUSB0
/dev/ttyS0

What am I missing here? openhab user is in dialout group, symlink ir rw for anybody, can it be lack of access rights in some other way?

I think in your other thread it is already mentioned that you must use Modbus binding 1.9.0 for any hope of multi slave serial.

It is not working neither with 1.8.3 nor 1.9.0 Modbus binding. Ok, it was working with 1.9.0 Modbus binding, but now I can’t get it back to work. 1.8.3 was pretty weak in functionality anyway.

Confident in the hardware? e.g. for Modbus serial - using twisted pair cable, terminators, pullups (line idles high).

No :smiley: But it was working like a charm for several months.

I have computer running OH -> USB-RS232 converter -> standard RS232 2m cable -> controller. It is suggested to use RS232 port of the controller by manufacturer. Btw, there is RS485 port too with optional pullups on the controller. I tried it, but did not succeed.

Have you a laptop or somesuch you could use as a serial line monitor, confirm where that overrun comes from?

Sure, but I would need some hints / guidance how to do it.

As you have seen “serial port swapping”, and are having difficulty fixing that, looks like the place to start. I have no idea about that in this environment.
Maybe a lead from here
http://www.domoticz.com/wiki/PersistentUSBDevices

No, creating symlinks to serial ports does not help.

Symlinks are created and responding (stty command gives response):

lrwxrwxrwx 1 root root          7 jan 23 20:05 ttyCarloGavazzi -> ttyUSB1
lrwxrwxrwx 1 root root          7 jan 23 19:56 ttyMySensors -> ttyUSB0
...
crw-rw---- 1 root dialout 188,  0 jan 23 19:56 ttyUSB0
crw-rw---- 1 root dialout 188,  1 jan 23 20:05 ttyUSB1

but I get this in openhab.log:

2017-01-23 19:53:43.068 [ERROR] [pi.modbus.net.SerialConnection] - Could not get port identifier, maybe insufficien
t permissions. null
2017-01-23 19:53:43.071 [ERROR] [dbusSlaveConnectionFactoryImpl] - connect try 1/3 error: Could not get port identi
fier, maybe insufficient permissions. null. Connection SerialConnection@16b39069[portName=/dev/ttyCarloGavazzi,port
=<null>]. Endpoint ModbusSerialSlaveEndpoint@2095c205[portName=/dev/ttyCarloGavazzi]
2017-01-23 19:53:43.373 [ERROR] [pi.modbus.net.SerialConnection] - Could not get port identifier, maybe insufficien
t permissions. null
2017-01-23 19:53:43.373 [ERROR] [dbusSlaveConnectionFactoryImpl] - connect try 2/3 error: Could not get port identi
fier, maybe insufficient permissions. null. Connection SerialConnection@16b39069[portName=/dev/ttyCarloGavazzi,port
=<null>]. Endpoint ModbusSerialSlaveEndpoint@2095c205[portName=/dev/ttyCarloGavazzi]
2017-01-23 19:53:43.676 [ERROR] [pi.modbus.net.SerialConnection] - Could not get port identifier, maybe insufficien
t permissions. null
2017-01-23 19:53:43.676 [ERROR] [dbusSlaveConnectionFactoryImpl] - connect try 3/3 error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection@16b39069[portName=/dev/ttyCarloGavazzi,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@2095c205[portName=/dev/ttyCarloGavazzi]
2017-01-23 19:53:43.677 [ERROR] [dbusSlaveConnectionFactoryImpl] - re-connect reached max tries 3, throwing last error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection@16b39069[portName=/dev/ttyCarloGavazzi,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@2095c205[portName=/dev/ttyCarloGavazzi]
2017-01-23 19:53:43.677 [ERROR] [dbusSlaveConnectionFactoryImpl] - Error connecting connection SerialConnection@16b39069[portName=/dev/ttyCarloGavazzi,port=<null>] for endpoint ModbusSerialSlaveEndpoint@2095c205[portName=/dev/ttyCarloGavazzi]: Could not get port identifier, maybe insufficient permissions. null

Something wrong with serial ports. I was playing around, sometimes the port connected to modbus makes the other port to stop working. Disconnecting/restarting service/reboot helps. I tried connect the modbus as only serial, that does not help.

But has it fixed the identity swapping at boot up?

Log is hinting strongly about permissions, old thread about Pi and OH1 serial here


maybe that all needs re-doing after symlinks finalised.

It’s not very clear what works, what doesn’t, what “not works” means, what “helps” means - in terms of what results you see.

Seem that I have done it! :slight_smile: Thanks for your help!

But has it fixed the identity swapping at boot up?

Yes, it did.

old thread about Pi and OH1 serial here Serial binding on rpi
maybe that all needs re-doing after symlinks finalised.

This one helped me in a sense that it pointed me that serial port(s) must be added to Java startup parameters in openhab startup script. Lacked this initially, because I was using standard ports, so skipped Note 2 in a serial binding documentation. Plus I did not thought to reread/redo everything after implementing Note 5.

So, serial seem stable now and I can return to the original modbus problem / topic.

Thank you again! I learned some things in the process too.

Excellent news. Do we need to add any guidance to the Modbus binding Wiki? Maybe just a pointer to the Serial binding guide notes?

My experience was not because documentation does not contain information which solved my problem. It was because I do not have a habit to reread everything and do not see dependencies in a Linux fast.

If there is a suggestion, I’d “promote” adding serial port(s) to JAVA_ARGS_DEFAULT in serial binding documentation from just a note to (recommended) step.