From 67a5c1dfc00ccf7e12ed92251d5c9a376b4404c0 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 9 Jun 2017 11:57:42 +1000 Subject: [PATCH] Sub: simplify start_logging --- ArduSub/Log.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/ArduSub/Log.cpp b/ArduSub/Log.cpp index 8c9ceb6715..87b5d035bf 100644 --- a/ArduSub/Log.cpp +++ b/ArduSub/Log.cpp @@ -466,22 +466,25 @@ void Sub::Log_Write_Vehicle_Startup_Messages() } -// start a new log void Sub::start_logging() { - if (g.log_bitmask != 0 && !in_log_download) { - if (!ap.logging_started) { - ap.logging_started = true; - DataFlash.StartNewLog(); - } else if (!DataFlash.logging_started()) { - hal.console->println("Starting new log"); - // dataflash may have stopped logging - when we get_log_data, - // for example. Try to restart: - DataFlash.StartNewLog(); - } - // enable writes - DataFlash.EnableWrites(true); + if (g.log_bitmask == 0) { + return; } + if (in_log_download) { + return; + } + + ap.logging_started = true; + + // dataflash may have stopped logging - when we get_log_data, + // for example. Always try to restart: + if (!DataFlash.logging_started()) { + DataFlash.StartNewLog(); + } + + // enable writes + DataFlash.EnableWrites(true); } void Sub::log_init(void)