Modbus openHAB2 binding available for alpha testing

openhab2-addons
modbus
binding
Tags: #<Tag:0x00007f182f88f600> #<Tag:0x00007f182f88f3f8> #<Tag:0x00007f182f88f150>

(Ssalonen) #122

Did typo writemultiableregisters (should be writemultipleregisters) :smiley: ? I think the old binding just ignored typoed parameters and therefore the setting would not have any effect.

In any case, I think the separate poll confirms that slave just responds with error on FC-06 so everything good from the new binding perspective?


(Nanna Agesen) #123

Sorry it was a typo :frowning:

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

This is my config start.


(Ssalonen) #124

Actually, I think I misunderstood your modbus poll test. So there should not be any error since binding should use Fc 16.

Can you please try with today’s version just to be sure the bug is not fixed


(Nanna Agesen) #125

Yes I will give the new version a test tonight.

Best Nanna


(Frederic Mariën) #126

No problem at all! I was on holiday so there was no stress.
Thank you for your work!

At first sight, everything looks fine according to the connections and the registering and unregistering of polling tasks.
I will do some more checks during the week.

Something else I see now while using the new thing configuration is that I get an error message while using the readValueType uint16 and int16 (the only ones I used until now).
I get this error message on all data things in paper UI:

Out-of-bounds: Poller is reading from index 4000 to 4011 but configuration tries to parse uint16 starting from register 1. Exceeds polled data by -64160 bits

This is my test configuration:

Bridge modbus:tcp:endpointTCP [ host="192.168.50.113", port=502, id=11, reconnectAfterMillis=300000 ] {
	Bridge poller ReadSection1 [ start=4000, length=12, refresh=10000, type="holding" ] {
		Thing data VE_DeviceType [ readStart="1", readValueType="uint16" ]
		
		Thing data VE_DeviceVersion [ readStart="3", readValueType="uint16" ]
		
		Thing data VE_OutsideTemperature [ readStart="8", readValueType="uint16" ]
		
		Thing data VE_OutsideTemperature [ readStart="9", readValueType="uint16" ]	
		
		Thing data VE_InletPressure [ readStart="10", readValueType="uint16" ]
		
		Thing data VE_OutletPressure [ readStart="11", readValueType="uint16" ]
		
	//	Thing data VE_Airflow [ readStart="12", readValueType="uint16" ]
	}
}

Do you have an idea what could be the issue? Do you need more logging on this?

Greetings,
Frederic


(Ssalonen) #127

As said, the addresses are absolute in data thing :slight_smile: Please refer to docs for more info. I think this makes more sense in the end, although it’s quite jarring experience for early testers

In other words readStart should be over 4000 in your case.

Best
Sami


(Nanna Agesen) #128

As you explained before is it understood correctly that it’s only data thing that are absolute?

I have installed the latest version of the binding and haven’t converted yet to Data thing.

I’m getting this warning now

10:42:26.072 [ERROR] [ort.modbus.internal.ModbusManagerImpl] - Unhandled exception in callback: java.lang.IllegalArgumentException Index=4 with type=uint32_swap is out-of-bounds given registers of size 6
java.lang.IllegalArgumentException: Index=4 with type=uint32_swap is out-of-bounds given registers of size 6
	at org.openhab.io.transport.modbus.ModbusBitUtilities.extractStateFromRegisters(ModbusBitUtilities.java:88) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusReadThingHandler.onRegisters(ModbusReadThingHandler.java:309) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusReadWriteThingHandler.lambda$3(ModbusReadWriteThingHandler.java:104) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusReadWriteThingHandler.lambda$6(ModbusReadWriteThingHandler.java:138) ~[?:?]
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374) ~[?:?]
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusReadWriteThingHandler.forEachChildReader(ModbusReadWriteThingHandler.java:137) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusReadWriteThingHandler.onRegisters(ModbusReadWriteThingHandler.java:103) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator.lambda$2(ModbusPollerThingHandlerImpl.java:66) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[?:?]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:?]
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[?:?]
	at java.util.Iterator.forEachRemaining(Iterator.java:116) ~[?:?]
	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator.forEachAllChildCallbacks(ModbusPollerThingHandlerImpl.java:61) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator.onRegisters(ModbusPollerThingHandlerImpl.java:66) ~[?:?]
	at org.openhab.io.transport.modbus.internal.ModbusManagerImpl.invokeCallbackWithResponse(ModbusManagerImpl.java:255) ~[?:?]
	at org.openhab.io.transport.modbus.internal.ModbusManagerImpl.lambda$18(ModbusManagerImpl.java:559) ~[?:?]
	at java.util.Optional.ifPresent(Optional.java:159) ~[?:?]
	at org.openhab.io.transport.modbus.internal.ModbusManagerImpl.lambda$9(ModbusManagerImpl.java:559) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:?]
	at java.lang.Thread.run(Thread.java:745) [?:?]

Thing Config

// #Smarthouse EM-24 Energi Analyzer (Address 3506-3678) (174)	

	Bridge poller EM24_Energi [ start=3506, length=6, refresh=5000, type="input" ] {
        Bridge readwrite EM24_Energi_24_AL1 { 
	         Thing read I3506 [ start=0, transform="JS(divide1000.js)", trigger="*", valueType="uint32_swap" ]    
		 }
	Bridge readwrite EM24_Energi_24_AL2 { 	
		 Thing read I3508 [ start=2, transform="JS(divide1000.js)", trigger="*", valueType="uint32_swap" ]	
		 }
	Bridge readwrite EM24_Energi_24_AL3 { 		
		 Thing read I3510 [ start=4, transform="JS(divide1000.js)", trigger="*", valueType="uint32_swap" ]   	     
                 }

Can you short explain the absolute addressing, would the address 3506 that are input be (FC-04 starting with 30) 303506?


(Ssalonen) #129

As you explained before is it understood correctly that it’s only data thing that are absolute?

Indeed, I haven’t (at least intentionally) changed behaviour of read and write things.

Absolute addressing (readStart and writeStart parameters of data):

Input as zero-based index number, e.g. in place of 400001 (first holding register), use the address 0. Must be between (poller start) and (poller start + poller length - 1) (inclusive).

When polling registers and reading <16 bit value types you provide REG.ITEM as readStart. The docs explain this in more detail.

Relative addressing (read and write things):

In your example, poller has start=3506. This is the address passed in the modbus protocol as is. Since you are reading input registers, the first polled register has number 30001+3506=33507 (or sometimes written as 303507)

See also this wikipedia article.


Coming back to your error, it looks buggy / unclear indeed.

I think it is corner case not covered by my tests. Please try with updated version (from 15 mins ago)


(Nanna Agesen) #130

Just to be sure I’ve got the correct version is it the one from marketplace.eclipse.org?


(Nanna Agesen) #131

Hi Again

I got a lot of errors and Ill try to concentrate on one at a time.

I’m trying to read and write from a holding register that is verified to be a Uint32, it needs to be swapped to get the right value.

My thing is configured as below, not yet converted to data thing

// #Smarthouse Varmesetpunkt Udestue
	Bridge poller Setpoint_Udestue [ start=987, length=2, refresh=200, type="holding" ] {
        Bridge readwrite Setpoint_Udestue { 
            Thing read H987 [ start=0, transform="JS(divide10.js)", trigger="*", valueType="uint32_swap" ]    
	    Thing write H987 [ start=0, transform="JS(multiply10.js)", trigger="*", valueType="uint32_swap", type="holding" ]

I get this warning

13:29:57.306 [WARN ] [ort.modbus.internal.ModbusManagerImpl] - Transaction id of the response does not match request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@7891eb2c[slaveId=1,functionCode=READ_MULTIPLE_REGISTERS,start=987,length=2].  Endpoint ModbusTCPSlaveEndpoint@2fe7d96d[address=192.168.100.86,port=502]. Connection: Optional[TCPMasterConnection@6552dbb9[socket=Socket[addr=/192.168.100.86,port=502,localport=34870]]]. Ignoring response.
13:29:57.308 [WARN ] [s.handler.ModbusReadWriteThingHandler] - Read write thing handler got read error: org.openhab.io.transport.modbus.ModbusUnexpectedTransactionIdException null

As i’m reading an Uint32 has anything changed regarding the Length?
I have an start address 987, with a length of 2

Best Nanna


(Nanna Agesen) #132

More Details on the error/warning

13:29:57.306 [WARN ] [ort.modbus.internal.ModbusManagerImpl] - Transaction id of the response does not match request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@7891eb2c[slaveId=1,functionCode=READ_MULTIPLE_REGISTERS,start=987,length=2].  Endpoint ModbusTCPSlaveEndpoint@2fe7d96d[address=192.168.100.86,port=502]. Connection: Optional[TCPMasterConnection@6552dbb9[socket=Socket[addr=/192.168.100.86,port=502,localport=34870]]]. Ignoring response.
13:29:57.308 [WARN ] [s.handler.ModbusReadWriteThingHandler] - Read write thing handler got read error: org.openhab.io.transport.modbus.ModbusUnexpectedTransactionIdException null
13:29:57.309 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'modbus:read:endpointSmarthouse:Setpoint_Udestue:Setpoint_Udestue:H987' changed from OFFLINE (BRIDGE_OFFLINE): Read-write bridge Modbus read-write definition is offline to OFFLINE (BRIDGE_OFFLINE)
13:29:57.309 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'modbus:read:endpointSmarthouse:Setpoint_Udestue:Setpoint_Udestue:H987' changed from OFFLINE (BRIDGE_OFFLINE) to OFFLINE (BRIDGE_OFFLINE): Read-write bridge Modbus read-write definition is offline
13:29:57.309 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'modbus:write:endpointSmarthouse:Setpoint_Udestue:Setpoint_Udestue:H987' changed from OFFLINE (BRIDGE_OFFLINE): Read-write bridge Modbus read-write definition is offline to OFFLINE (BRIDGE_OFFLINE)
13:29:57.310 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'modbus:write:endpointSmarthouse:Setpoint_Udestue:Setpoint_Udestue:H987' changed from OFFLINE (BRIDGE_OFFLINE) to UNKNOWN
13:29:57.310 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'modbus:readwrite:endpointSmarthouse:Setpoint_Udestue:Setpoint_Udestue' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Read write thing handler got read error: org.openhab.io.transport.modbus.ModbusUnexpectedTransactionIdException null. See logs above for more information
13:29:57.310 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'modbus:write:endpointSmarthouse:Setpoint_Udestue:Setpoint_Udestue:H987' changed from UNKNOWN to OFFLINE (BRIDGE_OFFLINE): Read-write bridge Modbus read-write definition is offline
13:29:57.311 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'modbus:read:endpointSmarthouse:Setpoint_Udestue:Setpoint_Udestue:H987' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE): Read-write bridge Modbus read-write definition is offline
13:29:57.311 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'modbus:write:endpointSmarthouse:Setpoint_Udestue:Setpoint_Udestue:H987' changed from ONLINE to UNKNOWN
13:29:57.311 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'modbus:write:endpointSmarthouse:Setpoint_Udestue:Setpoint_Udestue:H987' changed from UNKNOWN to OFFLINE (BRIDGE_OFFLINE): Read-write bridge Modbus read-write definition is offline
13:29:57.312 [ERROR] [modbus.handler.ModbusReadThingHandler] - Thing Modbus read definition received read error: org.openhab.io.transport.modbus.ModbusUnexpectedTransactionIdException null. Stack trace follows for unexpected errors.
org.openhab.io.transport.modbus.ModbusUnexpectedTransactionIdException: null
	at org.openhab.io.transport.modbus.internal.ModbusManagerImpl.lambda$17(ModbusManagerImpl.java:554) ~[?:?]
	at java.util.Optional.ifPresent(Optional.java:159) ~[?:?]
	at org.openhab.io.transport.modbus.internal.ModbusManagerImpl.lambda$8(ModbusManagerImpl.java:553) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:?]
	at java.lang.Thread.run(Thread.java:745) [?:?]
13:29:57.313 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'modbus:read:endpointSmarthouse:Setpoint_Udestue:Setpoint_Udestue:H987' changed from OFFLINE (BRIDGE_OFFLINE): Read-write bridge Modbus read-write definition is offline to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.io.transport.modbus.ModbusUnexpectedTransactionIdException: null
13:29:57.458 [ERROR] [ort.modbus.internal.ModbusManagerImpl] - Unhandled exception in callback: java.lang.NullPointerException null
java.lang.NullPointerException: null
13:29:57.500 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'modbus:readwrite:endpointSmarthouse:Setpoint_Udestue:Setpoint_Udestue' changed from OFFLINE (COMMUNICATION_ERROR): Read write thing handler got read error: org.openhab.io.transport.modbus.ModbusUnexpectedTransactionIdException null. See logs above for more information to ONLINE
13:29:57.501 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'modbus:write:endpointSmarthouse:Setpoint_Udestue:Setpoint_Udestue:H987' changed from ONLINE to UNKNOWN
13:29:57.501 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'modbus:write:endpointSmarthouse:Setpoint_Udestue:Setpoint_Udestue:H987' changed from UNKNOWN to ONLINE

(Nanna Agesen) #133

Ok as for now it looks like all errors disappeared.

My refresh were set to 1000, I changed it to 5000 and for my things with Uint32_swap it needed to be 8000


(Ssalonen) #134

Just to be sure I’ve got the correct version is it the one from marketplace.eclipse.org2?

Marketplace links to the latest snapshot always so that is the correct version.

13:29:57.306 [WARN ] [ort.modbus.internal.ModbusManagerImpl] - Transaction id of the response does not match request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@7891eb2c[slaveId=1,functionCode=READ_MULTIPLE_REGISTERS,start=987,length=2]. Endpoint ModbusTCPSlaveEndpoint@2fe7d96d[address=192.168.100.86,port=502]. Connection: Optional[TCPMasterConnection@6552dbb9[socket=Socket[addr=/192.168.100.86,port=502,localport=34870]]]. Ignoring response.

Transaction id is a running number set in the request. Response should have the same number. If not, the binding discard the response (polled data is ignored).

I think you actually found a really hard-to-find bug! The comparison might have used wrong transaction id in some race conditions. I have now fixed the transaction id (~10mins ago), so hopefully it works with short poll periods as well.

As i’m reading an Uint32 has anything changed regarding the Length?
I have an start address 987, with a length of 2

Nothing has changed, you specify the number of registers you want to poll.


(Ssalonen) #135

Btw, REFRESH command should now work with data things.


(Nanna Agesen) #136

Hi Again

Can confirm that it now works with short poll :slight_smile:

Best Nanna


(Nanna Agesen) #137

I’m Still facing problems with my slave device, needing the writemultipleregisters=true in the old binding set.

I’m not sure if my problem is not understanding the Absolute Data addressing, or i’m having more issue.

I know this isn’t right, hope you can help me correct my config, so I’m 100% sure there is nothing here

/ #nilan_holding_control	

	Bridge poller Nilan_Holding_Control [ start=1000, length=8, refresh=1002, type="holding" ] {

	    Thing data Nilan_Holding_Control [ readStart="0", readValueType="holding", writeStart="0", writeValueType="uint16",writeType="holding", writeMultipleEvenWithSingleRegister="true" ]
	    
	    Thing data Nilan_Control_RunSet [ readStart="1", readValueType="holding", writeStart="1", writeValueType="uint16",writeType="holding", writeMultipleEvenWithSingleRegister="true" ]
	    
	    Thing data Nilan_Control_ModeSet [ readStart="2", readValueType="holding", writeStart="2", writeValueType="uint16",writeType="holding", writeMultipleEvenWithSingleRegister="true" ]
	    
	    Thing data Nilan_Control_VentSet [ readStart="3", readValueType="holding", writeStart="3", writeValueType="uint16",writeType="holding", writeMultipleEvenWithSingleRegister="true" ]

	    Thing data Nilan_Control_TempSet [ readStart="4", readValueType="holding", writeStart="4", writeValueType="uint16",writeType="holding", writeMultipleEvenWithSingleRegister="true" ]
	    
	    Thing data Nilan_Control_ServiceMode [ readStart="5", readValueType="holding", writeStart="5", writeValueType="uint16",writeType="holding", writeMultipleEvenWithSingleRegister="true" ]
	    
	    Thing data Nilan_Control_ServicePct [ readStart="6", readValueType="holding", writeStart="6", writeValueType="uint16",writeType="holding", writeMultipleEvenWithSingleRegister="true" ]
	    
	    Thing data Nilan_Control_Preset [ readStart="7", readValueType="holding", writeStart="7", writeValueType="uint16",writeType="holding", writeMultipleEvenWithSingleRegister="true" ] 
	  	 }

im Getting this error

18:37:03.241 [ERROR] [ort.modbus.internal.ModbusManagerImpl] - Unhandled exception in callback: java.lang.NullPointerException null
java.lang.NullPointerException: null
	at org.openhab.binding.modbus.handler.ModbusDataThingHandler.onRegisters(ModbusDataThingHandler.java:450) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator.lambda$2(ModbusPollerThingHandlerImpl.java:67) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[?:?]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:?]
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[?:?]
	at java.util.Iterator.forEachRemaining(Iterator.java:116) ~[?:?]
	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator.forEachAllChildCallbacks(ModbusPollerThingHandlerImpl.java:62) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator.onRegisters(ModbusPollerThingHandlerImpl.java:67) ~[?:?]
	at org.openhab.io.transport.modbus.internal.ModbusManagerImpl.invokeCallbackWithResponse(ModbusManagerImpl.java:247) ~[?:?]
	at org.openhab.io.transport.modbus.internal.ModbusManagerImpl.lambda$18(ModbusManagerImpl.java:556) ~[?:?]
	at java.util.Optional.ifPresent(Optional.java:159) ~[?:?]
	at org.openhab.io.transport.modbus.internal.ModbusManagerImpl.lambda$9(ModbusManagerImpl.java:556) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:?]
	at java.lang.Thread.run(Thread.java:745) [?:?]

(Ssalonen) #138

Thanks, I will revert with more comments next week.

Obviously you should not get crash as you did, so have to improve the error handling the very least (the reason for the crash is invalid configuration, but still)

I need to make sure the addressing is crystal clear (in the docs), and if it is wrong, a helpful message would be shown in paper ui.

EDIT:

I have now improved the error handling and fixed some bugs as well related how the data was extracted from the registers.

I tested with below config with no errors (see the comments for changes compared to your version):

    // type uint16 -> holding
	Bridge poller Nilan_Holding_Control [ start=1000, length=8, refresh=1002, type="holding" ] {
        // changes to data item:
        // 1. readValueType holding -> uint16
        // 2. writeValueType uint16 -> int16 (same thing when writing)
        // 3. absolute addresses (0 -> 1000, 1 -> 1001 etc.)
        // 4. writeMultipleEvenWithSingleRegister -> writeMultipleEvenWithSingleRegisterOrCoil
        // 5. "true" -> true (should be boolean)
	    Thing data Nilan_Holding_Control [ readStart="1000", readValueType="uint16", writeStart="1000", writeValueType="int16",writeType="holding", writeMultipleEvenWithSingleRegisterOrCoil=true ]
	    
	    Thing data Nilan_Control_RunSet [ readStart="1001", readValueType="uint16", writeStart="1001", writeValueType="int16",writeType="holding", writeMultipleEvenWithSingleRegisterOrCoil=true ]
	    
	    Thing data Nilan_Control_ModeSet [ readStart="1002", readValueType="uint16", writeStart="1002", writeValueType="int16",writeType="holding", writeMultipleEvenWithSingleRegisterOrCoil=true ]
	    
	    Thing data Nilan_Control_VentSet [ readStart="1003", readValueType="uint16", writeStart="1003", writeValueType="int16",writeType="holding", writeMultipleEvenWithSingleRegisterOrCoil=true ]

	    Thing data Nilan_Control_TempSet [ readStart="1004", readValueType="uint16", writeStart="1004", writeValueType="int16",writeType="holding", writeMultipleEvenWithSingleRegisterOrCoil=true ]
	    
	    Thing data Nilan_Control_ServiceMode [ readStart="1005", readValueType="uint16", writeStart="1005", writeValueType="int16",writeType="holding", writeMultipleEvenWithSingleRegisterOrCoil=true ]
	    
	    Thing data Nilan_Control_ServicePct [ readStart="1006", readValueType="uint16", writeStart="1006", writeValueType="int16",writeType="holding", writeMultipleEvenWithSingleRegisterOrCoil=true ]
	    
	    Thing data Nilan_Control_Preset [ readStart="1007", readValueType="uint16", writeStart="1007", writeValueType="int16",writeType="holding", writeMultipleEvenWithSingleRegisterOrCoil=true ] 
    } 

(Frederic Mariën) #139

Oh, I see, I must have already been half asleep yesterday evening :slight_smile:
The word “indexing” in “// Note the zero based indexing: first coil is index 0.” must have caused the confusion on my side.

I’ve fixed that but now I get another error and I don’t think it has something to do with the config.
I get this message:

2017-10-08 21:09:30.274 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Unhandled exception in callback: java.lang.IllegalArgumentException Index=16 with type=uint16 is out-of-bounds given registers of size 12
java.lang.IllegalArgumentException: Index=16 with type=uint16 is out-of-bounds given registers of size 12
	at org.openhab.io.transport.modbus.ModbusBitUtilities.extractStateFromRegisters(ModbusBitUtilities.java:88) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusDataThingHandler.onRegisters(ModbusDataThingHandler.java:445) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator.lambda$2(ModbusPollerThingHandlerImpl.java:66) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[?:?]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:?]
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[?:?]
	at java.util.Iterator.forEachRemaining(Iterator.java:116) ~[?:?]
	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator.forEachAllChildCallbacks(ModbusPollerThingHandlerImpl.java:61) ~[?:?]
	at org.openhab.binding.modbus.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator.onRegisters(ModbusPollerThingHandlerImpl.java:66) ~[?:?]
	at org.openhab.io.transport.modbus.internal.ModbusManagerImpl.invokeCallbackWithResponse(ModbusManagerImpl.java:252) ~[?:?]
	at org.openhab.io.transport.modbus.internal.ModbusManagerImpl.lambda$18(ModbusManagerImpl.java:559) ~[?:?]
	at java.util.Optional.ifPresent(Optional.java:159) ~[?:?]
	at org.openhab.io.transport.modbus.internal.ModbusManagerImpl.lambda$9(ModbusManagerImpl.java:559) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]

I don’t really see what the length of registers to read has to do with the parsing.
I’m reading holding registers but maybe they are parsed as coils?
My current config:

Bridge modbus:tcp:endpointTCP [ host="192.168.50.113", port=502, id=11, reconnectAfterMillis=300000 ] {
	Bridge poller ReadSection1 [ start=4000, length=12, refresh=10000, type="holding" ] {
		Thing data VE_DeviceType [ readStart="4001", readValueType="uint16" ]
		
		Thing data VE_DeviceVersion [ readStart="4003", readValueType="uint16" ]
		
		Thing data VE_OutsideTemperature [ readStart="4008", readValueType="uint16" ]
		
		Thing data VE_OutsideTemperature [ readStart="4009", readValueType="uint16" ]	
		
		Thing data VE_InletPressure [ readStart="4010", readValueType="uint16" ]
		
		Thing data VE_OutletPressure [ readStart="4011", readValueType="uint16" ]
		
	//	Thing data VE_Airflow [ readStart="4012", readValueType="uint16" ]
	}
}

EDIT: I’m using version 2.2.0.201710081505

Thanks for your help!

Greetings,
Frederic


(Ssalonen) #140

Before investigating further, could you please update to latest version and report the error?

Best
Sami

EDIT: @FredericMa Fixed some bugs related to this. I think it should work now with the latest version from today. Please try again and report if it works or still fails.


(Nanna Agesen) #141

HUGE thanks for your help, it works perfect :slight_smile:

I see I missed the change in writeMultipleEvenWithSingleRegisterOrCoil=true, and I understand the absolute addressing now - GREAT :slight_smile: