diff --git a/pymodbus/payload.py b/pymodbus/payload.py index 2c6eb98027..b6ec8e1cb7 100644 --- a/pymodbus/payload.py +++ b/pymodbus/payload.py @@ -330,9 +330,6 @@ def _unpack_words(self, handle) -> bytes: # Change Word order if little endian word order # # Pack values back based on correct byte order # # ---------------------------------------------- # - - :param handle: Value to be unpacked - :return: """ if Endian.LITTLE in {self._byteorder, self._wordorder}: handle = array("H", handle) diff --git a/pymodbus/transaction.py b/pymodbus/transaction.py index a7fad3d7b5..6a4f275fa9 100644 --- a/pymodbus/transaction.py +++ b/pymodbus/transaction.py @@ -41,9 +41,18 @@ # The Global Transaction Manager # --------------------------------------------------------------------------- # class ModbusTransactionManager: - """Implement a transaction for a manager. + """Implement a transaction manager. - Results are keyed based on the supplied transaction id. + Only 1 request can be active at any time, the reasoning being: + + - of the 4 official framer types only socket support transactions + - Only few devices with tcp/ip accept multiple transactions + - majority of these devices simply queue the requests, no parallel execution + + So in total it is a very low percentage that would benefit from a proper transaction handler, + meaning it does not make sense to support it. + + The transaction manager support multiple client requests with automatic queing! """ def __init__(self): @@ -136,7 +145,7 @@ class SyncModbusTransactionManager(ModbusTransactionManager): def __init__(self, client: ModbusBaseSyncClient, retries): """Initialize an instance of the ModbusTransactionManager.""" super().__init__() - self.client: ModbusBaseSyncClient = client + self.client = client self.retries = retries self._transaction_lock = RLock() self._no_response_devices: list[int] = [] @@ -146,6 +155,7 @@ def __init__(self, client: ModbusBaseSyncClient, retries): def _set_adu_size(self): """Set adu size.""" # base ADU size of modbus frame in bytes + if isinstance(self.client.framer, ModbusSocketFramer): self.base_adu_size = 7 # tid(2), pid(2), length(2), uid(1) elif isinstance(self.client.framer, ModbusRtuFramer):