Skip to content

Commit

Permalink
Add timestamp filenames option
Browse files Browse the repository at this point in the history
  • Loading branch information
benlye committed Mar 5, 2021
1 parent 1646675 commit eef1b44
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions octoprint_firmwareupdater/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ def get_settings_defaults(self):
"marlinbft_progresslogging": False,
"marlinbft_no_m997_reset_wait": False,
"marlinbft_no_m997_restart_wait": False,
"marlinbft_timestamp_filenames": False,
"postflash_delay": 0,
"preflash_delay": 3,
"postflash_gcode": None,
Expand Down
11 changes: 9 additions & 2 deletions octoprint_firmwareupdater/methods/marlinbft.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import time
import datetime

binproto2_installed = True
try:
Expand Down Expand Up @@ -45,6 +46,7 @@ def _flash_marlinbft(self, firmware=None, printer_port=None, **kwargs):
bft_timeout = self.get_profile_setting_int("marlinbft_timeout")
bft_verbose = self.get_profile_setting_boolean("marlinbft_progresslogging")
no_m997_reset_wait = self.get_profile_setting_boolean("marlinbft_no_m997_reset_wait")
timestamp_filenames = self.get_profile_setting_boolean("marlinbft_timestamp_filenames")

# Loggging
if bft_verbose:
Expand Down Expand Up @@ -74,10 +76,15 @@ def _flash_marlinbft(self, firmware=None, printer_port=None, **kwargs):
protocol.connect()

# Copy the file
self._logger.info(u"Transfering file to printer using Marlin BFT '{}' -> /firmware.bin".format(firmware))
if timestamp_filenames:
target = datetime.datetime.now().strftime("fw%H%M%S.bin")
else:
target = "firmware.bin"

self._logger.info(u"Transfering file to printer using Marlin BFT '{}' -> /{}".format(firmware, target))
self._send_status("progress", subtype="sending")
filetransfer = mbp.FileTransferProtocol(protocol, logger=transfer_logger)
filetransfer.copy(firmware, 'firmware.bin', True, False)
filetransfer.copy(firmware, target, True, False)
self._logger.info(u"Binary file transfer complete")

# Disconnect
Expand Down
4 changes: 3 additions & 1 deletion octoprint_firmwareupdater/static/js/firmwareupdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ $(function() {
self.configMarlinBftProgressLogging = ko.observable();
self.configMarlinBftNoResetWait = ko.observable();
self.configMarlinBftNoRestartWait = ko.observable();
self.configMarlinBftTimestampFilenames = ko.observable();
self.marlinbftHasCapability = ko.observable();
self.marlinbftHasBinProto2Package = ko.observable();

Expand Down Expand Up @@ -840,6 +841,7 @@ $(function() {
self.configMarlinBftProgressLogging(self.getProfileSetting("marlinbft_progresslogging"));
self.configMarlinBftNoResetWait(self.getProfileSetting("marlinbft_no_m997_reset_wait"));
self.configMarlinBftNoRestartWait(self.getProfileSetting("marlinbft_no_m997_restart_wait"));
self.configMarlinBftTimestampFilenames(self.getProfileSetting("marlinbft_timestamp_filenames"));

// Load the stm32flash settings
self.configStm32flashPath(self.getProfileSetting("stm32flash_path"));
Expand Down Expand Up @@ -948,6 +950,7 @@ $(function() {
profiles[index]["marlinbft_progresslogging"] = self.configMarlinBftProgressLogging();
profiles[index]["marlinbft_no_m997_reset_wait"] = self.configMarlinBftNoResetWait();
profiles[index]["marlinbft_no_m997_restart_wait"] = self.configMarlinBftNoRestartWait();
profiles[index]["marlinbft_timestamp_filenames"] = self.configMarlinBftTimestampFilenames();

// STM32Flash Settings
profiles[index]["stm32flash_path"] = self.configStm32flashPath();
Expand Down Expand Up @@ -1059,7 +1062,6 @@ $(function() {

self.resetBossacCommandLine = function() {
self.configBossacCommandLine(self.profileDefaults["bossac_commandline"]);

};

self.resetDfuCommandLine = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,15 @@
<span class="help-block">{{ _('Plugin won\'t wait for printer to come back online after the reset has initiated.') }}</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Use timestamp filenames') }}</label>
<div class="controls">
<div class="input">
<input type="checkbox" data-bind="checked: configMarlinBftTimestampFilenames">
</div>
<span class="help-block">{{ _('Firmware file will be saved on the printer as <code>fwHHMMSS.bin</code> (where HHMMSS is the current time) instead of <code>firmware.bin</code>. Needed for Ender 3 V2.') }}</span>
</div>
</div>
</div>
<!-- Advanced marlinbft options -->

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.10.1"
plugin_version = "1.10.2"

# 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 eef1b44

Please sign in to comment.