diff --git a/octoprint_eeprom_marlin/__init__.py b/octoprint_eeprom_marlin/__init__.py index bc356a0..b9ec41d 100755 --- a/octoprint_eeprom_marlin/__init__.py +++ b/octoprint_eeprom_marlin/__init__.py @@ -207,11 +207,12 @@ def comm_protocol_gcode_received(self, comm, line, *args, **kwargs): self.collecting_eeprom = False self.collecting_stats = False - elif "printer locked" in line.lower(): - self._logger.info("Printer locked, aborting data collection") - self.send_message("locked", {}) - self.collecting_eeprom = False - self.collecting_stats = False + if "printer locked" in line.lower(): + self.send_message("locked", {}) + self._firmware_info.locked = True + # Disable data collection + self.collecting_eeprom = False + self.collecting_stats = False if self.collecting_eeprom: parsed = self._parser.parse_eeprom_data(line) diff --git a/octoprint_eeprom_marlin/api.py b/octoprint_eeprom_marlin/api.py index fe650a7..aea1dbd 100644 --- a/octoprint_eeprom_marlin/api.py +++ b/octoprint_eeprom_marlin/api.py @@ -57,6 +57,12 @@ def on_api_command(self, command, data): commands = ["M503" if self._settings.get(["use_m503"]) else "M501"] if self._settings.get_boolean(["m78"]): commands += ["M78"] + if self._firmware_info.locked: + # If the printer was locked on startup, we will need to check the name using M115 first. + commands = ["M115"] + commands + # Assume the user unlocked the printer - if they didn't, the locked state will return as soon as we + # send these commands. + self._firmware_info.locked = False self._printer.commands(commands) elif command == CMD_SAVE: diff --git a/octoprint_eeprom_marlin/data.py b/octoprint_eeprom_marlin/data.py index c360546..a525a21 100644 --- a/octoprint_eeprom_marlin/data.py +++ b/octoprint_eeprom_marlin/data.py @@ -287,6 +287,7 @@ class FirmwareInfo: is_marlin = False # type: bool additional_info = {} # type: dict capabilities = {} # type: dict + locked = False def additional_info_from_dict(self, data): self.additional_info = {} @@ -304,6 +305,7 @@ def to_dict(self): "is_marlin": self.is_marlin, "additional": self.additional_info, "capabilities": self.capabilities, + "locked": self.locked, } diff --git a/octoprint_eeprom_marlin/static/js/eeprom_marlin.js b/octoprint_eeprom_marlin/static/js/eeprom_marlin.js index cbfc28a..dab48e2 100755 --- a/octoprint_eeprom_marlin/static/js/eeprom_marlin.js +++ b/octoprint_eeprom_marlin/static/js/eeprom_marlin.js @@ -171,6 +171,7 @@ $(function () { self.info.is_marlin(data.info.is_marlin); self.info.name(data.info.name); + self.printer_locked(data.info.locked); }; self.stats = (function () { @@ -221,7 +222,7 @@ $(function () { return ( !self.loading() && !self.initialLoad() && - self.info.is_marlin() && + (self.info.is_marlin() || self.printer_locked()) && // Allow refresh button when locked !self.printerState.isBusy() && self.printerState.isReady() ); @@ -463,6 +464,10 @@ $(function () { self.loading(false); self.printer_locked(true); } + if (data.type === "unlocked") { + self.loading(false); + self.printer_locked(false); + } }; self.onAllBound = self.onEventConnected = function () { diff --git a/octoprint_eeprom_marlin/templates/alerts/printer_locked.jinja2 b/octoprint_eeprom_marlin/templates/alerts/printer_locked.jinja2 index f60c93d..768a9ae 100644 --- a/octoprint_eeprom_marlin/templates/alerts/printer_locked.jinja2 +++ b/octoprint_eeprom_marlin/templates/alerts/printer_locked.jinja2 @@ -8,6 +8,6 @@
- {{ _("Unlock the printer to use the EEPROM editor") }} + {{ _("Unlock the printer and then press 'Load' to use the EEPROM editor") }}
diff --git a/octoprint_eeprom_marlin/templates/overlays/not_connected.jinja2 b/octoprint_eeprom_marlin/templates/overlays/not_connected.jinja2 index 487d04d..b8f5aaf 100644 --- a/octoprint_eeprom_marlin/templates/overlays/not_connected.jinja2 +++ b/octoprint_eeprom_marlin/templates/overlays/not_connected.jinja2 @@ -1,5 +1,5 @@ -