diff --git a/doc/source/_static/examples.tgz b/doc/source/_static/examples.tgz index fe1e85615..15011cffd 100644 Binary files a/doc/source/_static/examples.tgz and b/doc/source/_static/examples.tgz differ diff --git a/doc/source/_static/examples.zip b/doc/source/_static/examples.zip index 028a2ff58..e36607852 100644 Binary files a/doc/source/_static/examples.zip and b/doc/source/_static/examples.zip differ diff --git a/doc/source/client.rst b/doc/source/client.rst index ec71e15b9..ae4a8404e 100644 --- a/doc/source/client.rst +++ b/doc/source/client.rst @@ -55,9 +55,9 @@ Pymodbus offers clients with transport different protocols and different framers - ASCII - RTU - RTU_OVER_TCP - - Socket + - SOCKET - TLS - * - Serial (RS-485) + * - SERIAL (RS-485) - Yes - Yes - No @@ -248,6 +248,20 @@ There are a client class for each type of communication and for asynchronous/syn - :mod:`AsyncModbusUdpClient` - :mod:`ModbusUdpClient` +Client common +^^^^^^^^^^^^^ +Some methods are common to all client: + +.. autoclass:: pymodbus.client.base.ModbusBaseClient + :members: + :member-order: bysource + :show-inheritance: + +.. autoclass:: pymodbus.client.base.ModbusBaseSyncClient + :members: + :member-order: bysource + :show-inheritance: + Client serial ^^^^^^^^^^^^^ .. autoclass:: pymodbus.client.AsyncModbusSerialClient diff --git a/pymodbus/client/base.py b/pymodbus/client/base.py index 26d7871b8..9123381fa 100644 --- a/pymodbus/client/base.py +++ b/pymodbus/client/base.py @@ -32,7 +32,10 @@ def __init__( on_connect_callback: Callable[[bool], None] | None, comm_params: CommParams | None = None, ) -> None: - """Initialize a client instance.""" + """Initialize a client instance. + + :meta private: + """ ModbusClientMixin.__init__(self) # type: ignore[arg-type] if comm_params: self.comm_params = comm_params @@ -99,13 +102,18 @@ def execute(self, request: ModbusRequest): :param request: The request to process :returns: The result of the request execution :raises ConnectionException: Check exception text. + + :meta private: """ if not self.ctx.transport: raise ConnectionException(f"Not connected[{self!s}]") return self.async_execute(request) async def async_execute(self, request) -> ModbusResponse: - """Execute requests asynchronously.""" + """Execute requests asynchronously. + + :meta private: + """ request.transaction_id = self.ctx.transaction.getNextTID() packet = self.ctx.framer.buildPacket(request) @@ -134,7 +142,10 @@ async def async_execute(self, request) -> ModbusResponse: return resp # type: ignore[return-value] def build_response(self, request: ModbusRequest): - """Return a deferred response for the current request.""" + """Return a deferred response for the current request. + + :meta private: + """ my_future: asyncio.Future = asyncio.Future() request.fut = my_future if not self.ctx.transport: @@ -179,7 +190,10 @@ def __init__( retries: int, comm_params: CommParams | None = None, ) -> None: - """Initialize a client instance.""" + """Initialize a client instance. + + :meta private: + """ ModbusClientMixin.__init__(self) # type: ignore[arg-type] if comm_params: self.comm_params = comm_params @@ -205,7 +219,7 @@ def __init__( # Client external interface # ----------------------------------------------------------------------- # def register(self, custom_response_class: ModbusResponse) -> None: - """Register a custom response class with the decoder (call **sync**). + """Register a custom response class with the decoder. :param custom_response_class: (optional) Modbus response class. :raises MessageRegisterException: Check exception text. @@ -231,6 +245,8 @@ def execute(self, request: ModbusRequest) -> ModbusResponse: :param request: The request to process :returns: The result of the request execution :raises ConnectionException: Check exception text. + + :meta private: """ if not self.connect(): raise ConnectionException(f"Failed to connect[{self!s}]") @@ -264,7 +280,10 @@ def recv(self, size: int | None) -> bytes: @classmethod def get_address_family(cls, address): - """Get the correct address family.""" + """Get the correct address family. + + :meta private: + """ try: _ = socket.inet_pton(socket.AF_INET6, address) except OSError: # not a valid ipv6 address