chiark / gitweb /
Cancel resend if firmware asks for line 1 or more than 100 lines before current
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Tue, 11 Aug 2015 16:54:38 +0000 (12:54 -0400)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Tue, 11 Aug 2015 16:57:07 +0000 (12:57 -0400)
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

index 9a516b61bc0d1f178bc79b06875edad30160462c..3f98d5dd619442fcb9b56a7d4605832f34da9c0d 100644 (file)
@@ -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