From d00a8cdd3c9486b9bfa221a0c760f193b5765e42 Mon Sep 17 00:00:00 2001 From: dhoomakethu Date: Tue, 16 Oct 2018 18:42:43 +0530 Subject: [PATCH 1/3] #353 - debugging, Add debug logs to check size of avaialble data in read buffer --- pymodbus/client/sync.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pymodbus/client/sync.py b/pymodbus/client/sync.py index abfd724e0..b5fe44210 100644 --- a/pymodbus/client/sync.py +++ b/pymodbus/client/sync.py @@ -534,6 +534,7 @@ def _wait_for_data(self): start = time.time() while condition(start): avaialble = self._in_waiting() + _logger.debug("Available in read buffer - {}".format(avaialble)) if (more_data and not avaialble) or (more_data and avaialble == size): break if avaialble and avaialble != size: From e85057a2af0cbfaf2119ab7cdb4a9026b5f184a7 Mon Sep 17 00:00:00 2001 From: dhoomakethu Date: Wed, 17 Oct 2018 13:53:05 +0530 Subject: [PATCH 2/3] #353 Provide an option to disable inter char timeouts --- examples/common/synchronous_client.py | 6 ++++++ pymodbus/client/sync.py | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) 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 b5fe44210..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 @@ -534,7 +538,6 @@ def _wait_for_data(self): start = time.time() while condition(start): avaialble = self._in_waiting() - _logger.debug("Available in read buffer - {}".format(avaialble)) if (more_data and not avaialble) or (more_data and avaialble == size): break if avaialble and avaialble != size: From c0a235958a674964ab1bdbbcbfcc82196b47e64a Mon Sep 17 00:00:00 2001 From: dhoomakethu Date: Thu, 18 Oct 2018 12:16:30 +0530 Subject: [PATCH 3/3] #353 Bump version, update changelog --- CHANGELOG.rst | 4 ++++ pymodbus/version.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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/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