From 09208ecf443e21da55b98bcab394ad21753e240c Mon Sep 17 00:00:00 2001 From: Michel F <80367602+MrWaloo@users.noreply.github.com> Date: Sat, 25 Jan 2025 14:36:17 +0100 Subject: [PATCH 1/2] Typo arround `no_response_expected` Documentation typo and advanced modbus message call example. No breaking change, only cosmetic. --- doc/source/client.rst | 10 +++++----- pymodbus/client/mixin.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/source/client.rst b/doc/source/client.rst index 99d115c1a..1ac217a22 100644 --- a/doc/source/client.rst +++ b/doc/source/client.rst @@ -199,12 +199,12 @@ The logical devices represented by the device is addressed with the :mod:`slave= With **Serial**, the comm port is defined when creating the object. The physical devices are addressed with the :mod:`slave=` parameter. -:mod:`slave=0` is defined as broadcast in the modbus standard, but pymodbus treats is a normal device. +:mod:`slave=0` is defined as broadcast in the modbus standard, but pymodbus treats it as a normal device. If an application is expecting multiple responses to a broadcast request, it must call :mod:`client.execute` and deal with the responses. If no response is expected to a request, the :mod:`no_response_expected=True` argument can be used -in the normal API calls, this will cause the call to return imidiatble with :mod:`None` +in the normal API calls, this will cause the call to return immediately with :mod:`None`. Client response handling @@ -224,7 +224,7 @@ The application should evaluate the result generically:: raise ModbusException(txt) :mod:`except ModbusException as exc:` happens generally when pymodbus experiences an internal error. -There are a few situation where a unexpected response from a device can cause an exception. +There are a few situation where an unexpected response from a device can cause an exception. :mod:`rr.isError()` is set whenever the device reports a problem. @@ -257,7 +257,7 @@ There are a client class for each type of communication and for asynchronous/syn Client common ^^^^^^^^^^^^^ -Some methods are common to all client: +Some methods are common to all clients: .. autoclass:: pymodbus.client.base.ModbusBaseClient :members: @@ -323,7 +323,7 @@ Modbus calls Pymodbus makes all standard modbus requests/responses available as simple calls. -Using ModbusClient.register() custom messagees can be added to pymodbus, +Using ModbusClient.register() custom messages can be added to pymodbus, and handled automatically. .. autoclass:: pymodbus.client.mixin.ModbusClientMixin diff --git a/pymodbus/client/mixin.py b/pymodbus/client/mixin.py index 9ed5c0928..2fa02da5a 100644 --- a/pymodbus/client/mixin.py +++ b/pymodbus/client/mixin.py @@ -37,10 +37,10 @@ class ModbusClientMixin(Generic[T]): # pylint: disable=too-many-public-methods Advanced modbus message call:: request = ReadCoilsRequest(1,10) - response = client.execute(request) + response = client.execute(no_response_expected=False, request=request) # or request = ReadCoilsRequest(1,10) - response = await client.execute(request) + response = await client.execute(no_response_expected=False, request=request) .. tip:: All methods can be used directly (synchronous) or @@ -51,7 +51,7 @@ def __init__(self): """Initialize.""" @abstractmethod - def execute(self, no_response_expected: bool, request: ModbusPDU,) -> T: + def execute(self, no_response_expected: bool, request: ModbusPDU) -> T: """Execute request.""" def read_coils(self, address: int, *, count: int = 1, slave: int = 1, no_response_expected: bool = False) -> T: From a7dc5aa5772f4beb760a3cadacb0af90a2806e4a Mon Sep 17 00:00:00 2001 From: Michel F <80367602+MrWaloo@users.noreply.github.com> Date: Sat, 25 Jan 2025 21:13:54 +0100 Subject: [PATCH 2/2] Update mixin.py --- pymodbus/client/mixin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymodbus/client/mixin.py b/pymodbus/client/mixin.py index 2fa02da5a..12c544d6c 100644 --- a/pymodbus/client/mixin.py +++ b/pymodbus/client/mixin.py @@ -37,10 +37,10 @@ class ModbusClientMixin(Generic[T]): # pylint: disable=too-many-public-methods Advanced modbus message call:: request = ReadCoilsRequest(1,10) - response = client.execute(no_response_expected=False, request=request) + response = client.execute(False, request) # or request = ReadCoilsRequest(1,10) - response = await client.execute(no_response_expected=False, request=request) + response = await client.execute(False, request) .. tip:: All methods can be used directly (synchronous) or