Suppresses sending GCode comments (text after ;) to printer with smoothie-stream...
authorJoseph Lenox <lenox.joseph@gmail.com>
Wed, 18 Apr 2018 03:55:03 +0000 (22:55 -0500)
committerJoseph Lenox <lenox.joseph@gmail.com>
Wed, 18 Apr 2018 03:55:03 +0000 (22:55 -0500)
smoothie-stream.py

index 8a8a7bc..a39c017 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,19 +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" )
-print("Waiting for complete...")
-
-while okcnt < linecnt:
-    rep= tn.read_some()
-    okcnt += rep.count("ok")
-    if verbose: print(str(linecnt) + " - " + str(okcnt) )
-    if args.log: outlog.write(str(linecnt) + " - " + 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)
+        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 args.log: outlog.close()