Allow multi line commands in sending phase
(cherry picked from commit 1018946)
This commit is contained in:
1 parent
a50e8bbbb5
commit
35c45df86c
3 files changed
+94
-39
No files matched your search
+10
-7
@@ -451,18 +451,21 @@ This describes actually four hooks:
|
||||
should use this option.
|
||||
* A 2-tuple consisting of a rewritten version of the ``cmd`` and the ``cmd_type``, e.g. ``return "M105", "temperature_poll"``.
|
||||
Handlers which wish to rewrite both the command and the command type should use this option.
|
||||
* **``queuing`` phase only**: A list of any of the above to allow for expanding one command into
|
||||
* A list of any of the above to allow for expanding one command into
|
||||
many. The following example shows how any queued command could be turned into a sequence of a temperature query,
|
||||
line number reset, display of the ``gcode`` on the printer's display and finally the actual command (this example
|
||||
does not make a lot of sense to be quiet honest):
|
||||
does not make a lot of sense to be quite honest):
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def multi_expansion(*args, **kwargs):
|
||||
return [("M105", "temperature_poll"),
|
||||
("M110",),
|
||||
"M117 GCODE: {}".format(gcode),
|
||||
(command, command_type)]
|
||||
def rewrite_foo(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs):
|
||||
if gcode or not cmd.startswith("@foo"):
|
||||
return
|
||||
|
||||
return [("M105", "temperature_poll"),
|
||||
("M110",),
|
||||
"M117 echo foo: {}".format(cmd)]
|
||||
|
||||
|
||||
Note: Only one command of a given ``cmd_type`` (other than None) may be queued at a time. Trying to rewrite the ``cmd_type``
|
||||
to one already in the queue will give an error.
|
||||
|
||||
Reference in new issue
Block a user