From c9a4a6d7725acb3755945846f4be420e749f6e11 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 9 Jun 2017 14:19:11 +1000 Subject: [PATCH] DataFlash: eliminate calls to manipulate _writes_enabled --- libraries/DataFlash/DataFlash.h | 1 + libraries/DataFlash/DataFlash_Backend.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/libraries/DataFlash/DataFlash.h b/libraries/DataFlash/DataFlash.h index 3ff0211570..5b4454e1c8 100644 --- a/libraries/DataFlash/DataFlash.h +++ b/libraries/DataFlash/DataFlash.h @@ -212,6 +212,7 @@ public: bool logging_failed() const; void set_vehicle_armed(bool armed_state); + bool vehicle_is_armed() const { return _armed; } protected: diff --git a/libraries/DataFlash/DataFlash_Backend.cpp b/libraries/DataFlash/DataFlash_Backend.cpp index e579ec813a..81b6418ff4 100644 --- a/libraries/DataFlash/DataFlash_Backend.cpp +++ b/libraries/DataFlash/DataFlash_Backend.cpp @@ -265,5 +265,9 @@ bool DataFlash_Backend::WritesOK() const if (!_writes_enabled) { return false; } + if (!_front.vehicle_is_armed() && !_front.log_while_disarmed()) { + return false; + } + return true; }