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
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:'):
# 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