3 Stream g-code to Smoothie USB serial connection
5 Based on GRBL stream.py
8 from __future__
import print_function
15 # Define command line argument interface
16 parser
= argparse
.ArgumentParser(description
='Stream g-code file to Smoothie over telnet.')
17 parser
.add_argument('gcode_file', type=argparse
.FileType('r'),
18 help='g-code filename to be streamed')
19 parser
.add_argument('device',
20 help='Smoothie Serial Device')
21 parser
.add_argument('-q','--quiet',action
='store_true', default
=False,
22 help='suppress output text')
23 args
= parser
.parse_args()
26 verbose
= not args
.quiet
28 # Stream g-code to Smoothie
33 s
= serial
.Serial(dev
, 115200)
34 s
.flushInput() # Flush startup text in serial input
36 print("Streaming " + args
.gcode_file
.name
+ " to " + args
.device
)
42 """thread worker function"""
43 global okcnt
, errorflg
49 print("Incoming: " + rep
)
50 if "error" in rep
or "!!" in rep
:
56 print("Read thread exited")
60 t
= threading
.Thread(target
=read_thread
)
69 if line
.startswith(';') :
74 if verbose
: print("SND " + str(linecnt
) + ": " + line
.strip() + " - " + str(okcnt
))
76 print("Waiting for complete...")
78 while okcnt
< linecnt
:
79 if verbose
: print(str(linecnt
) + " - " + str(okcnt
) )
82 # Wait here until grbl is finished to close serial port and file.
83 raw_input(" Press <Enter> to exit")
85 # Close file and serial port