From ab96a53ffc4df9521df6b275201112154ff4fe4f Mon Sep 17 00:00:00 2001
From: Michael Day <mday299@yahoo.com>
Date: Tue, 8 Dec 2015 15:02:55 -0800
Subject: [PATCH] Plane: battery autoland failsafe checks for ACS prelanding
 state now.

Therefore, the battery failsafe will not interrupt an already landing
plane.
---
 ArduPlane/events.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/ArduPlane/events.cpp b/ArduPlane/events.cpp
index a4fbb525f5..0c92ed971f 100644
--- a/ArduPlane/events.cpp
+++ b/ArduPlane/events.cpp
@@ -159,11 +159,13 @@ void Plane::low_battery_event(void)
                       (double)battery.voltage(), (double)battery.current_total_mah());
     if (flight_stage != AP_Vehicle::FixedWing::FLIGHT_LAND) {
 #if AP_ACS_USE == TRUE
-        gcs().send_text_P(MAV_SEVERITY_CRITICAL,PSTR("Battery low: auto-landing."));
+        if (! acs.preland_started()) {
+            gcs().send_text_P(MAV_SEVERITY_CRITICAL,PSTR("Battery low: auto-landing."));
 
-        //start landing if not already (ACS-specific behavior -- land vice RTL)
-        if (! jump_to_landing_sequence()) {
-            gcs_send_text_P(MAV_SEVERITY_CRITICAL,PSTR("Failed to start emergency land sequence!!"));
+            //start landing if not already (ACS-specific behavior -- land vice RTL)
+            if (! jump_to_landing_sequence()) {
+                gcs().send_text_P(MAV_SEVERITY_CRITICAL,PSTR("Failed to start emergency land sequence!!"));
+            }
         }
 #else
     	set_mode(RTL, MODE_REASON_BATTERY_FAILSAFE);
-- 
GitLab