-added new machine state (STATE_FLASHING)

-added required grbl hex file to flash
This commit is contained in:
make-ing 2015-08-27 15:10:05 +02:00
parent 4e76574bb9
commit 0632bb5fdf
2 changed files with 1805 additions and 6 deletions

1795
grbl.junior.hex Normal file

File diff suppressed because it is too large Load diff

View file

@ -116,6 +116,7 @@ class MachineCom(object):
STATE_TRANSFERING_FILE = 11 STATE_TRANSFERING_FILE = 11
STATE_LOCKED = 12 STATE_LOCKED = 12
STATE_HOMING = 13 STATE_HOMING = 13
STATE_FLASHING = 14
@ -316,6 +317,8 @@ class MachineCom(object):
return "Locked" return "Locked"
if self._state == self.STATE_HOMING: if self._state == self.STATE_HOMING:
return "Homing" return "Homing"
if self._state == self.STATE_FLASHING:
return "Flashing"
return "?%d?" % (self._state) return "?%d?" % (self._state)
def getErrorString(self): def getErrorString(self):
@ -332,9 +335,13 @@ class MachineCom(object):
def isLocked(self): def isLocked(self):
return self._state == self.STATE_LOCKED return self._state == self.STATE_LOCKED
def isHoming(self): def isHoming(self):
return self._state == self.STATE_HOMING return self._state == self.STATE_HOMING
def isFlashing(self):
return self._state == self.STATE_FLASHING
def isPrinting(self): def isPrinting(self):
return self._state == self.STATE_PRINTING return self._state == self.STATE_PRINTING
@ -856,13 +863,12 @@ class MachineCom(object):
return True return True
def _flashGrbl(self): def _flashGrbl(self):
self._log("flashing grbl version: " + self._requiredGrblVer) self._changeState(self.STATE_FLASHING)
self._serial.close() self._serial.close()
self._changeState(self.STATE_CLOSED)
import subprocess import subprocess
params = ["avrdude", "-patmega328p", "-carduino", "-b" + str(self._baudrate), "-P" + str(self._port), "-D", "-Uflash:w:grbl.junior.hex"] params = ["avrdude", "-patmega328p", "-carduino", "-b" + str(self._baudrate), "-P" + str(self._port), "-D", "-Uflash:w:grbl.junior.hex"]
#params = ['pwd'] returnCode = subprocess.call(params)
if subprocess.call(params) is False: if returnCode == False:
self._log("successfully flashed new grbl version") self._log("successfully flashed new grbl version")
else: else:
self._log("error during flashing of new grbl version") self._log("error during flashing of new grbl version")
@ -981,7 +987,6 @@ class MachineCom(object):
self._openSerial() self._openSerial()
self._changeState(self.STATE_CONNECTING) self._changeState(self.STATE_CONNECTING)
if("Invalid gcode" in line and self._state == self.STATE_PRINTING): if("Invalid gcode" in line and self._state == self.STATE_PRINTING):
# TODO Pause machine instead of resetting it. # TODO Pause machine instead of resetting it.
errorMsg = line errorMsg = line
@ -1010,7 +1015,6 @@ class MachineCom(object):
if("error:" in line): if("error:" in line):
self.handle_grbl_error(line) self.handle_grbl_error(line)
##~~ SD file list ##~~ SD file list
# if we are currently receiving an sd file list, each line is just a filename, so just read it and abort processing # if we are currently receiving an sd file list, each line is just a filename, so just read it and abort processing
if self._sdFileList and not "End file list" in line: if self._sdFileList and not "End file list" in line: