From 6bf91d2b3a2ea71c7bbf6869057ad5616280df97 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Fri, 14 Sep 2018 13:59:05 +0200 Subject: [PATCH 1/2] Fix updating temperature while preheating bed or extruder While preheating the bed/extruder with M190 or M109, the firmware keeps outputting temperature lines, but these do not contain "ok" because no new command was acknowledged. Fixes #3741 --- plugins/USBPrinting/USBPrinterOutputDevice.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 4ceda52875..39b358224c 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -313,6 +313,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice): while self._connection_state == ConnectionState.connected and self._serial is not None: try: line = self._serial.readline() + print(line) except: continue @@ -326,8 +327,8 @@ class USBPrinterOutputDevice(PrinterOutputDevice): if self._firmware_name is None: self.sendCommand("M115") - if (b"ok " in line and b"T:" in line) or line.startswith(b"T:") or b"ok B:" in line or line.startswith(b"B:"): # Temperature message. 'T:' for extruder and 'B:' for bed - extruder_temperature_matches = re.findall(b"T(\d*): ?([\d\.]+) ?\/?([\d\.]+)?", line) + if re.search(b"[B|T\d*]: ?\d+\.?\d*", line): # Temperature message. 'T:' for extruder and 'B:' for bed + extruder_temperature_matches = re.findall(b"T(\d*): ?(\d+\.?\d*) ?\/?(\d+\.?\d*)?", line) # Update all temperature values matched_extruder_nrs = [] for match in extruder_temperature_matches: @@ -349,7 +350,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice): if match[2]: extruder.updateTargetHotendTemperature(float(match[2])) - bed_temperature_matches = re.findall(b"B: ?([\d\.]+) ?\/?([\d\.]+)?", line) + bed_temperature_matches = re.findall(b"B: ?(\d+\.?\d*) ?\/?(\d+\.?\d*) ?", line) if bed_temperature_matches: match = bed_temperature_matches[0] if match[0]: From 9c865e80d113438699c34cee724d0c9945f7b8db Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Fri, 14 Sep 2018 19:15:23 +0200 Subject: [PATCH 2/2] Remove debug print --- plugins/USBPrinting/USBPrinterOutputDevice.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 39b358224c..36c5321180 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -313,7 +313,6 @@ class USBPrinterOutputDevice(PrinterOutputDevice): while self._connection_state == ConnectionState.connected and self._serial is not None: try: line = self._serial.readline() - print(line) except: continue