Skip to content

Commit

Permalink
Describe zero_mode in ModbusSlaveContext.__init__ (#2187)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron-sso authored and janiversen committed Jun 18, 2024
1 parent 31bb326 commit 4057780
Showing 1 changed file with 19 additions and 7 deletions.
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

0 comments on commit 4057780

Please sign in to comment.