gcode: Send proactive state messages
Send a g-code info message on printer state changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
91691afdcf
commit
094b9de69e
|
@ -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
|
commands - "status" and "restart" are examples of these commands. Use
|
||||||
the "help" command to get a list of other extended commands.
|
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
|
[config check document](Config_checks.md) to perform some basic checks
|
||||||
on the pin definitions in the config file.
|
on the pin definitions in the config file.
|
||||||
|
|
||||||
|
|
|
@ -106,8 +106,11 @@ class GCodeParser:
|
||||||
self.dump_debug()
|
self.dump_debug()
|
||||||
if self.is_fileinput:
|
if self.is_fileinput:
|
||||||
self.printer.request_exit('error_exit')
|
self.printer.request_exit('error_exit')
|
||||||
|
self._respond_state("Shutdown")
|
||||||
return
|
return
|
||||||
if state != 'ready':
|
if state != 'ready':
|
||||||
|
if state == 'disconnect':
|
||||||
|
self._respond_state("Disconnect")
|
||||||
return
|
return
|
||||||
self.is_printer_ready = True
|
self.is_printer_ready = True
|
||||||
self.gcode_handlers = self.ready_gcode_handlers
|
self.gcode_handlers = self.ready_gcode_handlers
|
||||||
|
@ -125,6 +128,7 @@ class GCodeParser:
|
||||||
self.fan = self.printer.lookup_object('fan', None)
|
self.fan = self.printer.lookup_object('fan', None)
|
||||||
if self.is_fileinput and self.fd_handle is None:
|
if self.is_fileinput and self.fd_handle is None:
|
||||||
self.fd_handle = self.reactor.register_fd(self.fd, self.process_data)
|
self.fd_handle = self.reactor.register_fd(self.fd, self.process_data)
|
||||||
|
self._respond_state("Ready")
|
||||||
def reset_last_position(self):
|
def reset_last_position(self):
|
||||||
self.last_position = self.position_with_transform()
|
self.last_position = self.position_with_transform()
|
||||||
def dump_debug(self):
|
def dump_debug(self):
|
||||||
|
@ -287,6 +291,8 @@ class GCodeParser:
|
||||||
self.respond('!! %s' % (lines[0].strip(),))
|
self.respond('!! %s' % (lines[0].strip(),))
|
||||||
if self.is_fileinput:
|
if self.is_fileinput:
|
||||||
self.printer.request_exit('error_exit')
|
self.printer.request_exit('error_exit')
|
||||||
|
def _respond_state(self, state):
|
||||||
|
self.respond_info("Klipper state: %s" % (state,))
|
||||||
# Parameter parsing helpers
|
# Parameter parsing helpers
|
||||||
class sentinel: pass
|
class sentinel: pass
|
||||||
def get_str(self, name, params, default=sentinel, parser=str,
|
def get_str(self, name, params, default=sentinel, parser=str,
|
||||||
|
@ -671,11 +677,12 @@ class GCodeParser:
|
||||||
cmd_STATUS_when_not_ready = True
|
cmd_STATUS_when_not_ready = True
|
||||||
cmd_STATUS_help = "Report the printer status"
|
cmd_STATUS_help = "Report the printer status"
|
||||||
def cmd_STATUS(self, params):
|
def cmd_STATUS(self, params):
|
||||||
msg = self.printer.get_state_message()
|
|
||||||
if self.is_printer_ready:
|
if self.is_printer_ready:
|
||||||
self.respond_info(msg)
|
self._respond_state("Ready")
|
||||||
else:
|
return
|
||||||
self.respond_error(msg)
|
msg = self.printer.get_state_message()
|
||||||
|
self._respond_state("Not ready")
|
||||||
|
self.respond_error(msg)
|
||||||
cmd_HELP_when_not_ready = True
|
cmd_HELP_when_not_ready = True
|
||||||
def cmd_HELP(self, params):
|
def cmd_HELP(self, params):
|
||||||
cmdhelp = []
|
cmdhelp = []
|
||||||
|
|
|
@ -139,7 +139,7 @@ class Printer:
|
||||||
self.state_message = message_startup
|
self.state_message = message_startup
|
||||||
self.is_shutdown = False
|
self.is_shutdown = False
|
||||||
self.run_result = None
|
self.run_result = None
|
||||||
self.state_cb = []
|
self.state_cb = [gc.printer_state]
|
||||||
def get_start_args(self):
|
def get_start_args(self):
|
||||||
return self.start_args
|
return self.start_args
|
||||||
def get_reactor(self):
|
def get_reactor(self):
|
||||||
|
|
Loading…
Reference in New Issue