Browse Source

DataFlash: simplify dataflash initialisation

mission-4.1.18
Peter Barker 8 years ago committed by Francisco Ferreira
parent
commit
91b62abfe5
  1. 6
      libraries/DataFlash/DataFlash.cpp
  2. 8
      libraries/DataFlash/DataFlash.h
  3. 3
      libraries/DataFlash/DataFlash_File.cpp

6
libraries/DataFlash/DataFlash.cpp

@ -4,6 +4,7 @@ @@ -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[] = { @@ -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 @@ -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

8
libraries/DataFlash/DataFlash.h

@ -74,10 +74,6 @@ public: @@ -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: @@ -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();
};

3
libraries/DataFlash/DataFlash_File.cpp

@ -397,6 +397,9 @@ void DataFlash_File::Prep_MinSpace() @@ -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;

Loading…
Cancel
Save