diff --git a/tests/gcodeSender.py b/tests/gcodeSender.py index 376dc4e17..a7d2093fd 100755 --- a/tests/gcodeSender.py +++ b/tests/gcodeSender.py @@ -90,6 +90,8 @@ if args.errors: print() -proto = MarlinSerialProtocol(sio) +def onResendCallback(line): + print("Resending from: %d" % (line)) +proto = MarlinSerialProtocol(sio, onResendCallback) send_gcode_test(args.filename, proto) proto.close() \ No newline at end of file diff --git a/tests/pyMarlin/marlinSerialProtocol.py b/tests/pyMarlin/marlinSerialProtocol.py index 245d75e2c..9b4522608 100644 --- a/tests/pyMarlin/marlinSerialProtocol.py +++ b/tests/pyMarlin/marlinSerialProtocol.py @@ -82,7 +82,7 @@ class MarlinSerialProtocol: """This class implements the Marlin serial protocol, such as adding a checksum to each line, replying to resend requests and keeping the Marlin buffer full""" - def __init__(self, serial): + def __init__(self, serial, onResendCallback=None): self.serial = serial self.marlinBufSize = 4 self.marlinReserve = 1 @@ -91,6 +91,7 @@ class MarlinSerialProtocol: self.slow_commands = re.compile(b"M109|M190|G28|G29") self.slow_timeout = 400 self.fast_timeout = 15 + self.onResendCallback = onResendCallback self.restart() def _stripCommentsAndWhitespace(self, str): @@ -175,6 +176,8 @@ class MarlinSerialProtocol: self.history.rewindTo(position) self.pendingOk = 0 self.consecutiveOk = 0 + if self.onResendCallback: + self.onResendCallback(position) def _flushReadBuffer(self): while self.serial.readline() != b"":