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
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()