From 88ab4f7d70cb31c8cb992c28b02e6f9fbc7e093a Mon Sep 17 00:00:00 2001 From: Doug Weibel Date: Mon, 28 Nov 2011 19:13:18 -0700 Subject: [PATCH] Fix for intermittent bug of log #1 starting on page 2 and confusing file system --- ArduCopter/Log.pde | 10 +++------- ArduPlane/Log.pde | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/ArduCopter/Log.pde b/ArduCopter/Log.pde index c9adce420f..42d854afc0 100644 --- a/ArduCopter/Log.pde +++ b/ArduCopter/Log.pde @@ -234,13 +234,9 @@ static byte get_num_logs(void) // This function starts a new log file in the DataFlash static void start_new_log() { - uint16_t last_page; - - if(g.log_last_filenumber < 1) { - last_page = 0; - } else { - last_page = find_last(); - } + uint16_t last_page = find_last(); + if(last_page == 1) last_page = 0; + g.log_last_filenumber.set_and_save(g.log_last_filenumber+1); DataFlash.SetFileNumber(g.log_last_filenumber); DataFlash.StartWrite(last_page + 1); diff --git a/ArduPlane/Log.pde b/ArduPlane/Log.pde index b6b8d22a4b..db61ee5f3f 100644 --- a/ArduPlane/Log.pde +++ b/ArduPlane/Log.pde @@ -234,13 +234,9 @@ static byte get_num_logs(void) // This function starts a new log file in the DataFlash static void start_new_log() { - uint16_t last_page; - - if(g.log_last_filenumber < 1) { - last_page = 0; - } else { - last_page = find_last(); - } + uint16_t last_page = find_last(); + if(last_page == 1) last_page = 0; + g.log_last_filenumber.set_and_save(g.log_last_filenumber+1); DataFlash.SetFileNumber(g.log_last_filenumber); DataFlash.StartWrite(last_page + 1);