DataFlash: Spin up more battery messages

This is crazy, because it just burned 5.5% of all possible message ID's
This commit is contained in:
Michael du Breuil 2018-09-12 16:39:30 -07:00 committed by Francisco Ferreira
parent 8b3d993b1e
commit 9b82bcc901
2 changed files with 56 additions and 11 deletions

View File

@ -1437,20 +1437,23 @@ void DataFlash_Class::Log_Write_Current_instance(const uint64_t time_us,
// Write an Current data packet
void DataFlash_Class::Log_Write_Current()
{
// Big painful assert to ensure that logging won't produce suprising results when the
// number of battery monitors changes, does have the built in expectation that
// LOG_COMPASS_MSG follows the last LOG_CURRENT_CELLSx_MSG
static_assert(((LOG_CURRENT_MSG + AP_BATT_MONITOR_MAX_INSTANCES) == LOG_CURRENT_CELLS_MSG) &&
((LOG_CURRENT_CELLS_MSG + AP_BATT_MONITOR_MAX_INSTANCES) == LOG_COMPASS_MSG),
"The number of batt monitors has changed without updating the log "
"table entries. Please add new enums for LOG_CURRENT_MSG, LOG_CURRENT_CELLS_MSG "
"directly following the highest indexed fields. Don't forget to update the log "
"description table as well.");
const uint64_t time_us = AP_HAL::micros64();
const uint8_t num_instances = AP::battery().num_instances();
if (num_instances >= 1) {
for (uint8_t i = 0; i < num_instances; i++) {
Log_Write_Current_instance(time_us,
0,
LOG_CURRENT_MSG,
LOG_CURRENT_CELLS_MSG);
}
if (num_instances >= 2) {
Log_Write_Current_instance(time_us,
1,
LOG_CURRENT2_MSG,
LOG_CURRENT_CELLS2_MSG);
i,
(LogMessages)((uint8_t)LOG_CURRENT_MSG + i),
(LogMessages)((uint8_t)LOG_CURRENT_CELLS_MSG + i));
}
}

View File

@ -1226,10 +1226,38 @@ Format characters in the format string for binary log messages
"BAT", CURR_FMT,CURR_LABELS,CURR_UNITS,CURR_MULTS }, \
{ LOG_CURRENT2_MSG, sizeof(log_Current), \
"BAT2", CURR_FMT,CURR_LABELS,CURR_UNITS,CURR_MULTS }, \
{ LOG_CURRENT3_MSG, sizeof(log_Current), \
"BAT3", CURR_FMT,CURR_LABELS,CURR_UNITS,CURR_MULTS }, \
{ LOG_CURRENT4_MSG, sizeof(log_Current), \
"BAT4", CURR_FMT,CURR_LABELS,CURR_UNITS,CURR_MULTS }, \
{ LOG_CURRENT5_MSG, sizeof(log_Current), \
"BAT5", CURR_FMT,CURR_LABELS,CURR_UNITS,CURR_MULTS }, \
{ LOG_CURRENT6_MSG, sizeof(log_Current), \
"BAT6", CURR_FMT,CURR_LABELS,CURR_UNITS,CURR_MULTS }, \
{ LOG_CURRENT7_MSG, sizeof(log_Current), \
"BAT7", CURR_FMT,CURR_LABELS,CURR_UNITS,CURR_MULTS }, \
{ LOG_CURRENT8_MSG, sizeof(log_Current), \
"BAT8", CURR_FMT,CURR_LABELS,CURR_UNITS,CURR_MULTS }, \
{ LOG_CURRENT9_MSG, sizeof(log_Current), \
"BAT9", CURR_FMT,CURR_LABELS,CURR_UNITS,CURR_MULTS }, \
{ LOG_CURRENT_CELLS_MSG, sizeof(log_Current_Cells), \
"BCL", CURR_CELL_FMT, CURR_CELL_LABELS, CURR_CELL_UNITS, CURR_CELL_MULTS }, \
{ LOG_CURRENT_CELLS2_MSG, sizeof(log_Current_Cells), \
"BCL2", CURR_CELL_FMT, CURR_CELL_LABELS, CURR_CELL_UNITS, CURR_CELL_MULTS }, \
{ LOG_CURRENT_CELLS3_MSG, sizeof(log_Current_Cells), \
"BCL3", CURR_CELL_FMT, CURR_CELL_LABELS, CURR_CELL_UNITS, CURR_CELL_MULTS }, \
{ LOG_CURRENT_CELLS4_MSG, sizeof(log_Current_Cells), \
"BCL4", CURR_CELL_FMT, CURR_CELL_LABELS, CURR_CELL_UNITS, CURR_CELL_MULTS }, \
{ LOG_CURRENT_CELLS5_MSG, sizeof(log_Current_Cells), \
"BCL5", CURR_CELL_FMT, CURR_CELL_LABELS, CURR_CELL_UNITS, CURR_CELL_MULTS }, \
{ LOG_CURRENT_CELLS6_MSG, sizeof(log_Current_Cells), \
"BCL6", CURR_CELL_FMT, CURR_CELL_LABELS, CURR_CELL_UNITS, CURR_CELL_MULTS }, \
{ LOG_CURRENT_CELLS7_MSG, sizeof(log_Current_Cells), \
"BCL7", CURR_CELL_FMT, CURR_CELL_LABELS, CURR_CELL_UNITS, CURR_CELL_MULTS }, \
{ LOG_CURRENT_CELLS8_MSG, sizeof(log_Current_Cells), \
"BCL8", CURR_CELL_FMT, CURR_CELL_LABELS, CURR_CELL_UNITS, CURR_CELL_MULTS }, \
{ LOG_CURRENT_CELLS9_MSG, sizeof(log_Current_Cells), \
"BCL9", CURR_CELL_FMT, CURR_CELL_LABELS, CURR_CELL_UNITS, CURR_CELL_MULTS }, \
{ LOG_ATTITUDE_MSG, sizeof(log_Attitude),\
"ATT", "QccccCCCC", "TimeUS,DesRoll,Roll,DesPitch,Pitch,DesYaw,Yaw,ErrRP,ErrYaw", "sddddhhdh", "FBBBBBBBB" }, \
{ LOG_COMPASS_MSG, sizeof(log_Compass), \
@ -1494,8 +1522,22 @@ enum LogMessages : uint8_t {
LOG_ATTITUDE_MSG,
LOG_CURRENT_MSG,
LOG_CURRENT2_MSG,
LOG_CURRENT3_MSG,
LOG_CURRENT4_MSG,
LOG_CURRENT5_MSG,
LOG_CURRENT6_MSG,
LOG_CURRENT7_MSG,
LOG_CURRENT8_MSG,
LOG_CURRENT9_MSG,
LOG_CURRENT_CELLS_MSG,
LOG_CURRENT_CELLS2_MSG,
LOG_CURRENT_CELLS3_MSG,
LOG_CURRENT_CELLS4_MSG,
LOG_CURRENT_CELLS5_MSG,
LOG_CURRENT_CELLS6_MSG,
LOG_CURRENT_CELLS7_MSG,
LOG_CURRENT_CELLS8_MSG,
LOG_CURRENT_CELLS9_MSG,
LOG_COMPASS_MSG,
LOG_COMPASS2_MSG,
LOG_COMPASS3_MSG,