Skip to content

Commit

Permalink
Merge pull request pymodbus-dev#355 from riptideio/pymodbus-dev#353-E…
Browse files Browse the repository at this point in the history
…rror-Reading-Registers

pymodbus-dev#353 error reading registers
  • Loading branch information
dhoomakethu authored Oct 23, 2018
2 parents 05afbb0 + c0a2359 commit aef3e0a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 6 additions & 0 deletions examples/common/synchronous_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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::
#
Expand Down
6 changes: 5 additions & 1 deletion pymodbus/client/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pymodbus/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aef3e0a

Please sign in to comment.