aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-09-12 18:46:25 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-09-12 21:31:27 -0400
commit094b9de69e0438a5bbb6f6e67b19d842e0395717 (patch)
tree3c806cf49a17827a4cfd7caacd07c2ac04afd752
parent91691afdcf30e021c3f080af7097a9c4a68e5332 (diff)
downloadkutter-094b9de69e0438a5bbb6f6e67b19d842e0395717.tar.gz
kutter-094b9de69e0438a5bbb6f6e67b19d842e0395717.tar.xz
kutter-094b9de69e0438a5bbb6f6e67b19d842e0395717.zip
gcode: Send proactive state messages
Send a g-code info message on printer state changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--docs/Installation.md2
-rw-r--r--klippy/gcode.py15
-rw-r--r--klippy/klippy.py2
3 files changed, 13 insertions, 6 deletions
diff --git a/docs/Installation.md b/docs/Installation.md
index 2c8e573e..1ab0a005 100644
--- a/docs/Installation.md
+++ b/docs/Installation.md
@@ -147,7 +147,7 @@ In addition to common g-code commands, Klipper supports a few extended
commands - "status" and "restart" are examples of these commands. Use
the "help" command to get a list of other extended commands.
-After Klipper reports that the "printer is ready" go on to the
+After Klipper reports that the printer is ready go on to the
[config check document](Config_checks.md) to perform some basic checks
on the pin definitions in the config file.
diff --git a/klippy/gcode.py b/klippy/gcode.py
index 04b1ca4c..58602304 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -106,8 +106,11 @@ class GCodeParser:
self.dump_debug()
if self.is_fileinput:
self.printer.request_exit('error_exit')
+ self._respond_state("Shutdown")
return
if state != 'ready':
+ if state == 'disconnect':
+ self._respond_state("Disconnect")
return
self.is_printer_ready = True
self.gcode_handlers = self.ready_gcode_handlers
@@ -125,6 +128,7 @@ class GCodeParser:
self.fan = self.printer.lookup_object('fan', None)
if self.is_fileinput and self.fd_handle is None:
self.fd_handle = self.reactor.register_fd(self.fd, self.process_data)
+ self._respond_state("Ready")
def reset_last_position(self):
self.last_position = self.position_with_transform()
def dump_debug(self):
@@ -287,6 +291,8 @@ class GCodeParser:
self.respond('!! %s' % (lines[0].strip(),))
if self.is_fileinput:
self.printer.request_exit('error_exit')
+ def _respond_state(self, state):
+ self.respond_info("Klipper state: %s" % (state,))
# Parameter parsing helpers
class sentinel: pass
def get_str(self, name, params, default=sentinel, parser=str,
@@ -671,11 +677,12 @@ class GCodeParser:
cmd_STATUS_when_not_ready = True
cmd_STATUS_help = "Report the printer status"
def cmd_STATUS(self, params):
- msg = self.printer.get_state_message()
if self.is_printer_ready:
- self.respond_info(msg)
- else:
- self.respond_error(msg)
+ self._respond_state("Ready")
+ return
+ msg = self.printer.get_state_message()
+ self._respond_state("Not ready")
+ self.respond_error(msg)
cmd_HELP_when_not_ready = True
def cmd_HELP(self, params):
cmdhelp = []
diff --git a/klippy/klippy.py b/klippy/klippy.py
index 9427036a..e88b54d8 100644
--- a/klippy/klippy.py
+++ b/klippy/klippy.py
@@ -139,7 +139,7 @@ class Printer:
self.state_message = message_startup
self.is_shutdown = False
self.run_result = None
- self.state_cb = []
+ self.state_cb = [gc.printer_state]
def get_start_args(self):
return self.start_args
def get_reactor(self):