Commit f8417bbb authored by jglauche's avatar jglauche

add some command line options to printcore

parent 5e1960df
#!/usr/bin/env python #!/usr/bin/env python
# Licensed under GPLv3
from serial import Serial from serial import Serial
from threading import Thread from threading import Thread
from select import error as SelectError from select import error as SelectError
import time import time, getopt, sys
import sys
class printcore(): class printcore():
def __init__(self,port=None,baud=None): def __init__(self,port=None,baud=None):
...@@ -264,26 +265,41 @@ class printcore(): ...@@ -264,26 +265,41 @@ class printcore():
self.printer.write(str(command+"\n")) self.printer.write(str(command+"\n"))
if __name__ == '__main__': if __name__ == '__main__':
#print "Usage: python printcore.py filename.gcode" baud = 115200
filename="../prusamendel/sellsx_export.gcode" loud = False
if len(sys.argv)>1: statusreport=False
port=sys.argv[1] try:
filename=sys.argv[2] opts, args=getopt.getopt(sys.argv[1:], "h,b:,v,s",["help","baud","verbose","statusreport"])
print "Printing: "+filename except getopt.GetoptError,err:
print str(err)
print help
sys.exit(2)
for o,a in opts:
if o in ('-h', '--help'):
# FIXME: Fix help
print "Opts are: --help , -b --baud = baudrate, -v --verbose, -s --statusreport"
sys.exit(1)
if o in ('-b', '--baud'):
baud = int(a)
if o in ('-v','--verbose'):
loud=True
elif o in ('-s','--statusreport'):
statusreport=True
if len(args)>1:
port=args[-2]
filename=args[-1]
print "Printing: "+filename + " on "+port + " with baudrate "+str(baud)
else: else:
print "Usage: python printcore.py /dev/tty[USB|ACM]x filename.gcode" print "Usage: python [-h|-b|-v|-s] printcore.py /dev/tty[USB|ACM]x filename.gcode"
sys.exit(2) sys.exit(2)
p=printcore(port,115200) p=printcore(port,baud)
p.loud=True p.loud = loud
statusreport=False
time.sleep(2) time.sleep(2)
testdata=[i.replace("\n","") for i in open(filename)] gcode=[i.replace("\n","") for i in open(filename)]
p.startprint(testdata) p.startprint(gcode)
#time.sleep(1)
#p.pause()
#print "pause"
#time.sleep(5)
#p.resume()
try: try:
if statusreport: if statusreport:
p.loud=False p.loud=False
......
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