DataFlash: simplify dataflash initialisation

This commit is contained in:
Peter Barker 2017-06-12 23:05:02 +10:00 committed by Francisco Ferreira
parent 5a0cb40c47
commit 91b62abfe5
3 changed files with 13 additions and 4 deletions

View File

@ -4,6 +4,7 @@
#include "DataFlash_File.h"
#include "DataFlash_MAVLink.h"
#include <GCS_MAVLink/GCS.h>
DataFlash_Class *DataFlash_Class::_instance;
@ -49,6 +50,7 @@ const AP_Param::GroupInfo DataFlash_Class::var_info[] = {
void DataFlash_Class::Init(const struct LogStructure *structures, uint8_t num_types)
{
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_INFO, "Preparing log system");
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
validate_structures(structures, num_types);
dump_structures(structures, num_types);
@ -104,6 +106,10 @@ void DataFlash_Class::Init(const struct LogStructure *structures, uint8_t num_ty
for (uint8_t i=0; i<_next_backend; i++) {
backends[i]->Init();
}
Prep();
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_INFO, "Prepared log system");
}
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL

View File

@ -74,10 +74,6 @@ public:
bool NeedErase(void);
void EraseAll();
// possibly expensive calls to start log system:
bool NeedPrep();
void Prep();
// get a pointer to structures
const struct LogStructure *get_structures(uint8_t &num_types) {
num_types = _num_types;
@ -286,4 +282,8 @@ private:
void dump_structures(const struct LogStructure *structures, const uint8_t num_types);
void Log_Write_EKF_Timing(const char *name, uint64_t time_us, const struct ekf_timing &timing);
// possibly expensive calls to start log system:
void Prep();
bool NeedPrep();
};

View File

@ -397,6 +397,9 @@ void DataFlash_File::Prep_MinSpace()
#endif
void DataFlash_File::Prep() {
if (!NeedPrep()) {
return;
}
if (hal.util->get_soft_armed()) {
// do not want to do any filesystem operations while we are e.g. flying
return;