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._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,6 +321,7 @@ 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
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()
@ -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])