Added notification when resend occurs.

master
Marcio Teixeira 7 years ago
parent 258e128116
commit da59175d1c

@ -90,6 +90,8 @@ if args.errors:
print() print()
proto = MarlinSerialProtocol(sio) def onResendCallback(line):
print("Resending from: %d" % (line))
proto = MarlinSerialProtocol(sio, onResendCallback)
send_gcode_test(args.filename, proto) send_gcode_test(args.filename, proto)
proto.close() proto.close()

@ -82,7 +82,7 @@ class MarlinSerialProtocol:
"""This class implements the Marlin serial protocol, such """This class implements the Marlin serial protocol, such
as adding a checksum to each line, replying to resend as adding a checksum to each line, replying to resend
requests and keeping the Marlin buffer full""" requests and keeping the Marlin buffer full"""
def __init__(self, serial): def __init__(self, serial, onResendCallback=None):
self.serial = serial self.serial = serial
self.marlinBufSize = 4 self.marlinBufSize = 4
self.marlinReserve = 1 self.marlinReserve = 1
@ -91,6 +91,7 @@ class MarlinSerialProtocol:
self.slow_commands = re.compile(b"M109|M190|G28|G29") self.slow_commands = re.compile(b"M109|M190|G28|G29")
self.slow_timeout = 400 self.slow_timeout = 400
self.fast_timeout = 15 self.fast_timeout = 15
self.onResendCallback = onResendCallback
self.restart() self.restart()
def _stripCommentsAndWhitespace(self, str): def _stripCommentsAndWhitespace(self, str):
@ -175,6 +176,8 @@ class MarlinSerialProtocol:
self.history.rewindTo(position) self.history.rewindTo(position)
self.pendingOk = 0 self.pendingOk = 0
self.consecutiveOk = 0 self.consecutiveOk = 0
if self.onResendCallback:
self.onResendCallback(position)
def _flushReadBuffer(self): def _flushReadBuffer(self):
while self.serial.readline() != b"": while self.serial.readline() != b"":

Loading…
Cancel
Save