From 7bdd2eb7554b432ce40cf0f77d50526a57297c5a Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 6 Mar 2019 10:09:55 +1100 Subject: [PATCH] AP_Arming: move checking of fence up --- libraries/AP_Arming/AP_Arming.cpp | 24 ++++++++++++++++++++++++ libraries/AP_Arming/AP_Arming.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/libraries/AP_Arming/AP_Arming.cpp b/libraries/AP_Arming/AP_Arming.cpp index 236d303fd8..16b011af76 100644 --- a/libraries/AP_Arming/AP_Arming.cpp +++ b/libraries/AP_Arming/AP_Arming.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #if HAL_WITH_UAVCAN #include @@ -696,6 +697,29 @@ bool AP_Arming::can_checks(bool report) return true; } + +bool AP_Arming::fence_checks(bool display_failure) +{ + const AC_Fence *fence = AP::fence(); + if (fence == nullptr) { + return true; + } + + // check fence is ready + const char *fail_msg = nullptr; + if (fence->pre_arm_check(fail_msg)) { + return true; + } + + if (fail_msg == nullptr) { + check_failed(ARMING_CHECK_NONE, display_failure, "Check fence"); + } else { + check_failed(ARMING_CHECK_NONE, display_failure, "%s", fail_msg); + } + + return false; +} + bool AP_Arming::pre_arm_checks(bool report) { #if !APM_BUILD_TYPE(APM_BUILD_ArduCopter) diff --git a/libraries/AP_Arming/AP_Arming.h b/libraries/AP_Arming/AP_Arming.h index 225df71fbf..560836bf20 100644 --- a/libraries/AP_Arming/AP_Arming.h +++ b/libraries/AP_Arming/AP_Arming.h @@ -114,6 +114,8 @@ protected: bool mission_checks(bool report); + bool fence_checks(bool report); + virtual bool system_checks(bool report); bool can_checks(bool report);