Commit 84edbc20 authored by Guillaume Seguin's avatar Guillaume Seguin

Fix #523: strip comments in brackets and ; comments in printcore

parent 086bb290
...@@ -25,6 +25,7 @@ gcode_parsed_args = ["x", "y", "e", "f", "z", "i", "j"] ...@@ -25,6 +25,7 @@ gcode_parsed_args = ["x", "y", "e", "f", "z", "i", "j"]
gcode_parsed_nonargs = ["g", "t", "m", "n"] gcode_parsed_nonargs = ["g", "t", "m", "n"]
to_parse = "".join(gcode_parsed_args + gcode_parsed_nonargs) to_parse = "".join(gcode_parsed_args + gcode_parsed_nonargs)
gcode_exp = re.compile("\([^\(\)]*\)|;.*|[/\*].*\n|([%s])([-+]?[0-9]*\.?[0-9]*)" % to_parse) gcode_exp = re.compile("\([^\(\)]*\)|;.*|[/\*].*\n|([%s])([-+]?[0-9]*\.?[0-9]*)" % to_parse)
gcode_strip_comment_exp = re.compile("\([^\(\)]*\)")
m114_exp = re.compile("\([^\(\)]*\)|[/\*].*\n|([XYZ]):?([-+]?[0-9]*\.?[0-9]*)") m114_exp = re.compile("\([^\(\)]*\)|[/\*].*\n|([XYZ]):?([-+]?[0-9]*\.?[0-9]*)")
specific_exp = "(?:\([^\(\)]*\))|(?:;.*)|(?:[/\*].*\n)|(%s[-+]?[0-9]*\.?[0-9]*)" specific_exp = "(?:\([^\(\)]*\))|(?:;.*)|(?:[/\*].*\n)|(%s[-+]?[0-9]*\.?[0-9]*)"
move_gcodes = ["G0", "G1", "G2", "G3"] move_gcodes = ["G0", "G1", "G2", "G3"]
......
...@@ -551,8 +551,9 @@ class printcore(): ...@@ -551,8 +551,9 @@ class printcore():
self.clear = True self.clear = True
return return
tline = tline.split(";")[0] # Strip comments
if len(tline) > 0: tline = gcoder.gcode_strip_comment_exp.sub("", tline)
if tline:
self._send(tline, self.lineno, True) self._send(tline, self.lineno, True)
self.lineno += 1 self.lineno += 1
if self.printsendcb: if self.printsendcb:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment