Skip to content

Commit

Permalink
Merge pull request #174 from OctoPrint/devel
Browse files Browse the repository at this point in the history
LPC1768 fixes and more
  • Loading branch information
benlye authored Dec 17, 2020
2 parents 4f4eeb1 + 8e62050 commit 167462b
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 26 deletions.
14 changes: 11 additions & 3 deletions octoprint_firmwareupdater/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ def get_settings_defaults(self):
"enable_preflash_delay": None,
"enable_postflash_gcode": None,
"enable_preflash_gcode": None,
"disable_bootloadercheck": None
"disable_bootloadercheck": None,
"plugin_version": self._plugin_version
}

#~~ Asset API
Expand Down Expand Up @@ -370,9 +371,11 @@ def update_hook(self):
repo="OctoPrint-FirmwareUpdater",
current=self._plugin_version,

# stable branch
# stable releases
stable_branch=dict(
name="Stable", branch="master", comittish=["master"]
name="Stable",
branch="master",
comittish=["master"]
),

# release candidates
Expand All @@ -381,6 +384,11 @@ def update_hook(self):
name="Release Candidate",
branch="rc",
comittish=["rc", "master"],
),
dict(
name="Development",
branch="devel",
comittish=["devel", "rc", "master"],
)
],

Expand Down
63 changes: 42 additions & 21 deletions octoprint_firmwareupdater/methods/lpc1768.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
import time
import shutil
import subprocess
import sys

def _check_lpc1768(self):
lpc1768_path = self._settings.get(["lpc1768_path"])
Expand Down Expand Up @@ -42,23 +44,34 @@ def _flash_lpc1768(self, firmware=None, printer_port=None):
return False
time.sleep(1)

unmount_command = self._settings.get(["lpc1768_unmount_command"])
if unmount_command:
unmount_command = unmount_command.replace("{mountpoint}", lpc1768_path)

self._logger.info(u"Unmounting SD card: '{}'".format(unmount_command))
try:
r = os.system(unmount_command)
except:
e = sys.exc_info()[0]
self._logger.error("Error executing unmount command '{}'".format(unmount_command))
self._send_status("flasherror", message="Unable to unmount SD card")
return False

if r != 0:
self._logger.error("Error executing unmount command '{}'".format(unmount_command))
self._send_status("flasherror", message="Unable to unmount SD card")
return False
if os.access(lpc1768_path, os.W_OK):
unmount_command = self._settings.get(["lpc1768_unmount_command"])
if unmount_command:
unmount_command = unmount_command.replace("{mountpoint}", lpc1768_path)

self._logger.info(u"Unmounting SD card: '{}'".format(unmount_command))
try:
p = subprocess.Popen(unmount_command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
out, err = p.communicate()
r = p.returncode

except:
e = sys.exc_info()[0]
self._logger.error("Error executing unmount command '{}'".format(unmount_command))
self._logger.error("{}".format(str(e)))
self._send_status("flasherror", message="Unable to unmount SD card")
return False

if r != 0:
if err.strip().endswith("not mounted."):
self._logger.info("{}".format(err.strip()))
else:
self._logger.error("Error executing unmount command '{}'".format(unmount_command))
self._logger.error("{}".format(err.strip()))
self._send_status("flasherror", message="Unable to unmount SD card")
return False
else:
self._logger.info(u"SD card not mounted, skipping unmount")

self._logger.info(u"Pre-flash reset: attempting to reset the board")
if not _reset_lpc1768(self, printer_port):
Expand Down Expand Up @@ -117,17 +130,25 @@ def _flash_lpc1768(self, firmware=None, printer_port=None):

self._logger.info(u"Unmounting SD card: '{}'".format(unmount_command))
try:
r = os.system(unmount_command)
p = subprocess.Popen(unmount_command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
out, err = p.communicate()
r = p.returncode

except:
e = sys.exc_info()[0]
self._logger.error("Error executing unmount command '{}'".format(unmount_command))
self._logger.error("{}".format(str(e)))
self._send_status("flasherror", message="Unable to unmount SD card")
return False

if r != 0:
self._logger.error("Error executing unmount command '{}'".format(unmount_command))
self._send_status("flasherror", message="Unable to unmount SD card")
return False
if err.strip().endswith("not mounted."):
self._logger.info("{}".format(err.strip()))
else:
self._logger.error("Error executing unmount command '{}'".format(unmount_command))
self._logger.error("{}".format(err.strip()))
self._send_status("flasherror", message="Unable to unmount SD card")
return False

self._logger.info(u"Firmware update reset: attempting to reset the board")
if not _reset_lpc1768(self, printer_port):
Expand Down
2 changes: 2 additions & 0 deletions octoprint_firmwareupdater/static/js/firmwareupdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $(function() {
self.configPostflashCommandline = ko.observable();
self.configEnablePreflashGcode = ko.observable();
self.configPreflashGcode = ko.observable();
self.pluginVersion = ko.observable();

// Config settings for avrdude
self.configAvrdudeMcu = ko.observable();
Expand Down Expand Up @@ -132,6 +133,7 @@ $(function() {
if (self.loginState.isAdmin() && self.configShowNavbarIcon()) {
self.showFirmwareUpdaterNavbarIcon(true);
}
self.pluginVersion(self.settingsViewModel.settings.plugins.firmwareupdater.plugin_version());
}

self.showFirmwareUpdater = function(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@
</ul>
<p>No warranty is given, and no responsibility can be accepted if there are problems. By using this plugin you accept the associated risks.</p>
<i class="icon-book"></i>&nbsp;&nbsp;<h5 style="display: inline-block">Documentation</h5>
<p>Documentation is available on <a target=_new href="https://github.com/OctoPrint/OctoPrint-FirmwareUpdater/blob/master/README.md">Github</p>
<p>Documentation is available on <a target=_new href="https://github.com/OctoPrint/OctoPrint-FirmwareUpdater/blob/master/README.md">Github</a></p>
</div>
<div class="pull-right" style="font-size:12px; opacity:0.6">Plugin Version: <span data-bind="text: pluginVersion"></span></div>
</form>

<div id="settings_plugin_firmwareupdater_configurationdialog" class="modal hide fade">
Expand Down Expand Up @@ -547,6 +548,7 @@
</div>
<!-- End pre-flash and post-flash settings -->
</form>
<div class="pull-right" style="font-size:12px; opacity:0.6">Plugin Version: <span data-bind="text: pluginVersion"></span></div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" data-bind="click: onConfigHidden" aria-hidden="true">{{ _('Cancel') }}</button>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "OctoPrint-FirmwareUpdater"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.7.6"
plugin_version = "1.7.6rc2"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 167462b

Please sign in to comment.