DataFlash: allow drivers to setup their own logging formats

this allows drivers to ask the dataflash driver to add new log formats
This commit is contained in:
Andrew Tridgell 2014-03-24 12:03:31 +11:00
parent 5630bb1ef6
commit 1b1a92251f
2 changed files with 15 additions and 0 deletions

View File

@ -44,6 +44,7 @@ public:
/* logging methods common to all vehicles */
uint16_t StartNewLog(void);
void AddLogFormats(const struct LogStructure *structures, uint8_t num_types);
void EnableWrites(bool enable) { _writes_enabled = enable; }
void Log_Write_Format(const struct LogStructure *structure);
void Log_Write_Parameter(const char *name, float value);
@ -387,6 +388,8 @@ struct PACKED log_Radio {
{ LOG_RADIO_MSG, sizeof(log_Radio), \
"RAD", "IBBBBBHH", "TimeMS,RSSI,RemRSSI,TxBuf,Noise,RemNoise,RxErrors,Fixed" }
// message types 0 to 100 reversed for vehicle specific use
// message types for common messages
#define LOG_FORMAT_MSG 128
#define LOG_PARAMETER_MSG 129
@ -408,6 +411,8 @@ struct PACKED log_Radio {
#define LOG_CMD_MSG 145
#define LOG_RADIO_MSG 146
// message types 200 to 210 reversed for GPS driver use
#include "DataFlash_Block.h"
#include "DataFlash_File.h"

View File

@ -576,6 +576,16 @@ uint16_t DataFlash_Class::StartNewLog(void)
return ret;
}
// add new logging formats to the log. Used by libraries that want to
// add their own log messages
void DataFlash_Class::AddLogFormats(const struct LogStructure *structures, uint8_t num_types)
{
// write new log formats
for (uint8_t i=0; i<num_types; i++) {
Log_Write_Format(&structures[i]);
}
}
/*
write a structure format to the log
*/