|
|
|
@ -2,6 +2,9 @@
@@ -2,6 +2,9 @@
|
|
|
|
|
|
|
|
|
|
#include "DataFlash_Backend.h" |
|
|
|
|
|
|
|
|
|
#include "DataFlash_File.h" |
|
|
|
|
#include "DataFlash_MAVLink.h" |
|
|
|
|
|
|
|
|
|
DataFlash_Class *DataFlash_Class::_instance; |
|
|
|
|
|
|
|
|
|
const AP_Param::GroupInfo DataFlash_Class::var_info[] = { |
|
|
|
@ -42,6 +45,61 @@ const AP_Param::GroupInfo DataFlash_Class::var_info[] = {
@@ -42,6 +45,61 @@ const AP_Param::GroupInfo DataFlash_Class::var_info[] = {
|
|
|
|
|
AP_GROUPEND |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
void DataFlash_Class::Init(const struct LogStructure *structures, uint8_t num_types) |
|
|
|
|
{ |
|
|
|
|
if (_next_backend == DATAFLASH_MAX_BACKENDS) { |
|
|
|
|
AP_HAL::panic("Too many backends"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
_num_types = num_types; |
|
|
|
|
_structures = structures; |
|
|
|
|
|
|
|
|
|
#if defined(HAL_BOARD_LOG_DIRECTORY) |
|
|
|
|
if (_params.backend_types == DATAFLASH_BACKEND_FILE || |
|
|
|
|
_params.backend_types == DATAFLASH_BACKEND_BOTH) { |
|
|
|
|
DFMessageWriter_DFLogStart *message_writer = |
|
|
|
|
new DFMessageWriter_DFLogStart(_firmware_string); |
|
|
|
|
if (message_writer != nullptr) { |
|
|
|
|
#if HAL_OS_POSIX_IO |
|
|
|
|
backends[_next_backend] = new DataFlash_File(*this, |
|
|
|
|
message_writer, |
|
|
|
|
HAL_BOARD_LOG_DIRECTORY); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
if (backends[_next_backend] == nullptr) { |
|
|
|
|
hal.console->printf("Unable to open DataFlash_File"); |
|
|
|
|
} else { |
|
|
|
|
_next_backend++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#if DATAFLASH_MAVLINK_SUPPORT |
|
|
|
|
if (_params.backend_types == DATAFLASH_BACKEND_MAVLINK || |
|
|
|
|
_params.backend_types == DATAFLASH_BACKEND_BOTH) { |
|
|
|
|
if (_next_backend == DATAFLASH_MAX_BACKENDS) { |
|
|
|
|
AP_HAL::panic("Too many backends"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
DFMessageWriter_DFLogStart *message_writer = |
|
|
|
|
new DFMessageWriter_DFLogStart(_firmware_string); |
|
|
|
|
if (message_writer != nullptr) { |
|
|
|
|
backends[_next_backend] = new DataFlash_MAVLink(*this, |
|
|
|
|
message_writer); |
|
|
|
|
} |
|
|
|
|
if (backends[_next_backend] == nullptr) { |
|
|
|
|
hal.console->printf("Unable to open DataFlash_MAVLink"); |
|
|
|
|
} else { |
|
|
|
|
_next_backend++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
for (uint8_t i=0; i<_next_backend; i++) { |
|
|
|
|
backends[i]->Init(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const struct LogStructure *DataFlash_Class::structure(uint16_t num) const |
|
|
|
|
{ |
|
|
|
|
return &_structures[num]; |
|
|
|
|