gcode: Attempt to shutdown heaters and fans prior to a RESTART

If the user requests a restart and the machine appears to be otherwise
functioning normally, then attempt to stop the heaters and fans prior
to restarting the host.  This prevents the firmware from going into a
shutdown state when the heater is on and the host restarts.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-02-12 18:42:29 -05:00
parent ab1eb70d1c
commit 29131c873a
1 changed files with 14 additions and 5 deletions

View File

@ -72,12 +72,16 @@ class GCodeParser:
if is_ready and self.is_fileinput and self.fd_handle is None: if is_ready and 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)
def motor_heater_off(self): def motor_heater_off(self):
if self.toolhead is not None: if self.toolhead is None:
return
self.toolhead.motor_off() self.toolhead.motor_off()
print_time = self.toolhead.get_last_move_time()
if self.heater_nozzle is not None: if self.heater_nozzle is not None:
self.heater_nozzle.set_temp(0., 0.) self.heater_nozzle.set_temp(print_time, 0.)
if self.heater_bed is not None: if self.heater_bed is not None:
self.heater_bed.set_temp(0., 0.) self.heater_bed.set_temp(print_time, 0.)
if self.fan is not None:
self.fan.set_speed(print_time, 0.)
def dump_debug(self): def dump_debug(self):
logging.info("Dumping gcode input %d blocks" % ( logging.info("Dumping gcode input %d blocks" % (
len(self.input_log),)) len(self.input_log),))
@ -325,7 +329,7 @@ class GCodeParser:
def cmd_M107(self, params): def cmd_M107(self, params):
# Turn fan off # Turn fan off
print_time = self.toolhead.get_last_move_time() print_time = self.toolhead.get_last_move_time()
self.fan.set_speed(print_time, 0) self.fan.set_speed(print_time, 0.)
def cmd_M206(self, params): def cmd_M206(self, params):
# Set home offset # Set home offset
for a, p in self.axis2pos.items(): for a, p in self.axis2pos.items():
@ -369,6 +373,11 @@ class GCodeParser:
cmd_RESTART_when_not_ready = True cmd_RESTART_when_not_ready = True
cmd_RESTART_help = "Reload config file and restart host software" cmd_RESTART_help = "Reload config file and restart host software"
def cmd_RESTART(self, params): def cmd_RESTART(self, params):
if self.is_printer_ready:
self.respond_info("Preparing to restart...")
self.motor_heater_off()
self.toolhead.dwell(0.500)
self.toolhead.wait_moves()
self.printer.request_restart() self.printer.request_restart()
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"