From 8660e98b575a422c14a8f917664ea34bde8cf9db Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 20 Jul 2021 14:36:10 +1000 Subject: [PATCH] AP_Parachute: added arming_checks() --- libraries/AP_Parachute/AP_Parachute.cpp | 17 +++++++++++++++++ libraries/AP_Parachute/AP_Parachute.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/libraries/AP_Parachute/AP_Parachute.cpp b/libraries/AP_Parachute/AP_Parachute.cpp index 50f6339c7e..59dfe32aa8 100644 --- a/libraries/AP_Parachute/AP_Parachute.cpp +++ b/libraries/AP_Parachute/AP_Parachute.cpp @@ -187,6 +187,23 @@ void AP_Parachute::check_sink_rate() } } +// check settings are valid +bool AP_Parachute::arming_checks(size_t buflen, char *buffer) const +{ + if (_enabled > 0) { + if (_release_type == AP_PARACHUTE_TRIGGER_TYPE_SERVO) { + if (!SRV_Channels::function_assigned(SRV_Channel::k_parachute_release)) { + hal.util->snprintf(buffer, buflen, "Chute has no channel"); + return false; + } + } else if (!_relay.enabled(_release_type)) { + hal.util->snprintf(buffer, buflen, "Chute invalid relay %d", _release_type); + return false; + } + } + return true; +} + // singleton instance AP_Parachute *AP_Parachute::_singleton; diff --git a/libraries/AP_Parachute/AP_Parachute.h b/libraries/AP_Parachute/AP_Parachute.h index 0669343442..261b5707d9 100644 --- a/libraries/AP_Parachute/AP_Parachute.h +++ b/libraries/AP_Parachute/AP_Parachute.h @@ -86,6 +86,9 @@ public: // trigger parachute release if sink_rate is below critical_sink_rate for 1sec void check_sink_rate(); + // check settings are valid + bool arming_checks(size_t buflen, char *buffer) const; + static const struct AP_Param::GroupInfo var_info[]; // get singleton instance