From d85b2477065be2d06312a5930162dcb530ffb0ca Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 24 Jun 2015 11:09:01 +1000 Subject: [PATCH] DataFlash: Log_Write_SysInfo - pull out common logging startup messages --- libraries/DataFlash/DataFlash.h | 1 + libraries/DataFlash/LogFile.cpp | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/libraries/DataFlash/DataFlash.h b/libraries/DataFlash/DataFlash.h index 55753fc817..02ae269419 100644 --- a/libraries/DataFlash/DataFlash.h +++ b/libraries/DataFlash/DataFlash.h @@ -62,6 +62,7 @@ public: uint16_t StartNewLog(void); void AddLogFormats(const struct LogStructure *structures, uint8_t num_types); void EnableWrites(bool enable); + void Log_Write_SysInfo(const prog_char_t *firmware_string); void Log_Write_Format(const struct LogStructure *structure); void Log_Write_Parameter(const char *name, float value); void Log_Write_GPS(const AP_GPS &gps, uint8_t instance, int32_t relative_alt); diff --git a/libraries/DataFlash/LogFile.cpp b/libraries/DataFlash/LogFile.cpp index 3aabc7c2f4..d361db42d2 100644 --- a/libraries/DataFlash/LogFile.cpp +++ b/libraries/DataFlash/LogFile.cpp @@ -591,13 +591,13 @@ void DataFlash_Block::ListAvailableLogs(AP_HAL::BetterStream *port) #endif // DATAFLASH_NO_CLI // This function starts a new log file in the DataFlash, and writes -// the format of supported messages in the log, plus all parameters +// the format of supported messages in the log uint16_t DataFlash_Class::StartNewLog(void) { uint16_t ret; ret = start_new_log(); if (ret == 0xFFFF) { - // don't write out parameters if we fail to open the log + // don't write out formats if we fail to open the log return ret; } // write log formats so the log is self-describing @@ -977,6 +977,24 @@ void DataFlash_Class::Log_Write_Vibration(const AP_InertialSensor &ins) #endif } +void DataFlash_Class::Log_Write_SysInfo(const prog_char_t *firmware_string) +{ + Log_Write_Message_P(firmware_string); + +#if defined(PX4_GIT_VERSION) && defined(NUTTX_GIT_VERSION) + Log_Write_Message_P(PSTR("PX4: " PX4_GIT_VERSION " NuttX: " NUTTX_GIT_VERSION)); +#endif + + // write system identifier as well if available + char sysid[40]; + if (hal.util->get_system_id(sysid)) { + Log_Write_Message(sysid); + } + + // Write all current parameters + Log_Write_Parameters(); +} + // Write a text message to the log void DataFlash_Class::Log_Write_Message(const char *message) {