From b8e4ac21d0d338066d956ca50001d8c27f1ff39e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 28 Feb 2018 17:14:06 +0100 Subject: [PATCH] Example and copy-paste-fix for new comm error handler hook --- docs/plugins/hooks.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/plugins/hooks.rst b/docs/plugins/hooks.rst index d6d79fb52..3e1801ae6 100644 --- a/docs/plugins/hooks.rst +++ b/docs/plugins/hooks.rst @@ -592,7 +592,7 @@ octoprint.comm.protocol.gcode.received octoprint.comm.protocol.gcode.error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. py:function:: gcode_received_hook(comm_instance, error_message, *args, **kwargs) +.. py:function:: gcode_error_hook(comm_instance, error_message, *args, **kwargs) Get the messages of any errors messages sent by the printer, with the leading ``Error:`` or ``!!`` already stripped. Handlers should return True if they handled that error internally and it should not be processed by @@ -602,6 +602,16 @@ octoprint.comm.protocol.gcode.error Plugins might utilize this hook to handle errors generated by the printer that are recoverable in one way or the other and should not trigger the normal handling that assumes the worst. + **Example:** + + Looks for error messages containing "fan error" or "bed missing" (ignoring case) and marks them as handled by the + plugin. + + .. onlineinclude:: https://raw.githubusercontent.com/OctoPrint/Plugin-Examples/master/comm_error_handler_test.py + :linenos: + :tab-width: 4 + :caption: `comm_error_handler_test.py `_ + :param MachineCom comm_instance: The :class:`~octoprint.util.comm.MachineCom` instance which triggered the hook. :param str error_message: The error message received from the printer. :return: True if the error was handled in the plugin and should not be processed further, False (or None) otherwise.