Skip to content

Commit

Permalink
ModbusSerialClient: Initialise new fields.
Browse files Browse the repository at this point in the history
Not initialising _last_frame_end and _silent_interval breaks test cases.
We'll initialise _last_frame_end to 0.0 (to indicate the last frame is
possibly a *long* time ago, connect resets it) and we set
_silent_interval there since baud rate should not be changing.
  • Loading branch information
sjlongland authored and Cougar committed Dec 6, 2015
1 parent 2d3ab38 commit cd39f62
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pymodbus/client/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ 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._last_frame_end = 0.0
self._silent_interval = 3.5 * (1 + 8 + 2) / self.baudrate

@staticmethod
def __implementation(method):
Expand Down Expand Up @@ -324,7 +326,6 @@ def connect(self):
_logger.error(msg)
self.close()
self._last_frame_end = time.time()
self._silent_interval = 3.5 * (1 + 8 + 2) / self.baudrate
return self.socket != None

def close(self):
Expand Down

0 comments on commit cd39f62

Please sign in to comment.