Skip to content

Fix incorrect order of simdata tuple for SimDevice instantiation in ModbusDeviceContext.__init__#2952

Merged
janiversen merged 1 commit into
pymodbus-dev:devfrom
km-64:bugfix/use-correct-tuple-order-in-simdata-constructor
Jul 2, 2026
Merged

Fix incorrect order of simdata tuple for SimDevice instantiation in ModbusDeviceContext.__init__#2952
janiversen merged 1 commit into
pymodbus-dev:devfrom
km-64:bugfix/use-correct-tuple-order-in-simdata-constructor

Conversation

@km-64

@km-64 km-64 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The call to the constructor for SimData inside ModbusDeviceContext introduced in #2897 appears to have an incorrect tuple order for the simdata argument. This causes input registers to be swapped with holding registers in versions 3.13.0.

self.simdevice = SimDevice(
0, simdata=(co_simdata, di_simdata, ir_simdata, hr_simdata)
)

Referring to the docs the last two elements should be holding registers followed by input registers.

The tuple is defined as:
(<coils>, <discrete inputs>, <holding registers>, <input registers>)

-- https://pymodbus.readthedocs.io/en/latest/source/simulator/datamodel.html#pymodbus.simulator.SimDevice.simdata

…ctor

hr_simdata and ir_simdata should be swapped to match the documentation
in SimDevice for the simdevice attribute:

The tuple is defined as:
(<coils>, <discrete inputs>, <holding registers>, <input registers>)
@km-64 km-64 changed the title Fix incorrect order for SimData instantiation in ModbusDeviceContext.__init__ Fix incorrect order of simdata tuple for SimDevice instantiation in ModbusDeviceContext.__init__ Jul 1, 2026

@janiversen janiversen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@janiversen janiversen merged commit 7c5621b into pymodbus-dev:dev Jul 2, 2026
18 checks passed
@km-64 km-64 deleted the bugfix/use-correct-tuple-order-in-simdata-constructor branch July 2, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants