From 966c4735076f4e3afae89be03f94573e07a4612a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 3 Sep 2020 17:48:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20sending=20of=20M876=20whil?= =?UTF-8?q?e=20printing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to immediately force it into the send queue and not allow it to get pushed into the command queue. Otherwise it will be stuck there waiting for busy state to end instead of the emergency sending routine triggering. Closes #3699 --- .../plugins/action_command_prompt/__init__.py | 6 ++++-- src/octoprint/printer/__init__.py | 3 ++- src/octoprint/printer/standard.py | 10 ++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/octoprint/plugins/action_command_prompt/__init__.py b/src/octoprint/plugins/action_command_prompt/__init__.py index 680ea9dd1..d0e7f97ea 100644 --- a/src/octoprint/plugins/action_command_prompt/__init__.py +++ b/src/octoprint/plugins/action_command_prompt/__init__.py @@ -221,10 +221,12 @@ class ActionCommandPromptPlugin(octoprint.plugin.AssetPlugin, self._close_prompt() if "{choice}" in self._command: - self._printer.commands([self._command.format(choice=choice)]) + self._printer.commands([self._command.format(choice=choice)], + force=True) else: self._printer.commands(["{command} S{choice}".format(command=self._command, - choice=choice)]) + choice=choice)], + force=True) __plugin_name__ = "Action Command Prompt Support" diff --git a/src/octoprint/printer/__init__.py b/src/octoprint/printer/__init__.py index 09b8e25d7..529b0d475 100644 --- a/src/octoprint/printer/__init__.py +++ b/src/octoprint/printer/__init__.py @@ -175,7 +175,7 @@ class PrinterInterface(object): """ raise NotImplementedError() - def commands(self, commands, tags=None, *args, **kwargs): + def commands(self, commands, tags=None, force=False, *args, **kwargs): """ Sends the provided ``commands`` to the printer. @@ -183,6 +183,7 @@ class PrinterInterface(object): commands (str, list): The commands to send. Might be a single command provided just as a string or a list of multiple commands to send in order. tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle + force (bool): Whether to force sending of the command right away or allow queuing while printing """ raise NotImplementedError() diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 6aab74705..9296832a5 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -303,7 +303,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): self._comm.fakeOk() - def commands(self, commands, *args, **kwargs): + def commands(self, commands, tags=None, force=False, *args, **kwargs): """ Sends one or more gcode commands to the printer. """ @@ -313,8 +313,14 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if not isinstance(commands, (list, tuple)): commands = [commands] + if tags is None: + tags = set() + tags |= {"trigger:printer.commands"} + for command in commands: - self._comm.sendCommand(command, tags=kwargs.get("tags", set()) | {"trigger:printer.commands"}) + self._comm.sendCommand(command, + tags=tags, + force=force) def script(self, name, context=None, must_be_set=True, part_of_job=False, *args, **kwargs): if self._comm is None: