From 88153fdd60334462b999ac3459a60e70c6e236b7 Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Tue, 11 Aug 2015 12:54:38 -0400 Subject: [PATCH] Cancel resend if firmware asks for line 1 or more than 100 lines before current This is because it seems when we use a heat-and-wait command (possibly), there is a risk of getting a checksum error and resend. That could happen for more than the 10 lines we had set previously, so setting it to 100 sounds like a safer value. We also check for position 1 because if the error happens in the first 100 lines, it would be missed. We're also printing a message to the console when that happens. Fixes T178 --- Cura/util/machineCom.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Cura/util/machineCom.py b/Cura/util/machineCom.py index 9a516b61..3f98d5dd 100644 --- a/Cura/util/machineCom.py +++ b/Cura/util/machineCom.py @@ -364,7 +364,7 @@ class MachineCom(object): line = self._readline() if line is None: break - + #No matter the state, if we see an fatal error, goto the error state and store the error for reference. # Only goto error on known fatal errors. if line.startswith('Error:'): @@ -496,7 +496,8 @@ class MachineCom(object): # If we need to resend more than 10 lines, we can assume that the machine # was shut down and turned back on or something else that's weird just happened. # In that case, it can be dangerous to restart the print, so we'd better kill it - if self._gcodePos > newPos + 10: + if newPos == 1 or self._gcodePos > newPos + 100: + self._callback.mcMessage(_("Print canceled due to loss of communication to printer (USB unplugged or power lost)")) self.cancelPrint() else: self._gcodePos = newPos -- 2.30.2