diff --git a/docs/features/action_commands.rst b/docs/features/action_commands.rst index 6e5f8830a..b3d298e2e 100644 --- a/docs/features/action_commands.rst +++ b/docs/features/action_commands.rst @@ -54,6 +54,27 @@ resumed disconnect When this command is received from the printer, OctoPrint will immediately disconnect from it. +sd_inserted + When this command is received from the printer, OctoPrint will assume an SD card is present in the printer, + set the corresponding internal state flags and send a file list request. This command is only recognized + if SD support is enabled in OctoPrint. + + .. versionadded:: 1.6.0 + +sd_ejected + When this command is received from the printer, OctoPrint will assume the SD card has been removed from + the printer and clear the corresponding internal state flags. This command is only recognized + if SD support is enabled in OctoPrint. + + .. versionadded:: 1.6.0 + +sd_updated + When this command is received from the printer, OctoPrint will assume something on the SD card in the + printer has changed and trigger a file list request. This command is only recognized + if SD support is enabled in OctoPrint. + + .. versionadded:: 1.6.0 + If the bundled :ref:`Action Command Prompt Support Plugin ` is enabled (which should be the case by default), OctoPrint will also interactive dialog creation through its :ref:`supported commands `. diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 6dcc9f3b7..ae16eb05a 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -2288,6 +2288,19 @@ class MachineCom(object): elif action_name == "disconnect": self._log("Disconnecting on request of the printer...") self._callback.on_comm_force_disconnect() + elif self._sdEnabled and action_name == "sd_inserted": + self._log("Printer reported SD card as inserted") + self._sdAvailable = True + self.refreshSdFiles() + self._callback.on_comm_sd_state_change(self._sdAvailable) + elif self._sdEnabled and action_name == "sd_ejected": + self._log("Printer reported SD card as ejected") + self._sdAvailable = False + self._sdFiles = [] + self._callback.on_comm_sd_state_change(self._sdAvailable) + elif self._sdEnabled and action_name == "sd_updated": + self._log("Printer reported a change on the SD card") + self.refreshSdFiles() else: for name, hook in self._printer_action_hooks.items(): try: