Added sanity check for extruder selection in gcode files
Any T command targeting a number higher than the value specified in the settings for gcodeAnalysis.maxExtruders (defaults to 10) will be ignored and trigger a warning in the log file.
Fix for #539
(cherry picked from commit 7d5c55f)
This commit is contained in:
parent
ad68b05f7d
commit
d504157c6f
2 changed files with 23 additions and 17 deletions
|
|
@ -65,6 +65,9 @@ default_settings = {
|
|||
"mobileSizeThreshold": 2 * 1024 * 1024, # 2MB
|
||||
"sizeThreshold": 20 * 1024 * 1024, # 20MB
|
||||
},
|
||||
"gcodeAnalysis": {
|
||||
"maxExtruders": 10
|
||||
},
|
||||
"feature": {
|
||||
"temperatureGraph": True,
|
||||
"waitForStartOnConnect": False,
|
||||
|
|
|
|||
|
|
@ -92,23 +92,26 @@ class gcode(object):
|
|||
|
||||
T = getCodeInt(line, 'T')
|
||||
if T is not None:
|
||||
posOffset[0] -= offsets[currentExtruder]["x"] if currentExtruder < len(offsets) else 0
|
||||
posOffset[1] -= offsets[currentExtruder]["y"] if currentExtruder < len(offsets) else 0
|
||||
|
||||
currentExtruder = T
|
||||
|
||||
posOffset[0] += offsets[currentExtruder]["x"] if currentExtruder < len(offsets) else 0
|
||||
posOffset[1] += offsets[currentExtruder]["y"] if currentExtruder < len(offsets) else 0
|
||||
|
||||
if len(currentE) <= currentExtruder:
|
||||
for i in range(len(currentE), currentExtruder + 1):
|
||||
currentE.append(0.0)
|
||||
if len(maxExtrusion) <= currentExtruder:
|
||||
for i in range(len(maxExtrusion), currentExtruder + 1):
|
||||
maxExtrusion.append(0.0)
|
||||
if len(totalExtrusion) <= currentExtruder:
|
||||
for i in range(len(totalExtrusion), currentExtruder + 1):
|
||||
totalExtrusion.append(0.0)
|
||||
if T > settings().getInt(["gcodeAnalysis", "maxExtruders"]):
|
||||
self._logger.warn("GCODE tried to select tool %d, that looks wrong, ignoring for GCODE analysis" % T)
|
||||
else:
|
||||
posOffset[0] -= offsets[currentExtruder]["x"] if currentExtruder < len(offsets) else 0
|
||||
posOffset[1] -= offsets[currentExtruder]["y"] if currentExtruder < len(offsets) else 0
|
||||
|
||||
currentExtruder = T
|
||||
|
||||
posOffset[0] += offsets[currentExtruder]["x"] if currentExtruder < len(offsets) else 0
|
||||
posOffset[1] += offsets[currentExtruder]["y"] if currentExtruder < len(offsets) else 0
|
||||
|
||||
if len(currentE) <= currentExtruder:
|
||||
for i in range(len(currentE), currentExtruder + 1):
|
||||
currentE.append(0.0)
|
||||
if len(maxExtrusion) <= currentExtruder:
|
||||
for i in range(len(maxExtrusion), currentExtruder + 1):
|
||||
maxExtrusion.append(0.0)
|
||||
if len(totalExtrusion) <= currentExtruder:
|
||||
for i in range(len(totalExtrusion), currentExtruder + 1):
|
||||
totalExtrusion.append(0.0)
|
||||
|
||||
G = getCodeInt(line, 'G')
|
||||
if G is not None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue