+ newPos = int(line.split()[1])
+ # 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 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
+ elif self._state == self.STATE_PAUSED:
+ if 'ok' in line:
+ timeout = time.time() + 5
+ if not self._commandQueue.empty():
+ self._sendCommand(self._commandQueue.get())
+