diff --git a/libraries/AP_InternalError/AP_InternalError.cpp b/libraries/AP_InternalError/AP_InternalError.cpp index e90a64fb50..52217a3289 100644 --- a/libraries/AP_InternalError/AP_InternalError.cpp +++ b/libraries/AP_InternalError/AP_InternalError.cpp @@ -1,15 +1,24 @@ #include "AP_InternalError.h" +extern const AP_HAL::HAL &hal; + // actually create the instance: static AP_InternalError instance; void AP_InternalError::error(const AP_InternalError::error_t e) { #if CONFIG_HAL_BOARD == HAL_BOARD_SITL - if (e != AP_InternalError::error_t::watchdog_reset) { + switch (e) { + case AP_InternalError::error_t::watchdog_reset: + case AP_InternalError::error_t::main_loop_stuck: + // don't panic on these to facilitate watchdog testing + break; + default: AP_HAL::panic("internal error %u", unsigned(e)); } #endif internal_errors |= uint32_t(e); + hal.util->persistent_data.internal_errors = internal_errors; + hal.util->persistent_data.internal_error_count++; } diff --git a/libraries/AP_InternalError/AP_InternalError.h b/libraries/AP_InternalError/AP_InternalError.h index cc46ebe4bc..160ba0526d 100644 --- a/libraries/AP_InternalError/AP_InternalError.h +++ b/libraries/AP_InternalError/AP_InternalError.h @@ -48,6 +48,7 @@ public: iomcu_reset = (1U << 12), iomcu_fail = (1U << 13), spi_fail = (1U << 14), + main_loop_stuck = (1U << 15), }; void error(const AP_InternalError::error_t error);