diff --git a/libraries/AP_Arming/AP_Arming.cpp b/libraries/AP_Arming/AP_Arming.cpp index 110cbad667..c698883648 100644 --- a/libraries/AP_Arming/AP_Arming.cpp +++ b/libraries/AP_Arming/AP_Arming.cpp @@ -538,6 +538,19 @@ bool AP_Arming::board_voltage_checks(bool report) return true; } +/* + check base system operations + */ +bool AP_Arming::system_checks(bool report) +{ + if ((checks_to_perform & ARMING_CHECK_ALL) || (checks_to_perform & ARMING_CHECK_SYSTEM)) { + if (!hal.storage->healthy()) { + check_failed(ARMING_CHECK_SYSTEM, report, "Param storage failed"); + } + } + return true; +} + bool AP_Arming::pre_arm_checks(bool report) { #if !APM_BUILD_TYPE(APM_BUILD_ArduCopter) @@ -557,7 +570,8 @@ bool AP_Arming::pre_arm_checks(bool report) & logging_checks(report) & manual_transmitter_checks(report) & servo_checks(report) - & board_voltage_checks(report); + & board_voltage_checks(report) + & system_checks(report); } bool AP_Arming::arm_checks(ArmingMethod method) @@ -570,6 +584,14 @@ bool AP_Arming::arm_checks(ArmingMethod method) } } + // check system health on arm as well as prearm + if ((checks_to_perform & ARMING_CHECK_ALL) || + (checks_to_perform & ARMING_CHECK_SYSTEM)) { + if (!system_checks(true)) { + return false; + } + } + // note that this will prepare DataFlash to start logging // so should be the last check to be done before arming if ((checks_to_perform & ARMING_CHECK_ALL) || diff --git a/libraries/AP_Arming/AP_Arming.h b/libraries/AP_Arming/AP_Arming.h index 07c30ad681..95514d0e12 100644 --- a/libraries/AP_Arming/AP_Arming.h +++ b/libraries/AP_Arming/AP_Arming.h @@ -31,6 +31,7 @@ public: ARMING_CHECK_LOGGING = 0x0400, ARMING_CHECK_SWITCH = 0x0800, ARMING_CHECK_GPS_CONFIG = 0x1000, + ARMING_CHECK_SYSTEM = 0x2000, }; enum ArmingMethod { @@ -105,6 +106,8 @@ protected: bool manual_transmitter_checks(bool report); + virtual bool system_checks(bool report); + bool servo_checks(bool report) const; bool rc_checks_copter_sub(bool display_failure, const RC_Channel *channels[4], const bool check_min_max = true) const;