Skip to content

Commit 5020655

Browse files
sjlonglandCougar
authored andcommitted
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.
1 parent 74e15ea commit 5020655

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pymodbus/client/sync.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ def __init__(self, method='ascii', **kwargs):
304304
self.parity = kwargs.get('parity', Defaults.Parity)
305305
self.baudrate = kwargs.get('baudrate', Defaults.Baudrate)
306306
self.timeout = kwargs.get('timeout', Defaults.Timeout)
307+
self._last_frame_end = 0.0
308+
self._silent_interval = 3.5 * (1 + 8 + 2) / self.baudrate
307309

308310
@staticmethod
309311
def __implementation(method):
@@ -333,7 +335,6 @@ def connect(self):
333335
_logger.error(msg)
334336
self.close()
335337
self._last_frame_end = time.time()
336-
self._silent_interval = 3.5 * (1 + 8 + 2) / self.baudrate
337338
return self.socket != None
338339

339340
def close(self):

0 commit comments

Comments
 (0)