From bc911d15d1ddf4b26e58ce0219cec6043fb1ac93 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 13 May 2016 15:57:53 +1000 Subject: [PATCH] AP_TECS: convert to using Log_Write preparation for a TEC2 message --- libraries/AP_TECS/AP_TECS.cpp | 22 +++++++++++++++++----- libraries/AP_TECS/AP_TECS.h | 4 +--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/libraries/AP_TECS/AP_TECS.cpp b/libraries/AP_TECS/AP_TECS.cpp index f9ecb72452..dbce4e221d 100644 --- a/libraries/AP_TECS/AP_TECS.cpp +++ b/libraries/AP_TECS/AP_TECS.cpp @@ -1042,10 +1042,22 @@ void AP_TECS::update_pitch_throttle(int32_t hgt_dem_cm, } // log the contents of the log_tuning structure to dataflash -void AP_TECS::log_data(DataFlash_Class &dataflash, uint8_t msgid) +void AP_TECS::log_data(DataFlash_Class &dataflash) { - log_tuning.head1 = HEAD_BYTE1; - log_tuning.head2 = HEAD_BYTE2; - log_tuning.msgid = msgid; - dataflash.WriteBlock(&log_tuning, sizeof(log_tuning)); + dataflash.Log_Write("TECS", "TimeUS,h,dh,hdem,dhdem,spdem,sp,dsp,ith,iph,th,ph,dspdem,w,f", "QfffffffffffffB", + AP_HAL::micros64(), + log_tuning.hgt, + log_tuning.dhgt, + log_tuning.hgt_dem, + log_tuning.dhgt_dem, + log_tuning.spd_dem, + log_tuning.spd, + log_tuning.dspd, + log_tuning.ithr, + log_tuning.iptch, + log_tuning.thr, + log_tuning.ptch, + log_tuning.dspd_dem, + log_tuning.speed_weight, + log_tuning.flags); } diff --git a/libraries/AP_TECS/AP_TECS.h b/libraries/AP_TECS/AP_TECS.h index 2878020d17..b7785f225f 100644 --- a/libraries/AP_TECS/AP_TECS.h +++ b/libraries/AP_TECS/AP_TECS.h @@ -70,7 +70,7 @@ public: } // log data on internal state of the controller. Called at 10Hz - void log_data(DataFlash_Class &dataflash, uint8_t msgid); + void log_data(DataFlash_Class &dataflash); // return current target airspeed float get_target_airspeed(void) const { @@ -357,5 +357,3 @@ private: float timeConstant(void) const; }; -#define TECS_LOG_FORMAT(msg) { msg, sizeof(AP_TECS::log_TECS_Tuning), \ - "TECS", "QfffffffffffffB", "TimeUS,h,dh,hdem,dhdem,spdem,sp,dsp,ith,iph,th,ph,dspdem,w,f" }