Skip to content

Commit

Permalink
Merge pull request #420 from mrbeam/b_fix_avrdude_fail
Browse files Browse the repository at this point in the history
Fixes error state if flash_grbl failed + analytics: added avrdude output
  • Loading branch information
irlaec authored Mar 14, 2019
2 parents 038ce97 + 1f352e9 commit 9efd4b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
7 changes: 4 additions & 3 deletions octoprint_mrbeam/analytics/analytics_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, plugin):
self._storedConversions = list()

self._jobevent_log_version = 4
self._deviceinfo_log_version = 3
self._deviceinfo_log_version = 4
self._logevent_version = 1
self._dust_log_version = 2
self._cam_event_log_version = 2
Expand Down Expand Up @@ -250,11 +250,12 @@ def _event_startup(self,event,payload):
def _event_shutdown(self,event,payload):
self._write_deviceinfo(ak.SHUTDOWN)

def write_flash_grbl(self, from_version, to_version, succesful):
def write_flash_grbl(self, from_version, to_version, succesful, err=None):
payload = dict(
from_version=from_version,
to_version=to_version,
succesful=succesful)
succesful=succesful,
err=err)
self._write_deviceinfo(ak.FLASH_GRBL, payload=payload)

def _event_ip_addresses(self):
Expand Down
9 changes: 3 additions & 6 deletions octoprint_mrbeam/comm_acc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,20 +1063,17 @@ def flash_grbl(self, grbl_file=None, verify_only=False, is_connected=True):
_mrbeam_plugin_implementation._analytics_handler.write_flash_grbl(
from_version=from_version,
to_version=grbl_file,
succesful=(code == 0))
succesful=(code == 0),
err = None if (code == 0) else output)
except:
self._logger.exception("Exception while writing GRBL-flashing to analytics: ")

# error case
if code != 0 and not verify_only:
msg_short = "ERROR flashing GRBL '{}'".format(grbl_file)
msg_short = "ERROR flashing GRBL '{}': FAILED (See Avrdude output above for details.)".format(grbl_file)
msg_long = '{}:\n{}'.format(msg_short, output)
self._logger.error(msg_long, terminal_as_comm=True)
self._logger.error(msg_short, terminal_as_comm=True)
self._errorValue = "avrdude returncode: %s" % code
self._changeState(self.STATE_CLOSED_WITH_ERROR)
self._logger.info("Please reconnect manually or reboot system.", terminal_as_comm=True)
return
elif code != 0 and verify_only:
msg_short = "Verification GRBL '{}': FAILED (See Avrdude output above for details.)".format(grbl_file)
msg_long = '{}:\n{}'.format(msg_short, output)
Expand Down

0 comments on commit 9efd4b7

Please sign in to comment.