diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4053b2bfd..4b61313ff 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,7 @@ +Version 2.1.1 +----------------------------------------------------------- +* Provide an option to disable inter char timeouts with Modbus RTU. + Version 2.1.0 ----------------------------------------------------------- * Fix Issues with Serial client where in partial data was read when the response size is unknown. diff --git a/examples/common/synchronous_client.py b/examples/common/synchronous_client.py index b21f4f77a..482b221f3 100755 --- a/examples/common/synchronous_client.py +++ b/examples/common/synchronous_client.py @@ -56,6 +56,12 @@ def run_sync_client(): # * retries - Specify how many retries to allow per transaction (default=3) # * retry_on_empty - Is an empty response a retry (default = False) # * source_address - Specifies the TCP source address to bind to + # * strict - Applicable only for Modbus RTU clients. + # Adheres to modbus protocol for timing restrictions + # (default = True). + # Setting this to False would disable the inter char timeout + # restriction (t1.5) for Modbus RTU + # # # Here is an example of using these options:: # diff --git a/pymodbus/client/sync.py b/pymodbus/client/sync.py index abfd724e0..01ca0fcbe 100644 --- a/pymodbus/client/sync.py +++ b/pymodbus/client/sync.py @@ -415,6 +415,8 @@ def __init__(self, method='ascii', **kwargs): :param parity: Which kind of parity to use :param baudrate: The baud rate to use for the serial device :param timeout: The timeout between serial requests (default 3s) + :param strict: Use Inter char timeout for baudrates <= 19200 (adhere + to modbus standards) """ self.method = method self.socket = None @@ -427,6 +429,7 @@ def __init__(self, method='ascii', **kwargs): self.parity = kwargs.get('parity', Defaults.Parity) self.baudrate = kwargs.get('baudrate', Defaults.Baudrate) self.timeout = kwargs.get('timeout', Defaults.Timeout) + self._strict = kwargs.get("strict", True) self.last_frame_end = None if self.method == "rtu": if self.baudrate > 19200: @@ -473,7 +476,8 @@ def connect(self): _logger.error(msg) self.close() if self.method == "rtu": - self.socket.interCharTimeout = self.inter_char_timeout + if self._strict: + self.socket.interCharTimeout = self.inter_char_timeout self.last_frame_end = None return self.socket is not None diff --git a/pymodbus/version.py b/pymodbus/version.py index 7a997315e..1e8057b9b 100644 --- a/pymodbus/version.py +++ b/pymodbus/version.py @@ -41,7 +41,7 @@ def __str__(self): return '[%s, version %s]' % (self.package, self.short()) -version = Version('pymodbus', 2, 1, 0) +version = Version('pymodbus', 2, 1, 1) version.__name__ = 'pymodbus' # fix epydoc error