From f7886627b99e57bb4d34f17afc6c9e00c397037c Mon Sep 17 00:00:00 2001 From: jan iversen Date: Fri, 4 Oct 2024 19:24:29 +0200 Subject: [PATCH] ModbusSlaveContext, remove zero_mode parameter. --- API_changes.rst | 3 +-- pymodbus/datastore/context.py | 23 ++++------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/API_changes.rst b/API_changes.rst index cc19c8bde..f95d8696f 100644 --- a/API_changes.rst +++ b/API_changes.rst @@ -4,8 +4,7 @@ Versions (X.Y.Z) where Z > 0 e.g. 3.0.1 do NOT have API changes! API changes 3.8.0 ----------------- - - +- ModbusSlaveContext, remove zero_mode parameter. API changes 3.7.0 diff --git a/pymodbus/datastore/context.py b/pymodbus/datastore/context.py index ea76b7ffa..a46a8ca20 100644 --- a/pymodbus/datastore/context.py +++ b/pymodbus/datastore/context.py @@ -79,17 +79,6 @@ class ModbusSlaveContext(ModbusBaseSlaveContext): :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, @@ -97,14 +86,13 @@ def __init__(self, *_args, co=ModbusSequentialDataBlock.create(), ir=ModbusSequentialDataBlock.create(), hr=ModbusSequentialDataBlock.create(), - zero_mode=False): + ): """Initialize the datastores.""" self.store = {} self.store["d"] = di self.store["c"] = co self.store["i"] = ir self.store["h"] = hr - self.zero_mode = zero_mode def __str__(self): """Return a string representation of the context. @@ -126,8 +114,7 @@ def validate(self, fc_as_hex, address, count=1): :param count: The number of values to test :returns: True if the request in within range, False otherwise """ - if not self.zero_mode: - address += 1 + address += 1 Log.debug("validate: fc-[{}] address-{}: count-{}", fc_as_hex, address, count) return self.store[self.decode(fc_as_hex)].validate(address, count) @@ -139,8 +126,7 @@ def getValues(self, fc_as_hex, address, count=1): :param count: The number of values to retrieve :returns: The requested values from a:a+c """ - if not self.zero_mode: - address += 1 + address += 1 Log.debug("getValues: fc-[{}] address-{}: count-{}", fc_as_hex, address, count) return self.store[self.decode(fc_as_hex)].getValues(address, count) @@ -151,8 +137,7 @@ def setValues(self, fc_as_hex, address, values): :param address: The starting address :param values: The new values to be set """ - if not self.zero_mode: - address += 1 + address += 1 Log.debug("setValues[{}] address-{}: count-{}", fc_as_hex, address, len(values)) self.store[self.decode(fc_as_hex)].setValues(address, values)