void DataFlash_Class::Init(const struct LogStructure *structures, uint8_t num_types) { gcs().send_text(MAV_SEVERITY_INFO, "Preparing log system"); #if CONFIG_HAL_BOARD == HAL_BOARD_SITL validate_structures(structures, num_types); dump_structures(structures, num_types); #endif 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(); } Prep(); EnableWrites(true); gcs().send_text(MAV_SEVERITY_INFO, "Prepared log system"); }
void DataFlash_Class::EnableWrites(bool enable) { FOR_EACH_BACKEND(EnableWrites(enable)); }
void AP_Logger::Init(const struct LogStructure *structures, uint8_t num_types) { gcs().send_text(MAV_SEVERITY_INFO, "Preparing log system"); #if CONFIG_HAL_BOARD == HAL_BOARD_SITL validate_structures(structures, num_types); dump_structures(structures, num_types); #endif 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 HAL_OS_POSIX_IO || HAL_OS_FATFS_IO if (_params.backend_types & uint8_t(Backend_Type::FILESYSTEM)) { LoggerMessageWriter_DFLogStart *message_writer = new LoggerMessageWriter_DFLogStart(); if (message_writer != nullptr) { backends[_next_backend] = new AP_Logger_File(*this, message_writer, HAL_BOARD_LOG_DIRECTORY); } if (backends[_next_backend] == nullptr) { hal.console->printf("Unable to open AP_Logger_File"); } else { _next_backend++; } } #endif #endif // HAL_BOARD_LOG_DIRECTORY #if DATAFLASH_MAVLINK_SUPPORT if (_params.backend_types & uint8_t(Backend_Type::MAVLINK)) { if (_next_backend == DATAFLASH_MAX_BACKENDS) { AP_HAL::panic("Too many backends"); return; } LoggerMessageWriter_DFLogStart *message_writer = new LoggerMessageWriter_DFLogStart(); if (message_writer != nullptr) { backends[_next_backend] = new AP_Logger_MAVLink(*this, message_writer); } if (backends[_next_backend] == nullptr) { hal.console->printf("Unable to open AP_Logger_MAVLink"); } else { _next_backend++; } } #endif #if CONFIG_HAL_BOARD == HAL_BOARD_SITL if (_params.backend_types & uint8_t(Backend_Type::BLOCK)) { if (_next_backend == DATAFLASH_MAX_BACKENDS) { AP_HAL::panic("Too many backends"); return; } LoggerMessageWriter_DFLogStart *message_writer = new LoggerMessageWriter_DFLogStart(); if (message_writer != nullptr) { backends[_next_backend] = new AP_Logger_SITL(*this, message_writer); } if (backends[_next_backend] == nullptr) { hal.console->printf("Unable to open AP_Logger_SITL"); } else { _next_backend++; } } #endif #ifdef HAL_LOGGING_DATAFLASH if (_params.backend_types & uint8_t(Backend_Type::BLOCK)) { if (_next_backend == DATAFLASH_MAX_BACKENDS) { AP_HAL::panic("Too many backends"); return; } LoggerMessageWriter_DFLogStart *message_writer = new LoggerMessageWriter_DFLogStart(); if (message_writer != nullptr) { backends[_next_backend] = new AP_Logger_DataFlash(*this, message_writer); } if (backends[_next_backend] == nullptr) { hal.console->printf("Unable to open AP_Logger_DataFlash"); } else { _next_backend++; } } #endif for (uint8_t i=0; i<_next_backend; i++) { backends[i]->Init(); } Prep(); EnableWrites(true); gcs().send_text(MAV_SEVERITY_INFO, "Prepared log system"); }