From e67f72ce3dc04e3c0b05f4d901a1d559ac44cd85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 11 Feb 2019 18:19:47 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20paused=20action=20must=20not=20t?= =?UTF-8?q?rigger=20*any*=20local=20processing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That includes sending M400 and M114 to capture the pause position. See MarlinFirmware/Marlin#13039 --- docs/events/index.rst | 6 ++++-- src/octoprint/printer/standard.py | 6 +++--- src/octoprint/util/comm.py | 16 ++-------------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/docs/events/index.rst b/docs/events/index.rst index 171fa66b0..26deef5bd 100644 --- a/docs/events/index.rst +++ b/docs/events/index.rst @@ -379,7 +379,8 @@ PrintCancelled * ``owner``: the user who started the print job (if available) * ``time``: the elapsed time of the print when it was cancelled, in seconds (float) * ``user``: the user who cancelled the print job (if available) - * ``position``: the print head position at the time of cancelling (if available) + * ``position``: the print head position at the time of cancelling (if available, not available if recording of the + position on cancel is disabled) * ``position.x``: x coordinate, as reported back from the firmware through `M114` * ``position.y``: y coordinate, as reported back from the firmware through `M114` * ``position.z``: z coordinate, as reported back from the firmware through `M114` @@ -407,7 +408,8 @@ PrintPaused * ``size``: the file's size in bytes (if available) * ``owner``: the user who started the print job (if available) * ``user``: the user who paused the print job (if available) - * ``position``: the print head position at the time of pausing (if available) + * ``position``: the print head position at the time of pausing (if available, not available if the recording of + the position on pause is disabled or the pause is completely handled by the printer's firmware) * ``position.x``: x coordinate, as reported back from the firmware through `M114` * ``position.y``: y coordinate, as reported back from the firmware through `M114` * ``position.z``: z coordinate, as reported back from the firmware through `M114` diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 52aaec2ba..9b52fd2a9 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -96,7 +96,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): #hook card upload self.sd_card_upload_hooks = plugin_manager().get_hooks("octoprint.printer.sdcardupload") - + # comm self._comm = None @@ -669,7 +669,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if self._comm is None or not self._comm.isSdReady(): return [] return map(lambda x: (x[0][1:], x[1]), self._comm.getSdFiles()) - + def add_sd_file(self, filename, path, on_success=None, on_failure=None, *args, **kwargs): if not self._comm or self._comm.isBusy() or not self._comm.isSdReady(): self._logger.error("No connection to printer or printer is busy") @@ -1234,7 +1234,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): thread.start() def on_comm_print_job_paused(self, suppress_script=False, user=None): - payload = self._payload_for_print_job_event(position=self._comm.pause_position.as_dict() if self._comm and self._comm.pause_position else None, + payload = self._payload_for_print_job_event(position=self._comm.pause_position.as_dict() if self._comm and self._comm.pause_position and not suppress_script else None, action_user=user) if payload: eventManager().fire(Events.PRINT_PAUSED, payload) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 0dcca6c98..85a66ae20 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1261,15 +1261,7 @@ class MachineCom(object): self._log("Did not receive parseable position data from printer within {}s, continuing without it".format(timeout)) self._pause_preparation_done() - def _pause_preparation_done(self, check_timer=True, suppress_script=None, user=None): - if suppress_script is None: - with self._suppress_scripts_mutex: - suppress_script = "pause" in self._suppress_scripts - try: - self._suppress_scripts.remove("pause") - except KeyError: - pass - + def _pause_preparation_done(self, check_timer=True, suppress_script=False, user=None): if user is None: with self._action_users_mutex: try: @@ -1336,10 +1328,6 @@ class MachineCom(object): part_of_job=True, tags=tags | {"trigger:comm.set_pause", "trigger:pause"}) # pause print - if not local_handling: - with self._suppress_scripts_mutex: - self._suppress_scripts.add("pause") - def _on_M400_sent(): # we don't call on_print_job_paused on our callback here # because we do this only after our M114 has been answered @@ -1360,7 +1348,7 @@ class MachineCom(object): "trigger:pause", "trigger:record_position"}) - if self._log_position_on_pause: + if self._log_position_on_pause and local_handling: with self._action_users_mutex: self._action_users["pause"] = user