From 8e2535f5b6d35ebd8c94fe65d57a99f7f9432022 Mon Sep 17 00:00:00 2001 From: jan iversen Date: Fri, 4 Oct 2024 19:40:49 +0200 Subject: [PATCH] remove zero_mode parameter. (#2354) --- API_changes.rst | 1 + doc/source/roadmap.rst | 3 ++- examples/server_async.py | 5 ----- pymodbus/datastore/context.py | 23 ++++------------------- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/API_changes.rst b/API_changes.rst index 0fb606cba..f95d8696f 100644 --- a/API_changes.rst +++ b/API_changes.rst @@ -4,6 +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/doc/source/roadmap.rst b/doc/source/roadmap.rst index 1c68232c9..b5557e735 100644 --- a/doc/source/roadmap.rst +++ b/doc/source/roadmap.rst @@ -18,12 +18,13 @@ The following bullet points are what the maintainers focus on: - 3.7.X, bug fix release, hopefully with: - Not planned - 3.8.0, with: + - on dev: + - skip_encode, zero_mode parameters removed - Simplify PDU classes - Simplify transaction manager (central control point) - Remove ModbusControlBlock - new transaction handling - transaction 100% coverage - - skip_encode, zero_mode parameters removed - 4.0.0, with: - client async with sync/async API - Only one datastore, but with different API`s diff --git a/examples/server_async.py b/examples/server_async.py index 433d70157..b11132edb 100755 --- a/examples/server_async.py +++ b/examples/server_async.py @@ -96,11 +96,6 @@ def setup_server(description=None, context=None, cmdline=None): # (broadcast mode). # However, this can be overloaded by setting the single flag to False and # then supplying a dictionary of slave id to context mapping:: - # - # The slave context can also be initialized in zero_mode which means - # that a request to address(0-7) will map to the address (0-7). - # The default is False which is based on section 4.4 of the - # specification, so address(0-7) will map to (1-8):: context = {} for slave in range(args.slaves): 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)