Right now, shutdown messages from the mcu contain limited information about the cause of the shutdown, just the timer at the point that try_shutdown() was called and a static string.
It would be nice to add a few new fields to this m->h message including optional information about the cause of the shutdown. Since the static string is already enumerated in the dictionary, it can be used as a substitute for a shutdown cause.
However, many causes of shutdowns could provide additional specifics, such as would be valuable to the user when troubleshooting.
For example: Timer too close from timer.c could include the waketime of the timer that was in the past (as could the reschedule in the past cases) to aid the end user in determining which timer, or ADC out of range could include the oid of the ADC that went out of range. This would allow error_mcu on the host to provide some useful information.
One way of doing this could go like this:
- Change the signature of the “shutdown” response including an extra field in both klipper and klippy.
- Create a new sched_shutdown_extra(uint_fast8_t reason, unit_64 extra_data)
- Replace sched_shutdown with one that calls sched_shutdown_extra with 0 in extra_data
- Extend error_mcu.py to decode and print the extra data field where appropriate.