From cd39f6232bdccae295b3a5f51d0c427ee04f2304 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 4dc6133a49..5cc8f8d4d0 100644 --- a/pymodbus/client/sync.py +++ b/pymodbus/client/sync.py @@ -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): @@ -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):