Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe zero_mode in ModbusSlaveContext.__init__ #2187

Merged
merged 1 commit into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions pymodbus/datastore/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,29 @@ def setValues(self, fc_as_hex: int, address: int, values: list[int | bool]) -> N
# Slave Contexts
# ---------------------------------------------------------------------------#
class ModbusSlaveContext(ModbusBaseSlaveContext):
"""This creates a modbus data model with each data access stored in a block."""
"""
Create a modbus data model with each data access stored in a
block.

:param di: discrete inputs initializer ModbusDataBlock
:param co: coils initializer ModbusDataBlock
:param hr: holding register initializer ModbusDataBlock
:param ir: input registers initializer ModbusDataBlock
:param zero_mode: Not add one to address

When True, a request for address zero to n will map to
datastore address zero to n.

When False, a request for address zero to n will map to
datastore address one to n+1, based on section 4.4 of
specification.

Default is False.
"""

def __init__(self, *_args, **kwargs):
"""Initialize the datastores.

:param kwargs: Each element is a ModbusDataBlock

"di" - Discrete Inputs initializer
"co" - Coils initializer
"hr" - Holding Register initializer
"ir" - Input Registers iniatializer
"""
self.store = {}
self.store["d"] = kwargs.get("di", ModbusSequentialDataBlock.create())
Expand Down