Don't flood the printer with temperature requests while says it is busy

Fixes #3994
This commit is contained in:
fieldOfView 2018-10-05 12:56:40 +02:00
parent 88c19aa11d
commit cb24d58ab8

View file

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