|
Start Easimill and upaload gcode
Set ΜΑNUAL MODE. 1. Press AXIS POWER button 2. Homing Machine Press <ZERO> to datum machine (press ZERO) 3. Select function Select function (DATA LINK) 4. Data link Select (press 1) set AUTO mode (!! Great Attention. The machine will start no other warning !!!) 5. Run in terminal $:~/python$ python3 uploadGcode.py Gcodefile.gcode # 2018, [email protected]
# Python 3.5.1 # Homing the machine, TURN MACHINE AUTO, upload gcode from serial port # Easimill3-Installation-Programming-Maintenance-Manual.pdf, page 104 # # $:~/python$ python3 uploadGcode.py Gcodefile.gcode import time import serial import sys if len(sys.argv) != 2 : print ("------------------------------------") print ("Usage: python3", str(sys.argv[0]), "Gcodefile.gcode") print ("------------------------------------") exit(1) serS0 = serial.Serial( port = '/dev/ttyS0', baudrate = 4800, parity = serial.PARITY_EVEN, stopbits = serial.STOPBITS_TWO, bytesize = serial.SEVENBITS, xonxoff = False, rtscts = False, dsrdtr = False, timeout = 6 # write_timeout = 6 ) STX = "\x02" CR = "\x0D" # \r ETX = "\x03" ACK = "\x06" #OK NAK = "\x15" #Error #<NAK>nn ERROR CODE SleepTime = 1 if serS0.isOpen(): serS0.close() serS0.open() if serS0.isOpen(): print(serS0.name + ' is open...') serS0.flushInput() #flush input buffer, discarding all its contents serS0.flushOutput() #flush output buffer, aborting current output fname=str(sys.argv[1]) f=open(fname,"r") rawData=f.read() f.close() cmdList = rawData.splitlines( ) s = STX+CR s = s.encode('ascii') serS0.write(s) time.sleep(SleepTime) s = STX+"E"+CR #clear memory s = s.encode('ascii') serS0.write(s) time.sleep(SleepTime) e=0 n=0 for ngcmd in cmdList: if ngcmd.find(";") is -1: #check for comments (;) n +=1 s = 'N{:03d} '.format(n)+ngcmd+"L" print (s) s = STX+s+CR s = s.encode('ascii') serS0.write(s) time.sleep(SleepTime) out = 0 while serS0.inWaiting() > 0: out = int.from_bytes(serS0.read(1),byteorder='little') if out > 0: if out > 6: e= out-15 print("-----------------------") print("Error: in line",'N{:03d} '.format(n)), "e: ", e print("-----------------------") exit(out) break else: print(ngcmd) s = STX+"B"+CR # Whole program to be executed s = s.encode('ascii') serS0.write(s) time.sleep(SleepTime) print (" ") print ("------------------") print (" ") print (s," Execut program") serS0.close() |