mcu: Provide some further help on common MCU shutdown errors

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-09-05 21:15:24 -04:00
parent 68fc6abf74
commit 09e32d1b84
5 changed files with 32 additions and 7 deletions

View File

@ -242,8 +242,7 @@ class Printer:
def note_shutdown(self, msg): def note_shutdown(self, msg):
if self.state_message == message_ready: if self.state_message == message_ready:
self.need_dump_debug = True self.need_dump_debug = True
self.state_message = "Firmware shutdown: %s%s" % ( self.state_message = "%s%s" % (msg, message_shutdown)
msg, message_shutdown)
self.gcode.set_printer_ready(False) self.gcode.set_printer_ready(False)
def note_mcu_error(self, msg): def note_mcu_error(self, msg):
self.state_message = "%s%s" % (msg, message_restart) self.state_message = "%s%s" % (msg, message_restart)

View File

@ -475,13 +475,16 @@ class MCU:
if self.is_shutdown: if self.is_shutdown:
return return
self.is_shutdown = True self.is_shutdown = True
self._shutdown_msg = params['#msg'] self._shutdown_msg = msg = params['#msg']
logging.info("%s: %s" % (params['#name'], self._shutdown_msg)) logging.info("%s: %s" % (params['#name'], self._shutdown_msg))
pst = self._print_start_time pst = self._print_start_time
logging.info("Clock last synchronized at %.6f (%d)" % ( logging.info("Clock last synchronized at %.6f (%d)" % (
pst, int(pst * self._mcu_freq))) pst, int(pst * self._mcu_freq)))
self.serial.dump_debug() self.serial.dump_debug()
self._printer.note_shutdown(self._shutdown_msg) prefix = "MCU shutdown: "
if params['#name'] == 'is_shutdown':
prefix = "Previous MCU shutdown: "
self._printer.note_shutdown(prefix + msg + error_help(msg))
# Connection phase # Connection phase
def _check_restart(self, reason): def _check_restart(self, reason):
start_reason = self._printer.get_start_args().get("start_reason") start_reason = self._printer.get_start_args().get("start_reason")
@ -742,5 +745,28 @@ class MCU:
def __del__(self): def __del__(self):
self.disconnect() self.disconnect()
Common_MCU_errors = {
("Timer too close", "No next step", "Missed scheduling of next "): """
This is generally indicative of an intermittent
communication failure.""",
("ADC out of range",): """
This generally occurs when a heater temperature exceeds
it's configured min_temp or max_temp.""",
("Rescheduled timer in the past", "Stepper too far in past"): """
This generally occurs when the micro-controller has been
requested to step at a rate higher than it is capable of
obtaining.""",
("Command request",): """
This generally occurs in response to an M112 G-Code command
or in response to an internal error in the host software.""",
}
def error_help(msg):
for prefixes, help_msg in Common_MCU_errors.items():
for prefix in prefixes:
if msg.startswith(prefix):
return help_msg
return ""
def add_printer_objects(printer, config): def add_printer_objects(printer, config):
printer.add_object('mcu', MCU(printer, config.getsection('mcu'))) printer.add_object('mcu', MCU(printer, config.getsection('mcu')))

View File

@ -43,7 +43,7 @@ analog_in_event(struct timer *timer)
return SF_RESCHEDULE; return SF_RESCHEDULE;
} }
if (a->value < a->min_value || a->value > a->max_value) if (a->value < a->min_value || a->value > a->max_value)
shutdown("adc out of range"); shutdown("ADC out of range");
sched_wake_task(&analog_wake); sched_wake_task(&analog_wake);
a->next_begin_time += a->rest_time; a->next_begin_time += a->rest_time;
a->timer.waketime = a->next_begin_time; a->timer.waketime = a->next_begin_time;

View File

@ -297,7 +297,7 @@ stats_update(uint32_t start, uint32_t cur)
void void
command_emergency_stop(uint32_t *args) command_emergency_stop(uint32_t *args)
{ {
shutdown("command request"); shutdown("Command request");
} }
DECL_COMMAND_FLAGS(command_emergency_stop, HF_IN_SHUTDOWN, "emergency_stop"); DECL_COMMAND_FLAGS(command_emergency_stop, HF_IN_SHUTDOWN, "emergency_stop");

View File

@ -79,7 +79,7 @@ stepper_load_next(struct stepper *s, uint32_t min_next_time)
if (unlikely(timer_is_before(s->next_step_time, min_next_time))) { if (unlikely(timer_is_before(s->next_step_time, min_next_time))) {
if ((int32_t)(s->next_step_time - min_next_time) if ((int32_t)(s->next_step_time - min_next_time)
< (int32_t)(-timer_from_us(1000))) < (int32_t)(-timer_from_us(1000)))
shutdown("stepper too far in past"); shutdown("Stepper too far in past");
s->time.waketime = min_next_time; s->time.waketime = min_next_time;
} else { } else {
s->time.waketime = s->next_step_time; s->time.waketime = s->next_step_time;