From 957213321ee2840a8e8201cf037f177c09b8d655 Mon Sep 17 00:00:00 2001 From: Lars Norpchen Date: Thu, 9 May 2013 08:07:33 -0700 Subject: [PATCH] Print 'unknown G/M code' warnings to console once --- octoprint/util/gcodeInterpreter.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/octoprint/util/gcodeInterpreter.py b/octoprint/util/gcodeInterpreter.py index 797d954..48a8399 100644 --- a/octoprint/util/gcodeInterpreter.py +++ b/octoprint/util/gcodeInterpreter.py @@ -72,6 +72,8 @@ class gcode(object): pathType = 'CUSTOM'; startCodeDone = False currentLayer = [] + unknownGcodes={} + unknownMcodes={} currentPath = gcodePath('move', pathType, layerThickness, pos.copy()) currentPath.list[0].e = totalExtrusion currentPath.list[0].extrudeAmountMultiply = extrudeAmountMultiply @@ -220,7 +222,9 @@ class gcode(object): if z is not None: posOffset.z = pos.z - z else: - print "Unknown G code:" + str(G) + if G not in unknownGcodes: + print "Unknown G code:" + str(G) + unknownGcodes[G] = True else: M = self.getCodeInt(line, 'M') if M is not None: @@ -267,7 +271,9 @@ class gcode(object): if s != None: extrudeAmountMultiply = s / 100.0 else: - print "Unknown M code:" + str(M) + if M not in unknownMcodes: + print "Unknown M code:" + str(M) + unknownMcodes[M] = True self.layerList.append(currentLayer) self.extrusionAmount = maxExtrusion self.totalMoveTimeMinute = totalMoveTimeMinute