Connection pooling in modbus binding

excuse me, I want to do everything at once.
I confuse you with COM ports because I run modpoll with simulator via 0-modem emulator (COM14 in logs). it was necessary, it mean I correctly set option to modpoll.
Then I change modbus library in Arduino and received normal ping via modpoll<->Arduino (COM3).
After correcting openhab.cfg to last working condition of Arduino I receive a new openhab.log
once again I apologize for confusion.

1 Like

what is the arduino code you are using. I have a couple arduinos I can program and test with as well.

at first time i use this library (arduino-modbus-slave). this library apprehensive to read registers and good worked with modbus-master simulators. finally modpoll donā€™t recognized registers from arduino.
then I saw one example where was table with registers, so I knew data accordance. i try to connect this library (Modbus-Master-Slave-for-Arduino) with modpoll and have nice result. now i use this library.

Iā€™m trying to get more information whether this behaviour is expected with windows and whether there is some parameter or similar that needs to be set on windowsā€¦

It would be excellent if someone else could reproduce the EOF issue with windows as well. @LeXLuther422 and/or @mbs38, can you test how the Modbus/RTU serial works with windows?

Best
Sami

Iā€™ll do some testing. It might take a couple of days - I need to get myself a virtual Windows machine first :wink:

1 Like

interesting things happened. I reinstall drivers to my USB adapter, try to connect with arduino and it become respond to openhab. but with some errors.
do you have some ideas about it.

openhab.cfg

openhab.log

Hi thanks for the new log!

The log seems quite similar than before? Sometimes not even three times is not enough for a successful response read, sometimes it works with less retries.

As before, it seems that EOF is received before 1.5seconds (ie receive timeout) elapses, something that we did not observe with @mbs38 linux openhab. The root cause for the discrepency is unknown to me. It does seem to be certain that the 3rd party serial library (nrjavaserial) openhab uses behaves differently. Not sure whether it is the library, os differences, or actual differences between devices or drivers.

I forgot to mention it here but I have asked for support in the serial library openhab uses. Also mentioned this in the pull request. So far no reply from anywhereā€¦

I wonder whoā€™s behind the serial binding, probably he/she would have a lead regarding this.

Best
Sami

@ssalonen Iā€™ve finally tested it on a Windows 7 32bit system. Works without any problems and seems to be just as fast as on Arch Linux.

Configuration: http://pastebin.com/KWvJjN0M

Best Regards, Max

1 Like

Thank you very much for taking the time to test it.

Good to hear it works it works!

Just for the record, the feature has been merged, and release milestone has been set to 1.9.0.

Thank you very much for your help testing the binding!

Best,
Sami

Hello
Is there any way to use this binding for RTU over TCp ?

thank you

Hi.

Iā€™ve tried the new version.
I do not know whether it supports my configurations file.

poll=10000
writemultipleregisters=true

# Read kWh & kW from EM23 El Meter
serial.em23.connection=/dev/ttyUSB0:9600:8:none:1:rtu:1000
serial.em23.id=1
serial.em23.start=12
serial.em23.length=3
serial.em23.type=input

# Read Nilan Temp
serial.nilan.connection=/dev/ttyUSB0:19200:8:even:1:rtu:1000
serial.nilan.id=30
serial.nilan.valuetype=int16
serial.nilan.start=203
serial.nilan.length=6
serial.nilan.type=input

# Read Nilan RH
serial.nilan2.connection=/dev/ttyUSB0:19200:8:even:1:rtu:1000
serial.nilan2.id=30
serial.nilan2.valuetype=int16
serial.nilan2.start=221
serial.nilan2.length=1
serial.nilan2.type=input

# Read Nilan AlarmStatus
serial.nilan3.connection=/dev/ttyUSB0:19200:8:even:1:rtu:1000
serial.nilan3.id=30
serial.nilan3.valuetype=int16
serial.nilan3.start=400
serial.nilan3.length=10
serial.nilan3.type=input

# Read/Write Nilan ControlSet
serial.nilan4.connection=/dev/ttyUSB0:19200:8:even:1:rtu:1000
serial.nilan4.id=30
serial.nilan4.start=1001
serial.nilan4.length=4
serial.nilan4.type=holding

# Read/Write Nilan Speed
serial.nilan5.connection=/dev/ttyUSB0:19200:8:even:1:rtu:1000
serial.nilan5.id=30
serial.nilan5.start=200
serial.nilan5.length=2
serial.nilan5.type=holding

It works fine if I only connect to one device, Nilan or EM23.

Should it be possible to connect to both with just one USB device?

This is the errors i see in the log:

2016-07-09 06:55:55.465 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 04 00 0c 00 03 70 08
2016-07-09 06:55:55.466 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2016-07-09 06:55:55.469 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@63a5e4 (unit id 1 & transaction 165). Serial parameters: SerialParameters@1985547[portName=/dev/ttyUSB0,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2016-07-09 06:55:57.985 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 04 00 0c 00 03 70 08
2016-07-09 06:55:57.986 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2016-07-09 06:55:57.989 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 2/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@63a5e4 (unit id 1 & transaction 165). Serial parameters: SerialParameters@1985547[portName=/dev/ttyUSB0,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2016-07-09 06:56:00.505 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 04 00 0c 00 03 70 08
2016-07-09 06:56:00.506 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2016-07-09 06:56:00.508 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 3/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@63a5e4 (unit id 1 & transaction 165). Serial parameters: SerialParameters@1985547[portName=/dev/ttyUSB0,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2016-07-09 06:56:00.510 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 3, throwing last error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@63a5e4. Serial parameters: SerialParameters@1985547[portName=/dev/ttyUSB0,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2016-07-09 06:56:00.511 [ERROR] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (em23): Error getting modbus data for request net.wimpi.modbus.msg.ReadInputRegistersRequest@63a5e4. Error: I/O exception - failed to read. Endpoint ModbusSerialSlaveEndpoint@7f71ee[portName=/dev/ttyUSB0]. Connection: SerialConnection@d687e0[portName=/dev/ttyUSB0,port=/dev/ttyUSB0]

Hope someone can helpā€¦ Thanks.

Certainly it works with many devices. Can you please confirm what version of modbus binding you are running?

I also noticed that you have different baud rates with slaves ā€“ even though they are connected via same serial port. That might cause issuesā€¦

Best
Sami

Hi, rtu over tcp is not supported currently. Perhaps you would like to open separate thread about this?

Best,
Sami

Hi.

I use this version.

yes I have different baud rate, but this can unfortunately not be changed on the devices.

@carzten2000, please find the late official 1.9.0 snapshot version here. I recommend using the above official development version instead of the custom build you are currently using (now that the new functionality is merged). Iā€™m afraid that itā€™s unlikely that it works even there due to different baud rates.

So it works if you remove the slave having different baud rate, eg em23?

I believe there was discussion in this thread regarding the challenges of having different baud rates in the same line. Iā€™m not sure you can really get that working reliablyā€¦ But perhaps some one else has more information on this?

Technically speaking the binding currently configures (baud rate, parity etc) the serial port in the very beginning, and does not change it afterwards. That alone now causes issues for you as the baud rate would have to be reconfigured again and again to match the slave device requirements. This detail is easy to change thoughā€¦ We could try it out if you like?

Hi.

Yes, everything is working great when I remove the connection to the device em23.
So it is because of the differnet baud rates.

that would be greet if you want to change the binding so i can test it.

@carzten2000 Please try out this version and report back please. Now this version re-configures the serial port after every transaction.

Best,
Sami

Hi.

Iā€™am still getting the same error.

2016-07-12 09:27:15.321 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 04 00 0c 00 03 70 08
2016-07-12 09:27:15.323 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2016-07-12 09:27:15.327 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@392119 (unit id 1 & transaction 3). Serial parameters: SerialParameters@38130d[portName=/dev/ttyUSB0,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2016-07-12 09:27:17.195 [INFO ] [marthome.event.ItemStateChangedEvent] - room08_room_temp changed from 22.60 to 22.50
2016-07-12 09:27:17.841 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 04 00 0c 00 03 70 08
2016-07-12 09:27:17.848 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2016-07-12 09:27:17.850 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 2/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@392119 (unit id 1 & transaction 3). Serial parameters: SerialParameters@38130d[portName=/dev/ttyUSB0,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2016-07-12 09:27:20.361 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 04 00 0c 00 03 70 08
2016-07-12 09:27:20.362 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2016-07-12 09:27:20.364 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 3/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@392119 (unit id 1 & transaction 3). Serial parameters: SerialParameters@38130d[portName=/dev/ttyUSB0,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2016-07-12 09:27:20.365 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 3, throwing last error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@392119. Serial parameters: SerialParameters@38130d[portName=/dev/ttyUSB0,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2016-07-12 09:27:20.367 [ERROR] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (em23): Error getting modbus data for request net.wimpi.modbus.msg.ReadInputRegistersRequest@392119. Error: I/O exception - failed to read. Endpoint ModbusSerialSlaveEndpoint@1b70321[portName=/dev/ttyUSB0]. Connection: SerialConnection@6c8b5f[portName=/dev/ttyUSB0,port=/dev/ttyUSB0]

It does not look like the baud rate is changing.

If I remember correctly, the binding prints summary of parsed slaves in the beginning . That should make it clear what baud etc will be used.

Can you repeat the test with debug level logging and paste the relevant log snippet here? you can find instructions to logging configuration from the modbus binding wiki page

Best
Sami