aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-08-04 14:45:21 -0400
committerKevin O'Connor <kevin@koconnor.net>2020-08-06 14:21:08 -0400
commitb66dd1a60f4e30a4e8636812cf9fb46b8f34f658 (patch)
tree6dd99e5441110a3750e4c92a67463e2e28b8267a
parent8ed1696624ea76427bf1c13ae61a5f2289eb2e6b (diff)
downloadkutter-b66dd1a60f4e30a4e8636812cf9fb46b8f34f658.tar.gz
kutter-b66dd1a60f4e30a4e8636812cf9fb46b8f34f658.tar.xz
kutter-b66dd1a60f4e30a4e8636812cf9fb46b8f34f658.zip
gcode: Allow handlers to be registered for all gcode output
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/gcode.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py
index 3428ce4f..1ef2f37f 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -105,6 +105,7 @@ class GCodeParser:
# Command handling
self.is_printer_ready = False
self.mutex = self.reactor.mutex()
+ self.output_callbacks = []
self.base_gcode_handlers = self.gcode_handlers = {}
self.ready_gcode_handlers = {}
self.mux_commands = {}
@@ -171,6 +172,8 @@ class GCodeParser:
"mux command %s %s %s already registered (%s)" % (
cmd, key, value, prev_values))
prev_values[value] = func
+ def register_output_handler(self, cb):
+ self.output_callbacks.append(cb)
def set_move_transform(self, transform, force=False):
if self.move_transform is not None and not force:
raise self.printer.config_error(
@@ -390,6 +393,8 @@ class GCodeParser:
return GCodeCommand(self, command, commandline, params, False)
# Response handling
def respond_raw(self, msg):
+ for cb in self.output_callbacks:
+ cb(msg)
if self.pipe_is_active:
try:
os.write(self.fd, msg+"\n")