Merge pull request #3597 from fieldOfView/fix_multiextruder_usb_temperatures

[3.3] Fix getting multiple extruder temperatures from USB printer
This commit is contained in:
ChrisTerBeke 2018-05-24 10:52:30 +02:00 committed by GitHub
commit c491cb4707
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -308,7 +308,21 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
if b"ok 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 if b"ok 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) extruder_temperature_matches = re.findall(b"T(\d*): ?([\d\.]+) ?\/?([\d\.]+)?", line)
# Update all temperature values # Update all temperature values
for match, extruder in zip(extruder_temperature_matches, self._printers[0].extruders): matched_extruder_nrs = []
for match in extruder_temperature_matches:
extruder_nr = 0
if match[0] != b"":
extruder_nr = int(match[0])
if extruder_nr in matched_extruder_nrs:
continue
matched_extruder_nrs.append(extruder_nr)
if extruder_nr >= len(self._printers[0].extruders)
Logger.log("w", "Printer reports more temperatures than the number of configured extruders")
continue
extruder = self._printers[0].extruders[extruder_nr]
if match[1]: if match[1]:
extruder.updateHotendTemperature(float(match[1])) extruder.updateHotendTemperature(float(match[1]))
if match[2]: if match[2]: