mcu: Provide some further help on common MCU shutdown errors
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
68fc6abf74
commit
09e32d1b84
|
@ -242,8 +242,7 @@ class Printer:
|
|||
def note_shutdown(self, msg):
|
||||
if self.state_message == message_ready:
|
||||
self.need_dump_debug = True
|
||||
self.state_message = "Firmware shutdown: %s%s" % (
|
||||
msg, message_shutdown)
|
||||
self.state_message = "%s%s" % (msg, message_shutdown)
|
||||
self.gcode.set_printer_ready(False)
|
||||
def note_mcu_error(self, msg):
|
||||
self.state_message = "%s%s" % (msg, message_restart)
|
||||
|
|
|
@ -475,13 +475,16 @@ class MCU:
|
|||
if self.is_shutdown:
|
||||
return
|
||||
self.is_shutdown = True
|
||||
self._shutdown_msg = params['#msg']
|
||||
self._shutdown_msg = msg = params['#msg']
|
||||
logging.info("%s: %s" % (params['#name'], self._shutdown_msg))
|
||||
pst = self._print_start_time
|
||||
logging.info("Clock last synchronized at %.6f (%d)" % (
|
||||
pst, int(pst * self._mcu_freq)))
|
||||
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
|
||||
def _check_restart(self, reason):
|
||||
start_reason = self._printer.get_start_args().get("start_reason")
|
||||
|
@ -742,5 +745,28 @@ class MCU:
|
|||
def __del__(self):
|
||||
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):
|
||||
printer.add_object('mcu', MCU(printer, config.getsection('mcu')))
|
||||
|
|
|
@ -43,7 +43,7 @@ analog_in_event(struct timer *timer)
|
|||
return SF_RESCHEDULE;
|
||||
}
|
||||
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);
|
||||
a->next_begin_time += a->rest_time;
|
||||
a->timer.waketime = a->next_begin_time;
|
||||
|
|
|
@ -297,7 +297,7 @@ stats_update(uint32_t start, uint32_t cur)
|
|||
void
|
||||
command_emergency_stop(uint32_t *args)
|
||||
{
|
||||
shutdown("command request");
|
||||
shutdown("Command request");
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_emergency_stop, HF_IN_SHUTDOWN, "emergency_stop");
|
||||
|
||||
|
|
|
@ -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 ((int32_t)(s->next_step_time - min_next_time)
|
||||
< (int32_t)(-timer_from_us(1000)))
|
||||
shutdown("stepper too far in past");
|
||||
shutdown("Stepper too far in past");
|
||||
s->time.waketime = min_next_time;
|
||||
} else {
|
||||
s->time.waketime = s->next_step_time;
|
||||
|
|
Loading…
Reference in New Issue