temperaturecontrol: allow setting background tool without activating
[clinton/Smoothieware.git] / smoothie-stream.py
index 8a8a7bc..c3b5017 100644 (file)
@@ -26,6 +26,8 @@ parser.add_argument('-q','--quiet',action='store_true', default=False,
         help='suppress output text')
 parser.add_argument('-l','--log',action='store_true', default=False,
         help='suppress output text and output to file (gcode file with .log appended)')
+parser.add_argument('-c','--comment',action='store_true', default=False,
+        help='Send gcode comments to printer (text after ;)')
 args = parser.parse_args()
 
 f = args.gcode_file
@@ -47,12 +49,16 @@ tn.read_until("Smoothie command shell")
 okcnt= 0
 linecnt= 0
 for line in f:
-    tn.write(line)
-    linecnt+=1
-    rep= tn.read_eager()
-    okcnt += rep.count("ok")
-    if verbose: print("SND " + str(linecnt) + ": " + line.strip() + " - " + str(okcnt))
-    if args.log: outlog.write("SND " + str(linecnt) + ": " + line.strip() + " - " + str(okcnt) + "\n" )
+    if not args.comment:
+        line = re.sub("[ ]*;.*", '', line) # remove everything after ;
+        line = line.strip() #send only the bare necessity.
+    if len(line) > 0:
+        tn.write(line + "\n")
+        linecnt+=1
+        rep= tn.read_eager()
+        okcnt += rep.count("ok")
+        if verbose: print("SND " + str(linecnt) + ": " + line.strip() + " - " + str(okcnt))
+        if args.log: outlog.write("SND " + str(linecnt) + ": " + line.strip() + " - " + str(okcnt) + "\n" )
 print("Waiting for complete...")
 
 while okcnt < linecnt: