From a0e291bf8951693b06f0bac4c92408711b2ee1ca Mon Sep 17 00:00:00 2001 From: Jonathan Challinger Date: Mon, 25 Jan 2016 15:45:27 -0800 Subject: [PATCH] DataFlash: add reason to MODE --- libraries/DataFlash/DataFlash.cpp | 4 ++-- libraries/DataFlash/DataFlash.h | 2 +- libraries/DataFlash/DataFlash_Backend.h | 2 +- libraries/DataFlash/LogFile.cpp | 5 +++-- libraries/DataFlash/LogStructure.h | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libraries/DataFlash/DataFlash.cpp b/libraries/DataFlash/DataFlash.cpp index 6c19adc198..e79b9144cf 100644 --- a/libraries/DataFlash/DataFlash.cpp +++ b/libraries/DataFlash/DataFlash.cpp @@ -187,9 +187,9 @@ void DataFlash_Class::Log_Write_Message(const char *message) FOR_EACH_BACKEND(Log_Write_Message(message)); } -void DataFlash_Class::Log_Write_Mode(uint8_t mode) +void DataFlash_Class::Log_Write_Mode(uint8_t mode, uint8_t reason) { - FOR_EACH_BACKEND(Log_Write_Mode(mode)); + FOR_EACH_BACKEND(Log_Write_Mode(mode, reason)); } void DataFlash_Class::Log_Write_Parameter(const char *name, float value) diff --git a/libraries/DataFlash/DataFlash.h b/libraries/DataFlash/DataFlash.h index 7726e6da18..16df684b8a 100644 --- a/libraries/DataFlash/DataFlash.h +++ b/libraries/DataFlash/DataFlash.h @@ -121,7 +121,7 @@ public: void Log_Write_Attitude(AP_AHRS &ahrs, const Vector3f &targets); void Log_Write_Current(const AP_BattMonitor &battery, int16_t throttle); void Log_Write_Compass(const Compass &compass); - void Log_Write_Mode(uint8_t mode); + void Log_Write_Mode(uint8_t mode, uint8_t reason = 0); void Log_Write_EntireMission(const AP_Mission &mission); void Log_Write_Mission_Cmd(const AP_Mission &mission, diff --git a/libraries/DataFlash/DataFlash_Backend.h b/libraries/DataFlash/DataFlash_Backend.h index 51fc331742..7a66e7c2d2 100644 --- a/libraries/DataFlash/DataFlash_Backend.h +++ b/libraries/DataFlash/DataFlash_Backend.h @@ -88,7 +88,7 @@ public: bool Log_Write_Message(const char *message); bool Log_Write_Mission_Cmd(const AP_Mission &mission, const AP_Mission::Mission_Command &cmd); - bool Log_Write_Mode(uint8_t mode);; + bool Log_Write_Mode(uint8_t mode, uint8_t reason = 0); bool Log_Write_Parameter(const char *name, float value); bool Log_Write_Parameter(const AP_Param *ap, const AP_Param::ParamToken &token, diff --git a/libraries/DataFlash/LogFile.cpp b/libraries/DataFlash/LogFile.cpp index 85aa5ca4ee..b743103993 100644 --- a/libraries/DataFlash/LogFile.cpp +++ b/libraries/DataFlash/LogFile.cpp @@ -1687,13 +1687,14 @@ void DataFlash_Class::Log_Write_Compass(const Compass &compass) } // Write a mode packet. -bool DataFlash_Backend::Log_Write_Mode(uint8_t mode) +bool DataFlash_Backend::Log_Write_Mode(uint8_t mode, uint8_t reason) { struct log_Mode pkt = { LOG_PACKET_HEADER_INIT(LOG_MODE_MSG), time_us : AP_HAL::micros64(), mode : mode, - mode_num : mode + mode_num : mode, + mode_reason : reason }; return WriteCriticalBlock(&pkt, sizeof(pkt)); } diff --git a/libraries/DataFlash/LogStructure.h b/libraries/DataFlash/LogStructure.h index 08911a4626..e778729ad3 100644 --- a/libraries/DataFlash/LogStructure.h +++ b/libraries/DataFlash/LogStructure.h @@ -445,6 +445,7 @@ struct PACKED log_Mode { uint64_t time_us; uint8_t mode; uint8_t mode_num; + uint8_t mode_reason; }; /* @@ -750,7 +751,7 @@ Format characters in the format string for binary log messages { LOG_COMPASS_MSG, sizeof(log_Compass), \ "MAG", "QhhhhhhhhhB", "TimeUS,MagX,MagY,MagZ,OfsX,OfsY,OfsZ,MOfsX,MOfsY,MOfsZ,Health" }, \ { LOG_MODE_MSG, sizeof(log_Mode), \ - "MODE", "QMB", "TimeUS,Mode,ModeNum" }, \ + "MODE", "QMBB", "TimeUS,Mode,ModeNum,Rsn" }, \ { LOG_RFND_MSG, sizeof(log_RFND), \ "RFND", "QCC", "TimeUS,Dist1,Dist2" }, \ { LOG_DF_MAV_STATS, sizeof(log_DF_MAV_Stats), \