Modbus TCP Agent subtracts 1 from register address

Hi everyone,

I’m experiencing a strange issue with Modbus TCP Agent regarding register addressing.

According to the documentation, OpenRemote uses zero-based addressing. However, in my setup, when I set readAddress: 2000 for a holding register, the actual Modbus packet shows address 07 CF (1999):

00 01 00 00 00 06 03 03 **07 CF** 00 01

If I set readAddress: 2001 , the packet correctly shows 07 D0 (2000) and the device responds:

00 01 00 00 00 06 03 03 **07 D0** 00 01

So it seems OpenRemote subtracts 1 from whatever I enter.

My setup:

  • OpenRemote version: 1.19.0
  • Modbus TCP Agent
  • Attribute: HOLDING, UINT

Hi!

Great timing! @Berg has been busy with a refactor on the Modbus agent,
and it has been included in the latest 1.20.0 release that we published today :joy:
Not sure whether this issue you are having will be resolved by this,
but I think it’s definitely worth checking out!

Maybe @Berg has familiarity with this?

Yeah check out the new documentation, modbus has been revamped. Im not sure about the state back then but there might have been some inconsistensies in the docs. It is 1-based now.

Good afternoon @IkvEscad ,

Thanks for your post, and I completely agree, it was quite difficult for me to find a proper working method for dealing with register addressing. In the current version of the docs, you can find the second paragraph of the “Under the Hood” section:

Note on addressing: Remember that OpenRemote (and PLC4X) use zero-based addressing for Modbus. This is a common source of confusion. Always confirm whether your device documentation lists register addresses starting at 1 or 0, and adjust accordingly. For instance, if a device documentation refers to “Register 100” (but is zero-based internally), you might actually need to use 100 as is. However, if it refers to “Register 40001” (Modbus convention for first holding register), you should use 0. The OpenRemote Modbus agent ultimately converts your given address into the proper Modbus PDU address (e.g. address 0 will be sent as 0x0000 in the request).

That being said, it is strongly encouraged to move to the new implementation of Modbus, which should be released later today under version v.1.20.0.

Hope that helps!