Copter: added logging of dropped log messages in PM message

This commit is contained in:
Andrew Tridgell 2016-04-21 16:42:25 +10:00
parent fd51c3cc16
commit 5149a49daa
3 changed files with 14 additions and 3 deletions

View File

@ -915,6 +915,7 @@ private:
uint32_t perf_info_get_max_time(); uint32_t perf_info_get_max_time();
uint32_t perf_info_get_min_time(); uint32_t perf_info_get_min_time();
uint16_t perf_info_get_num_long_running(); uint16_t perf_info_get_num_long_running();
uint32_t perf_info_get_num_dropped();
Vector3f pv_location_to_vector(const Location& loc); Vector3f pv_location_to_vector(const Location& loc);
Vector3f pv_location_to_vector_with_default(const Location& loc, const Vector3f& default_posvec); Vector3f pv_location_to_vector_with_default(const Location& loc, const Vector3f& default_posvec);
float pv_alt_above_origin(float alt_above_home_cm); float pv_alt_above_origin(float alt_above_home_cm);

View File

@ -339,6 +339,7 @@ struct PACKED log_Performance {
int16_t pm_test; int16_t pm_test;
uint8_t i2c_lockup_count; uint8_t i2c_lockup_count;
uint16_t ins_error_count; uint16_t ins_error_count;
uint32_t log_dropped;
}; };
// Write a performance monitoring packet // Write a performance monitoring packet
@ -352,9 +353,10 @@ void Copter::Log_Write_Performance()
max_time : perf_info_get_max_time(), max_time : perf_info_get_max_time(),
pm_test : pmTest1, pm_test : pmTest1,
i2c_lockup_count : hal.i2c->lockup_count(), i2c_lockup_count : hal.i2c->lockup_count(),
ins_error_count : ins.error_count() ins_error_count : ins.error_count(),
log_dropped : DataFlash.num_dropped() - perf_info_get_num_dropped(),
}; };
DataFlash.WriteBlock(&pkt, sizeof(pkt)); DataFlash.WriteCriticalBlock(&pkt, sizeof(pkt));
} }
// Write an attitude packet // Write an attitude packet
@ -731,7 +733,7 @@ const struct LogStructure Copter::log_structure[] = {
{ LOG_CONTROL_TUNING_MSG, sizeof(log_Control_Tuning), { LOG_CONTROL_TUNING_MSG, sizeof(log_Control_Tuning),
"CTUN", "Qfffffecchh", "TimeUS,ThrIn,AngBst,ThrOut,DAlt,Alt,BarAlt,DSAlt,SAlt,DCRt,CRt" }, "CTUN", "Qfffffecchh", "TimeUS,ThrIn,AngBst,ThrOut,DAlt,Alt,BarAlt,DSAlt,SAlt,DCRt,CRt" },
{ LOG_PERFORMANCE_MSG, sizeof(log_Performance), { LOG_PERFORMANCE_MSG, sizeof(log_Performance),
"PM", "QHHIhBH", "TimeUS,NLon,NLoop,MaxT,PMT,I2CErr,INSErr" }, "PM", "QHHIhBHI", "TimeUS,NLon,NLoop,MaxT,PMT,I2CErr,INSErr,LogDrop" },
{ LOG_MOTBATT_MSG, sizeof(log_MotBatt), { LOG_MOTBATT_MSG, sizeof(log_MotBatt),
"MOTB", "Qffff", "TimeUS,LiftMax,BatVolt,BatRes,ThLimit" }, "MOTB", "Qffff", "TimeUS,LiftMax,BatVolt,BatRes,ThLimit" },
{ LOG_STARTUP_MSG, sizeof(log_Startup), { LOG_STARTUP_MSG, sizeof(log_Startup),

View File

@ -15,6 +15,7 @@ static uint16_t perf_info_loop_count;
static uint32_t perf_info_max_time; static uint32_t perf_info_max_time;
static uint32_t perf_info_min_time; static uint32_t perf_info_min_time;
static uint16_t perf_info_long_running; static uint16_t perf_info_long_running;
static uint32_t perf_info_log_dropped;
static bool perf_ignore_loop = false; static bool perf_ignore_loop = false;
// perf_info_reset - reset all records of loop time to zero // perf_info_reset - reset all records of loop time to zero
@ -24,6 +25,7 @@ void Copter::perf_info_reset()
perf_info_max_time = 0; perf_info_max_time = 0;
perf_info_min_time = 0; perf_info_min_time = 0;
perf_info_long_running = 0; perf_info_long_running = 0;
perf_info_log_dropped = DataFlash.num_dropped();
} }
// perf_ignore_loop - ignore this loop from performance measurements (used to reduce false positive when arming) // perf_ignore_loop - ignore this loop from performance measurements (used to reduce false positive when arming)
@ -77,3 +79,9 @@ uint16_t Copter::perf_info_get_num_long_running()
{ {
return perf_info_long_running; return perf_info_long_running;
} }
// perf_info_get_num_dropped - get number of dropped log messages
uint32_t Copter::perf_info_get_num_dropped()
{
return perf_info_log_dropped;
}