modbus tcp configuration

788 views
Skip to first unread message

xavier...@alternative-energies.fr

unread,
Apr 21, 2015, 5:14:16 AM4/21/15
to ope...@googlegroups.com

i want to read function 4 data from a modbus tcp slave


i can read this data from other clients like mbtget are giving me the answers :
mbtget -r4 -n 30 -a 0 10.0.0.110


but with openhab i am having issues.


here is my config :


openhab.cfg

# sets refresh interval to Modbus polling service.
# Value in milliseconds (optional, defaults to 200)
modbus:poll=200

# host (mandatory)
modbus:tcp.slave1.connection=192.168.0.21

# The data typ.pe, can be "coil" "discrete" "holding" "input"
modbus:tcp.slave1.type=input

# the TCP port (optional, defaults to '502')
modbus:tcp.slave1.port=502

# The slave id (optional, defaults to '1')
#modbus:tcp.slave1.id=1

# The slave start address (optional, defaults to '0')
modbus:tcp.slave1.start=0

# The number of data item to read
# (optional, defaults to '0' - but set it to something meaningful)
modbus:tcp.slave1.length=3

# Value type, required for combined registers (details: http://www.simplymodbus.ca/FAQ.htm#Types)
# Can be "bit", "int8", "uint8", "int16", "uint16", "int32", "uint32", "float32"
# (optional, defaults to 'uint16')
modbus:tcp.slave1.valuetype=uint16


items :

Number touch_version_major "touch version major" (gVersion) {modbus="slave1:0"}

Number touch_version_minor "touch version minor" (gVersion) {modbus="slave1:1"}

Number touch_version_build "touch version build" (gVersion) {modbus="slave1:2"}



log :


.o.core.internal.CoreActivator] - Couldn't create file 'webapps/static/uuid'.
java.io.FileNotFoundException: webapps/static/uuid (Permission non accordée)
    at java.io.FileOutputStream.open(Native Method) ~[na:1.7.0_75]
    at java.io.FileOutputStream.<init>(FileOutputStream.java:221) ~[na:1.7.0_75]
    at java.io.FileOutputStream.<init>(FileOutputStream.java:171) ~[na:1.7.0_75]
    at org.openhab.core.internal.CoreActivator.writeFile(CoreActivator.java:114) [org.openhab.core_1.6.2.jar:na]
    at org.openhab.core.internal.CoreActivator.createUUIDFile(CoreActivator.java:90) [org.openhab.core_1.6.2.jar:na]
    at org.openhab.core.internal.CoreActivator.start(CoreActivator.java:52) [org.openhab.core_1.6.2.jar:na]
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at java.security.AccessController.doPrivileged(Native Method) [na:1.7.0_75]
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
2015-04-20 20:40:58.712 [ERROR] [.o.core.internal.CoreActivator] - Couldn't create file 'webapps/static/version'.
java.io.FileNotFoundException: webapps/static/version (Permission non accordée)
    at java.io.FileOutputStream.open(Native Method) ~[na:1.7.0_75]
    at java.io.FileOutputStream.<init>(FileOutputStream.java:221) ~[na:1.7.0_75]
    at java.io.FileOutputStream.<init>(FileOutputStream.java:171) ~[na:1.7.0_75]
    at org.openhab.core.internal.CoreActivator.writeFile(CoreActivator.java:114) [org.openhab.core_1.6.2.jar:na]
    at org.openhab.core.internal.CoreActivator.createVersionFile(CoreActivator.java:107) [org.openhab.core_1.6.2.jar:na]
    at org.openhab.core.internal.CoreActivator.start(CoreActivator.java:59) [org.openhab.core_1.6.2.jar:na]
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at java.security.AccessController.doPrivileged(Native Method) [na:1.7.0_75]
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
2015-04-20 20:40:58.714 [INFO ] [.o.core.internal.CoreActivator] - openHAB runtime has been started (v1.6.2).
2015-04-20 20:41:01.123 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - mDNS service has been started
2015-04-20 20:41:01.498 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - Service Discovery initialization completed.
2015-04-20 20:41:10.705 [INFO ] [penhab.io.rest.RESTApplication] - Started REST API at /rest
2015-04-20 20:41:11.308 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'cogeneration.sitemap'
2015-04-20 20:41:11.575 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'cogeneration.items'
2015-04-20 20:41:16.267 [INFO ] [.o.u.w.i.servlet.WebAppServlet] - Started Classic UI at /openhab.app
2015-04-20 20:41:21.057 [INFO ] [.service.AbstractActiveService] - Modbus Polling Service has been started
[INFO ] [.b.modbus.internal.ModbusSlave] - ModbusSlave error getting responce from slave

Nick AtNick

unread,
Apr 22, 2015, 9:09:30 AM4/22/15
to ope...@googlegroups.com
Could you increase your log level and post the output again?

xavier...@alternative-energies.fr

unread,
Apr 30, 2015, 10:08:13 AM4/30/15
to ope...@googlegroups.com

Hello


where best shall i do that ?


logback.xml
logback_debug.xml ?


i see small documentation about that in the wiki

thank you

Nathan Stratton

unread,
May 1, 2015, 2:45:19 PM5/1/15
to ope...@googlegroups.com
You can run ./start_debug.sh or modify logback.xml and change:

<logger name="runtime.busevents" level="INFO" additivity="false">

To:

 <logger name="runtime.busevents" level="DEBUG" additivity="false">



><>
nathan stratton | vp technology | broadsoft, inc | +1-240-404-6580 | www.broadsoft.com

--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
To view this discussion on the web visit https://groups.google.com/d/msgid/openhab/53b9f2c9-89fd-4774-9571-3c74fdd58256%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Xavier Lebrun

unread,
May 25, 2015, 12:09:20 PM5/25/15
to ope...@googlegroups.com
i solved first some file rights errofs on the openhab installation by apt-get




i made the two following changes to logback.xml



<logger name="runtime.busevents" level="DEBUG" additivity="false">


and

<logger name="org.openhab" level="DEBUG"/>
     
 <logger name="org.openhab.binding.modbus" level="DEBUG" />


i have now the following exceptions :


[DEBUG] [.b.modbus.internal.ModbusSlave] - ModbusSlave:Error Code = 1
2015-05-25 18:11:16.991 [INFO ] [.b.modbus.internal.ModbusSlave] - ModbusSlave error getting responce from slave


i try to make tests with other slaves

Xavier Lebrun

unread,
May 25, 2015, 1:35:21 PM5/25/15
to ope...@googlegroups.com
is there any test/demo modbus server againts which openhab modbus binding could be tes

Xavier Lebrun

unread,
May 26, 2015, 4:25:12 AM5/26/15
to ope...@googlegroups.com

actually the logs are showing this kind of error


[DEBUG][modbus.internal.ModbusTcpSlave] - ModbusSlave: Error connecting to master: Connexion refusée
2015-05-26 01:28:45.690 [INFO ] [.b.modbus.internal.ModbusSlave] - ModbusSlave not connected


Connexion refusée = connexion refused


this is not so clear readin error.

atually the master is working fine as i can connect to it with mbtget command line interface.




Le lundi 25 mai 2015 18:09:20 UTC+2, Xavier Lebrun a écrit :

Xavier Lebrun

unread,
May 26, 2015, 4:55:14 AM5/26/15
to ope...@googlegroups.com
depending which slave i am connecting to


i can have also this kind of error


[INFO ] [.b.modbus.internal.ModbusSlave] - ModbusSlave error getting responce from slave


if i try to connect to those slaves/sensors with other tools like mbtget everything is working fine

Nick AtNick

unread,
May 26, 2015, 5:32:44 AM5/26/15
to ope...@googlegroups.com


On Monday, 25 May 2015 18:09:20 UTC+2, Xavier Lebrun wrote:
i solved first some file rights errofs on the openhab installation by apt-get
Nice!

[DEBUG] [.b.modbus.internal.ModbusSlave] - ModbusSlave:Error Code = 1
2015-05-25 18:11:16.991 [INFO ] [.b.modbus.internal.ModbusSlave] - ModbusSlave error getting responce from slave
For me that seems like an exception coming from the slave, code "1" means "Illegal Function" [1], I guess (because I dont know what data where actually sent to the device) that the target doesn't support Read Input Registers (function code four)[6]. Please check that in the devices datasheet and also please post an output of mbtget[7] with *additional option* -d, asking *that very device* on which you are trying with openHAB.

It is hard to debug because of so little exception information. IMHO one should raise the log level of the errors fetched in the ModbusSlave.java [2] especially the two possible log outputs concerning this error [3][4]. Further are both exceptions most likely coming from ModbusTCPTransaction [5]. The exception messages there should be extended with information about the ModbusRequest m_Request (e.g. function code, address to be read out, data value, ...).

[1] https://en.wikipedia.org/wiki/Modbus#Main_Modbus_exception_codes
[2] https://github.com/openhab/openhab/blob/0e3f2441596cc000e29c4bb74454aedeea357762/bundles/binding/org.openhab.binding.modbus/src/main/java/org/openhab/binding/modbus/internal/ModbusSlave.java
[3] https://github.com/openhab/openhab/blob/0e3f2441596cc000e29c4bb74454aedeea357762/bundles/binding/org.openhab.binding.modbus/src/main/java/org/openhab/binding/modbus/internal/ModbusSlave.java#L249
[4] https://github.com/openhab/openhab/blob/0e3f2441596cc000e29c4bb74454aedeea357762/bundles/binding/org.openhab.binding.modbus/src/main/java/org/openhab/binding/modbus/internal/ModbusSlave.java#L337
[5] https://github.com/openhab/openhab/blob/76e85fd80980b47864d07b147706c8afadbb2d32/bundles/binding/org.openhab.binding.modbus/src/main/java/net/wimpi/modbus/io/ModbusTCPTransaction.java#L205-L210
[6] https://en.wikipedia.org/wiki/Modbus#Supported_function_codes
[7] https://github.com/sourceperl/mbtget/blob/master/scripts/mbtget

Xavier Lebrun

unread,
May 26, 2015, 11:39:54 AM5/26/15
to ope...@googlegroups.com

most of the addresses i need on the slave are of the type function 4


mbtget is working fine that way :

mbtget -r4 -n 30 -a 0 192.168.1.31


actually most of the mistakes are of the type :


[DEBUG][modbus.internal.
ModbusTcpSlave] - ModbusSlave: Error connecting to master: Connexion refusée
2015-05-26 01:28:45.690 [INFO ] [.b.modbus.internal.ModbusSlave] - ModbusSlave not connected


i also made a try with ibh modbus slave simulator :


http://ibh-systems.com/modbus/slave/


i can read properly with mbtget but not with openhab

Xavier Lebrun

unread,
May 26, 2015, 12:27:47 PM5/26/15
to ope...@googlegroups.com
for information, i am open to pro/paid support solutions


i can send the slave modbus table documentation

and also open my routerport so that someone can access the modbus slave
TPANEL_MODBUS_DOKU_0.5.pdf

Nick AtNick

unread,
May 27, 2015, 9:28:41 AM5/27/15
to ope...@googlegroups.com


On Tuesday, 26 May 2015 17:39:54 UTC+2, Xavier Lebrun wrote:

[DEBUG][modbus.internal.
ModbusTcpSlave] - ModbusSlave: Error connecting to master: Connexion refusée
2015-05-26 01:28:45.690 [INFO ] [.b.modbus.internal.ModbusSlave] - ModbusSlave not connected

i can read properly with mbtget but not with openhab
Could you try to set the modbus:poll in the openhab.cfg to
modbus:poll=5200
this is the modbus timeout of your target device +200ms buffer.

Is there no other error than the connection refused thing, just that line?

Xavier Lebrun

unread,
May 27, 2015, 10:42:05 AM5/27/15
to ope...@googlegroups.com


Le mercredi 27 mai 2015 15:28:41 UTC+2, Nick AtNick a écrit :


On Tuesday, 26 May 2015 17:39:54 UTC+2, Xavier Lebrun wrote:

[DEBUG][modbus.internal.
ModbusTcpSlave] - ModbusSlave: Error connecting to master: Connexion refusée
2015-05-26 01:28:45.690 [INFO ] [.b.modbus.internal.ModbusSlave] - ModbusSlave not connected

i can read properly with mbtget but not with openhab
Could you try to set the modbus:poll in the openhab.cfg to
modbus:poll=5200
this is the modbus timeout of your target device +200ms buffer.

i have played a bit with the delay but i will put it again longer
 

 
Is there no other error than the connection refused thing, just that line?


i have solve most of my install issues (mainl wrong ownership rights)
now this is the only error i still have


by the way
thank you for supporting
 

Nick AtNick

unread,
May 27, 2015, 11:14:23 AM5/27/15
to ope...@googlegroups.com
"connection refused" - permission problems could still be an issue.
 
by the way
thank you for supporting
You are welcome. If you solved it, sharing your solution would be nice.
 

Xavier Lebrun

unread,
May 27, 2015, 11:46:09 AM5/27/15
to ope...@googlegroups.com
for linux debian

do you recommend the apt-get intall or the manual one ?


it seems there is some ownership issues with the apt-get method


xavier

Xavier Lebrun

unread,
May 27, 2015, 6:51:35 PM5/27/15
to ope...@googlegroups.com
i restarted everything from scratch with the manual install and not apt-get


i confirm i can read my device with mbtget
  • mbtget -r4 -n 30 -a 0 10.0.0.110

my configuration is :


modbus:poll=6000


modbus:tcp.slave1.connection=192.168.1.31
modbus:tcp.slave1.type=input
modbus:tcp.slave1.port=502
modbus:tcp.slave1.id=1
modbus:tcp.slave1.start=22
modbus:tcp.slave1.length=3
modbus:tcp.slave1.valuetype=uint16




items :


Number engine_errorstate "engine errorstate" (gState) {modbus="slave1:22"}
Number engine_mode "engine mode" (gState) {modbus="slave1:23"}
Number engine_state "engine state" (gState) {modbus="slave1:24"}


whenn startin start_debug.sh
still i have the error :



[INFO ] [.b.modbus.internal.ModbusSlave:305  ] - ModbusSlave error getting responce from slave



is there something wrong in my config ?


is there a test slave simulator i can use to test against my openhab ?


i have tried openhab againts this but it was not working. http://ibh-systems.com/modbus/slave/download/


if there is any exmple modbus config file against a modbus simulator or normal config.
i would be very happy to make a test

cause i am only making turns with openhab.


and other solutions i found like proview are completely overkill for my needs (but working)


xavier

Nick AtNick

unread,
May 28, 2015, 1:51:23 AM5/28/15
to ope...@googlegroups.com


On Thursday, 28 May 2015 00:51:35 UTC+2, Xavier Lebrun wrote:
my configuration is :


modbus:poll=6000


modbus:tcp.slave1.connection=192.168.1.31
modbus:tcp.slave1.type=input
modbus:tcp.slave1.port=502
modbus:tcp.slave1.id=1
modbus:tcp.slave1.start=22
modbus:tcp.slave1.length=3
modbus:tcp.slave1.valuetype=uint16




items :


Number engine_errorstate "engine errorstate" (gState) {modbus="slave1:22"}
Number engine_mode "engine mode" (gState) {modbus="slave1:23"}
Number engine_state "engine state" (gState) {modbus="slave1:24"}


whenn startin start_debug.sh
still i have the error :



[INFO ] [.b.modbus.internal.ModbusSlave:305  ] - ModbusSlave error getting responce from slave

Is there really no other error log ob the .b.modbus facility?


is there something wrong in my config ?


Yes, in the item config the values of the registers (e.g. {modbus="slave1:22"}) is the offset added to the offset of the connection (modbus:tcp.slave1.start=22). With that line you are trying to read register 44, which you are not requesting from the target because of modbus:tcp.slave1.length=3. Try {modbus="slave1:0"} to {modbus="slave1:2"}.

Xavier Lebrun

unread,
May 28, 2015, 4:32:09 AM5/28/15
to ope...@googlegroups.com
thank you i will review that


i have started again with a fresh ubuntu 14.04 ubuntu install and default-jre java

now the output is quite different and much more talky :
 

10:26:13.261 [DEBUG] [o.b.m.internal.ModbusActivator:30   ] - Modbus binding has been started.
10:26:13.297 [DEBUG] [.modbus.internal.ModbusBinding:282  ] - modbusSlave 'slave1' instanciated
10:26:13.298 [DEBUG] [.modbus.internal.ModbusBinding:344  ] - config looked good, proceeding with slave-connections
10:26:13.314 [INFO ] [.service.AbstractActiveService:169  ] - Modbus Polling Service has been started
10:26:15.068 [ERROR] [.o.m.c.i.folder.FolderObserver:105  ] - An unexpected exception has occured
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.xtext.resource.XtextResourceSet$1
    at org.eclipse.xtext.resource.XtextResourceSet.getURIConverter(XtextResourceSet.java:170) ~[na:na]
    at org.eclipse.xtext.resource.XtextResourceSet.getResource(XtextResourceSet.java:136) ~[na:na]
    at org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:23) ~[na:na]
    at org.openhab.model.core.internal.ModelRepositoryImpl.getResource(ModelRepositoryImpl.java:153) ~[na:na]
    at org.openhab.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:71) ~[na:na]
    at org.openhab.model.core.internal.folder.FolderObserver.checkFolder(FolderObserver.java:142) ~[na:na]
    at org.openhab.model.core.internal.folder.FolderObserver.run(FolderObserver.java:99) ~[na:na]
net.wimpi.modbus.ModbusIOException: Premature end of stream (Header truncated).
    at net.wimpi.modbus.io.ModbusTCPTransport.readResponse(ModbusTCPTransport.java:177)
    at net.wimpi.modbus.io.ModbusTCPTransaction.execute(ModbusTCPTransaction.java:193)
    at org.openhab.binding.modbus.internal.ModbusSlave.getModbusData(ModbusSlave.java:335)
    at org.openhab.binding.modbus.internal.ModbusSlave.update(ModbusSlave.java:289)
    at org.openhab.binding.modbus.internal.ModbusBinding.execute(ModbusBinding.java:231)
    at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156)
    at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173)
net.wimpi.modbus.ModbusIOException: Premature end of stream (Header truncated).
    at net.wimpi.modbus.io.ModbusTCPTransport.readResponse(ModbusTCPTransport.java:177)
    at net.wimpi.modbus.io.ModbusTCPTransaction.execute(ModbusTCPTransaction.java:193)
    at org.openhab.binding.modbus.internal.ModbusSlave.getModbusData(ModbusSlave.java:335)
    at org.openhab.binding.modbus.internal.ModbusSlave.update(ModbusSlave.java:289)
    at org.openhab.binding.modbus.internal.ModbusBinding.execute(ModbusBinding.java:231)
    at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156)
    at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173)
net.wimpi.modbus.ModbusIOException: Premature end of stream (Header truncated).
    at net.wimpi.modbus.io.ModbusTCPTransport.readResponse(ModbusTCPTransport.java:177)
    at net.wimpi.modbus.io.ModbusTCPTransaction.execute(ModbusTCPTransaction.java:193)
    at org.openhab.binding.modbus.internal.ModbusSlave.getModbusData(ModbusSlave.java:335)
    at org.openhab.binding.modbus.internal.ModbusSlave.update(ModbusSlave.java:289)
    at org.openhab.binding.modbus.internal.ModbusBinding.execute(ModbusBinding.java:231)
    at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156)
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173)
net.wimpi.modbus.ModbusIOException: Premature end of stream (Header truncated).
    at net.wimpi.modbus.io.ModbusTCPTransport.readResponse(ModbusTCPTransport.java:177)
    at net.wimpi.modbus.io.ModbusTCPTransaction.execute(ModbusTCPTransaction.java:193)
    at org.openhab.binding.modbus.internal.ModbusSlave.getModbusData(ModbusSlave.java:335)
    at org.openhab.binding.modbus.internal.ModbusSlave.update(ModbusSlave.java:289)
    at org.openhab.binding.modbus.internal.ModbusBinding.execute(ModbusBinding.java:231)
    at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156)
    at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173)
10:26:18.968 [DEBUG] [.b.modbus.internal.ModbusSlave:337  ] - ModbusSlave:Executing transaction failed (tried 3 times)
10:26:18.969 [INFO ] [.b.modbus.internal.ModbusSlave:305  ] - ModbusSlave error getting responce from slave
10:26:25.075 [ERROR] [.o.m.c.i.folder.FolderObserver:105  ] - An unexpected exception has occured
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.xtext.resource.XtextResourceSet$1
    at org.eclipse.xtext.resource.XtextResourceSet.getURIConverter(XtextResourceSet.java:170) ~[na:na]
    at org.eclipse.xtext.resource.XtextResourceSet.getResource(XtextResourceSet.java:136) ~[na:na]
    at org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:23) ~[na:na]
    at org.openhab.model.core.internal.ModelRepositoryImpl.getResource(ModelRepositoryImpl.java:153) ~[na:na]
    at org.openhab.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:71) ~[na:na]
    at org.openhab.model.core.internal.folder.FolderObserver.checkFolder(FolderObserver.java:142) ~[na:na]
    at org.openhab.model.core.internal.folder.FolderObserver.run(FolderObserver.java:99) ~[na:na]



i will review the offset you are talking about

Xavier Lebrun

unread,
May 28, 2015, 6:20:36 AM5/28/15
to ope...@googlegroups.com

a new test result



[DEBUG] [o.b.m.internal.ModbusActivator:30   ] - Modbus binding has been started.
12:09:32.804 [DEBUG] [i.internal.GenericItemProvider:341  ] - Start processing binding configuration of Item 'engine_errorstate (Type=NumberItem, State=Uninitialized)' with 'ModbusGenericBindingProvider' reader.
12:09:32.805 [DEBUG] [i.internal.GenericItemProvider:341  ] - Start processing binding configuration of Item 'engine_mode (Type=NumberItem, State=Uninitialized)' with 'ModbusGenericBindingProvider' reader.
12:09:32.806 [DEBUG] [i.internal.GenericItemProvider:341  ] - Start processing binding configuration of Item 'engine_state (Type=NumberItem, State=Uninitialized)' with 'ModbusGenericBindingProvider' reader.
12:09:32.844 [DEBUG] [.modbus.internal.ModbusBinding:282  ] - modbusSlave 'slave1' instanciated
12:09:32.845 [DEBUG] [.modbus.internal.ModbusBinding:344  ] - config looked good, proceeding with slave-connections
12:09:32.860 [INFO ] [.service.AbstractActiveService:169  ] - Modbus Polling Service has been started
12:09:32.892 [INFO ] [.b.modbus.internal.ModbusSlave:305  ] - ModbusSlave error getting responce from slave


still i can read with mbtget


is see no difference with the offset value

Nick AtNick

unread,
May 28, 2015, 7:11:52 AM5/28/15
to ope...@googlegroups.com

On Thursday, 28 May 2015 12:20:36 UTC+2, Xavier Lebrun wrote:

a new test result
Please note what you have done next time, s.t. others are able to retrace the results with the previous one. For now I suggest that you just have fixed the offset.


[DEBUG] [o.b.m.internal.ModbusActivator:30   ] - Modbus binding has been started.
12:09:32.804 [DEBUG] [i.internal.GenericItemProvider:341  ] - Start processing binding configuration of Item 'engine_errorstate (Type=NumberItem, State=Uninitialized)' with 'ModbusGenericBindingProvider' reader.
12:09:32.805 [DEBUG] [i.internal.GenericItemProvider:341  ] - Start processing binding configuration of Item 'engine_mode (Type=NumberItem, State=Uninitialized)' with 'ModbusGenericBindingProvider' reader.
12:09:32.806 [DEBUG] [i.internal.GenericItemProvider:341  ] - Start processing binding configuration of Item 'engine_state (Type=NumberItem, State=Uninitialized)' with 'ModbusGenericBindingProvider' reader.
12:09:32.844 [DEBUG] [.modbus.internal.ModbusBinding:282  ] - modbusSlave 'slave1' instanciated
12:09:32.845 [DEBUG] [.modbus.internal.ModbusBinding:344  ] - config looked good, proceeding with slave-connections
12:09:32.860 [INFO ] [.service.AbstractActiveService:169  ] - Modbus Polling Service has been started
12:09:32.892 [INFO ] [.b.modbus.internal.ModbusSlave:305  ] - ModbusSlave error getting responce from slave


still i can read with mbtget


is see no difference with the offset value
I'm pretty sure that the new offset is the correct one, except the TCP binding behaves different to the serial binding.

However because that doesn't say so much:
1. dig into the traffic (e.g. with wireshark [2]) and compare both: The mbtget and the openhab communication.
2. If you are able to write a little bit of java code, setup an IDE [1] and integrate some log messages. Or find one who's going to do that for you.

[1] https://github.com/openhab/openhab/wiki/IDE-Setup
[2] https://wiki.wireshark.org/CaptureSetup

Xavier Lebrun

unread,
May 28, 2015, 9:35:04 AM5/28/15
to ope...@googlegroups.com
i will make a try with wireshark.



for more support disponibility
as i told it previously i am open for paid support proposal.

Xavier Lebrun

unread,
May 28, 2015, 11:12:39 AM5/28/15
to ope...@googlegroups.com


here is the results with wireshark :

  1. mbtget
  • command : mbtget -r4 -n 4 -a 20  192.168.1.11
  • values:
      1 (ad 00020):    50
      2 (ad 00021):     0
      3 (ad 00022):     0
      4 (ad 00023):  8965


  • wireshark computer > slave :
  •   function code : read input register (4)
  • reference number : 20
  • word count : 4


  • wireshark slave > computer
  • function code : read input register (4)
  • Byte count : 8
  • register 0 (UINT16) : 50
  • Register 1 (unint16) : 0
  • register 2 (unint16)  : 0
  • register 3 : (unint16) : 8965

  1.  openhab

  • debug :

  • DEBUG] [.modbus.internal.ModbusBinding:282  ] - modbusSlave 'slave1' instanciated
  • 16:49:42.757 [DEBUG] [.modbus.internal.ModbusBinding:344  ] - config looked good, proceeding with slave-connections
    16:49:42.767 [INFO ] [.service.AbstractActiveService:169  ] - Modbus Polling Service has been started
    16:49:42.847 [INFO ] [.b.modbus.internal.ModbusSlave:305  ] - ModbusSlave error getting responce from slave


  • wireshark

  • openhab > slave :
  • function code : read input register (4)
  • reference number : 20
  • word count : 3

  • slave> openhab
  • ireshark slave > computer
  • function code : read input register (4)
  • Byte count : 6
  • register 0 (UINT16) : 50
  • Register 1 (unint16) : 0
  • register 2 (unint16)  : 0


to me, it seems wireshark is able to read the modbus connection that openhab is not able to read


could it be an openhab issue ?

or an issue in my installation ?

Nick AtNick

unread,
May 29, 2015, 5:24:06 AM5/29/15
to ope...@googlegroups.com
Ok, you are getting closer.


On Thursday, 28 May 2015 17:12:39 UTC+2, Xavier Lebrun wrote:


here is the results with wireshark :

  1. mbtget
  • command : mbtget -r4 -n 4 -a 20  192.168.1.11
  • values:
      1 (ad 00020):    50
      2 (ad 00021):     0
      3 (ad 00022):     0
      4 (ad 00023):  8965


  • wireshark computer > slave :
  •   function code : read input register (4)
  • reference number : 20
  • word count : 4
The registers (data sent) here are interesting (but missing)


  • wireshark slave > computer
  • function code : read input register (4)
  • Byte count : 8
  • register 0 (UINT16) : 50
  • Register 1 (unint16) : 0
  • register 2 (unint16)  : 0
  • register 3 : (unint16) : 8965

  1.  openhab

  • debug :

  • DEBUG] [.modbus.internal.ModbusBinding:282  ] - modbusSlave 'slave1' instanciated
    16:49:42.757 [DEBUG] [.modbus.internal.ModbusBinding:344  ] - config looked good, proceeding with slave-connections
    16:49:42.767 [INFO ] [.service.AbstractActiveService:169  ] - Modbus Polling Service has been started
    16:49:42.847 [INFO ] [.b.modbus.internal.ModbusSlave:305  ] - ModbusSlave error getting responce from slave


  • wireshark

  • openhab > slave :
  • function code : read input register (4)
  • reference number : 20
  • word count : 3
The registers (data sent) here are very interesting
  • slave> openhab
  • ireshark slave > computer
  • function code : read input register (4)
  • Byte count : 6
  • register 0 (UINT16) : 50
  • Register 1 (unint16) : 0
  • register 2 (unint16)  : 0

Oh, very nice! Wireshark has a built in modbus parser!! I'm pretty impressed from wireshark! :)

You'r getting closer to the actual problem, because sent and the received data chain are different between mbtget and openhab - see:
 - mbtget: word count: 4
 - openhab: word count: 3
the exact data/bytes are interesting, please analyze and post them (maybe in an extra file).

You could also double check the mbtget outgoing data with the previous mentioned mbtget flag -d.

could it be an openhab issue ?

yes, thats of course an options since the request is working with mbtget.


Xavier Lebrun

unread,
May 29, 2015, 9:54:20 AM5/29/15
to ope...@googlegroups.com
sorry i may have been confused in the reports i copy.


word count was 3 with this openhab test cause it was configured to read 3 values.


if openhab is asked to read 4 ralues.


wireshark gives exactly the same values between mbtget and openhab.
just openhab reply that he cannot get the answer from slave


actually i am following your good advices


but i have no idea about the possible origins



Nick AtNick

unread,
May 31, 2015, 4:35:51 AM5/31/15
to ope...@googlegroups.com


On Friday, 29 May 2015 15:54:20 UTC+2, Xavier Lebrun wrote:

but i have no idea about the possible origins
If you post *both* the mtbget and the openHAB datastream (sent bytes & received bytes) I'm going to analyze them according to the modbus standard [1].
Just to be clear, I need the values of the data sent/received and *not just* their pure amount.

[1] http://www.modbus.org/specs.php
Reply all
Reply to author
Forward
0 new messages