From 715cdfc6e873456e01c462289ad6d85cd07af023 Mon Sep 17 00:00:00 2001 From: Aidan Date: Wed, 6 Feb 2019 12:57:05 -0800 Subject: [PATCH] updated code to conform with python3 standards --- gcodesender.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gcodesender.py b/gcodesender.py index c5f6f84..7475d86 100755 --- a/gcodesender.py +++ b/gcodesender.py @@ -26,31 +26,31 @@ def removeComment(string): # Open serial port #s = serial.Serial('/dev/ttyACM0',115200) s = serial.Serial(args.port,115200) -print 'Opening Serial Port' +print ('Opening Serial Port') # Open g-code file #f = open('/media/UNTITLED/shoulder.g','r'); -f = open(args.file,'r'); -print 'Opening gcode file' +f = open(args.file,'r') +print ('Opening gcode file') # Wake up -s.write("\r\n\r\n") # Hit enter a few times to wake the Printrbot +s.write(str.encode("\r\n\r\n")) # Hit enter a few times to wake the Printrbot time.sleep(2) # Wait for Printrbot to initialize s.flushInput() # Flush startup text in serial input -print 'Sending gcode' +print ('Sending gcode') # Stream g-code for line in f: l = removeComment(line) l = l.strip() # Strip all EOL characters for streaming if (l.isspace()==False and len(l)>0) : - print 'Sending: ' + l - s.write(l + '\n') # Send g-code block + print ('Sending: ' + l) + s.write(str.encode(l + '\n')) # Send g-code block grbl_out = s.readline() # Wait for response with carriage return - print ' : ' + grbl_out.strip() + print (' : ' + grbl_out.strip().decode('utf-8')) # Wait here until printing is finished to close serial port and file. -raw_input(" Press to exit.") +input(" Press to exit.") # Close file and serial port f.close()