Modbus V2 8.0.6 RC1 zero based addressing

in the release notes for 8.0.6 RC1 there is:

Converted the One-Based Addressing setting in Modbus devices to Zero-Based Addressing.

Would it be possible to get some clarification on this? All Modbus devices need to have this setting inverted after the update?

edit: found this identifying it as a bug [Bug-15335]Zero-Based Addressing

I just want to give anyone else an updated about what we’ve found so far:

the new setting should be called “zero based addressing”. out of ~6 servers we’ve installed this updated on, 2 of them showed the new name in the gateway under a modbus tcp device. The rest still show “one based addressing”.

Most of the devices continued to work after the update, but many did not. toggling the setting and saving fixed it.

On some of the devices that kept on working (exact same type of end device) we noticed the setting was still True, even though it should have been false to match the other ones that we got working. Changing the setting to false, and saving, let the device continue getting correct data. Changing the setting back to True however, caused it to stop working. It seems as though the setting being displayed to the user on the gateway, is not the setting it actually has configured.

We’ve also found that rebooting a server caused working devices to stop working, and we had to go and change the settings to get it working.

We also found that on some devices, we had to toggle the span gaps setting to get things working again.

Was this setting called zero-based addressing again at some point in the past? We have that as the setting in some of our modbus configuration tables.

So, some backstory - hopefully this helps clarify behavior.
First, for context:
The setting has always been called ‘zero based addressing’ internally - so the column in the internal DB is zero based addressing, the internal Java classes refer to it as zero based addressing, the system.device.addDevice function called it zeroBasedAddressing, etc. So, we wanted to “fix” the behavior of the setting to align with what the code actually expects.

The actual changes made internally in that referenced changelog did, basically three things:

  1. Changed the appearance of the setting from ‘One Based Addressing’ to ‘Zero Based Addressing’.
  2. Toggled all existing settings on upgrade - so if you had the ‘One Based Addressing’ setting one way, it would be switched to ‘Zero Based Addressing’ (that is, the value of the record in the internal db would be flipped) [1]
  3. Change the behavior of the actual drivers to use the new setting correctly - even though it’s always been called “zero based addressing” in our code, the drivers were using the setting as one-based addressing (hence, that’s what we displayed to you as a user).

So, what’s the deal, and why is stuff acting so weird?
Well, footnote 1 on item 2 is essentially: On the first gateway startup, any existing modbus drivers would start before the change was made to the internal database. As a result, any Modbus connections would have the old setting value, but the new behavior - resulting in things not working.
Any change that made the driver restart, without changing the setting values (edit -> save with no changes, or restarting the modbus driver, or restarting the entire gateway) would get your devices back into a working state. Changing the setting manually should never be necessary.

The other complication here is that ‘rolling back’ to 8.0.5, if your gateway backup was upgraded to 8.0.6RC1, will not get things working, because the setting value in all your modbus drivers will still have been flipped.

The good news is that since someone else already ran into this and reported it, I’ve already got a fix up and it’ll be in 8.0.6 final - basically, the logic to upgrade the setting runs immediately on module startup, before any drivers have started, now.

2 Likes

damn thank you for this informative and clear explanation!

Is that going to fix the addDevice scripting function to set the ZeroBasedAddressing correctly?

deviceProps = {}
deviceProps["hostname"] = "192.168.1.2"
deviceProps["zeroBasedAddressing"] = False
system.device.addDevice(deviceName="TestZeroBasedFalse", deviceType="ModbusTcp", deviceProps=deviceProps)
1 Like