diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 36c5321180..fca0654d30 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -74,6 +74,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice): self._accepts_commands = True self._paused = False + self._printer_busy = False # when printer is preheating and waiting (M190/M109), or when waiting for action on the printer self._firmware_view = None self._firmware_location = None @@ -320,8 +321,9 @@ class USBPrinterOutputDevice(PrinterOutputDevice): # Timeout, or no request has been sent at all. self._command_received.set() # We haven't really received the ok, but we need to send a new command - self.sendCommand("M105") - self._last_temperature_request = time() + if not self._printer_busy: # don't flood the printer with temperature requests while it is busy + self.sendCommand("M105") + self._last_temperature_request = time() if self._firmware_name is None: self.sendCommand("M115") @@ -360,7 +362,9 @@ class USBPrinterOutputDevice(PrinterOutputDevice): if b"FIRMWARE_NAME:" in line: self._setFirmwareName(line) - if b"ok" in line: + if line.startswith(b"ok "): + self._printer_busy = False + self._command_received.set() if not self._command_queue.empty(): self._sendCommand(self._command_queue.get()) @@ -370,16 +374,19 @@ class USBPrinterOutputDevice(PrinterOutputDevice): else: self._sendNextGcodeLine() + if line.startswith(b"echo:busy: "): + self._printer_busy = True + if self._is_printing: if line.startswith(b'!!'): Logger.log('e', "Printer signals fatal error. Cancelling print. {}".format(line)) self.cancelPrint() - elif b"resend" in line.lower() or b"rs" in line: + elif line.lower().startswith(b"resend") or line.startswith(b"rs"): # A resend can be requested either by Resend, resend or rs. try: self._gcode_position = int(line.replace(b"N:", b" ").replace(b"N", b" ").replace(b":", b" ").split()[-1]) except: - if b"rs" in line: + if line.startswith(b"rs"): # In some cases of the RS command it needs to be handled differently. self._gcode_position = int(line.split()[1])