Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions gcodesender.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Enter> to exit.")
input(" Press <Enter> to exit.")

# Close file and serial port
f.close()
Expand Down