From 9f89bff0e78dcc72c799c745c4a74949354a2862 Mon Sep 17 00:00:00 2001 From: Stuart Longland Date: Wed, 21 Oct 2015 10:41:55 +1000 Subject: [PATCH] ModbusSerialClient: Initialise new fields. 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. --- pymodbus/client/sync.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pymodbus/client/sync.py b/pymodbus/client/sync.py index d6486bffe..c9e601c10 100644 --- a/pymodbus/client/sync.py +++ b/pymodbus/client/sync.py @@ -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): @@ -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):