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 committed Oct 21, 2015
1 parent 76ad691 commit 9f89bff
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 @@ -304,6 +304,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 @@ -333,7 +335,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 9f89bff

Please sign in to comment.