From 20755b8244c917885c06fa85171ad0439a8cf8e0 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 9 Jun 2017 13:38:54 +1000 Subject: [PATCH] Plane: simplify should_log (NFC) --- ArduPlane/system.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ArduPlane/system.cpp b/ArduPlane/system.cpp index faafa3b028..4eaf5203b6 100644 --- a/ArduPlane/system.cpp +++ b/ArduPlane/system.cpp @@ -835,14 +835,22 @@ void Plane::print_comma(void) bool Plane::should_log(uint32_t mask) { #if LOGGING_ENABLED == ENABLED - if (!(mask & g.log_bitmask) || in_mavlink_delay) { + if (in_mavlink_delay) { return false; } - bool ret = hal.util->get_soft_armed() || DataFlash.log_while_disarmed(); - if (ret && !DataFlash.logging_started() && !in_log_download) { + if (!(mask & g.log_bitmask)) { + return false; + } + if (!hal.util->get_soft_armed() && !DataFlash.log_while_disarmed()) { + return false; + } + if (in_log_download) { + return false; + } + if (!DataFlash.logging_started()) { start_logging(); } - return ret; + return true; #else return false; #endif