Added option to test using non-printing GCODE.

master
Marcio Teixeira 7 years ago
parent 3ae0f5c5c7
commit 3df418680e

@ -23,6 +23,8 @@ from pyMarlin import *
import argparse
import serial
import random
import sys
def load_gcode(filename):
with open(filename, "r") as f:
@ -30,8 +32,19 @@ def load_gcode(filename):
print("Read %d lines" % len(gcode))
return gcode
def generate_synthetic_gcode():
gcode = []
non_acting_gcodes = ["G90", "G91", "G92 X0 Y0 Z0", "G92 X123 Y456", "M31", "M114", "M115", "M119"]
for i in range(1, 10000):
which = random.randrange(0,len(non_acting_gcodes))
gcode.append(non_acting_gcodes[which])
return gcode
def send_gcode_test(filename, serial):
gcode = load_gcode(filename);
if filename == "TEST":
gcode = generate_synthetic_gcode()
else:
gcode = load_gcode(filename)
for i, line in enumerate(gcode):
serial.sendCommand(line)
@ -39,6 +52,7 @@ def send_gcode_test(filename, serial):
serial.readLine()
if(i % 1000 == 0):
print("Progress: %d" % (i*100/len(gcode)), end='\r')
sys.stdout.flush()
parser = argparse.ArgumentParser(description='''sends gcode to a printer while injecting errors to test error recovery.''')
parser.add_argument('-p', '--port', help='Serial port.', default='/dev/ttyACM1')
@ -46,7 +60,7 @@ parser.add_argument('-f', '--fake', help='Use a fake Marlin simulation instead
parser.add_argument('-e', '--errors', help='Corrupt 1 out N lines to exercise error recovery.', default='0', type=int)
parser.add_argument('-l', '--log', help='Write log file.')
parser.add_argument('-b', '--baud', help='Sets the baud rate for the serial port.', default='115000', type=int)
parser.add_argument('filename', help='file containing gcode.')
parser.add_argument('filename', help='file containing gcode, or TEST for synthetic non-printing GCODE')
args = parser.parse_args()
print()

Loading…
Cancel
Save