mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-23 00:04:02 -04:00
DataFlash: factor out validate_structure
This commit is contained in:
parent
8d7000db2c
commit
5070628230
@ -204,15 +204,10 @@ void DataFlash_Class::dump_structures(const struct LogStructure *logstructures,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFlash_Class::validate_structures(const struct LogStructure *logstructures, const uint8_t num_types)
|
bool DataFlash_Class::validate_structure(const struct LogStructure *logstructure, const int16_t offset)
|
||||||
{
|
{
|
||||||
Debug("Validating structures");
|
|
||||||
bool passed = true;
|
bool passed = true;
|
||||||
|
|
||||||
bool seen_ids[256] = { };
|
|
||||||
for (uint16_t i=0; i<num_types; i++) {
|
|
||||||
const struct LogStructure *logstructure = &logstructures[i];
|
|
||||||
|
|
||||||
#if DEBUG_LOG_STRUCTURES
|
#if DEBUG_LOG_STRUCTURES
|
||||||
Debug("offset=%d ID=%d NAME=%s\n", i, logstructure->msg_type, logstructure->name);
|
Debug("offset=%d ID=%d NAME=%s\n", i, logstructure->msg_type, logstructure->name);
|
||||||
#endif
|
#endif
|
||||||
@ -225,7 +220,7 @@ void DataFlash_Class::validate_structures(const struct LogStructure *logstructur
|
|||||||
|
|
||||||
// ensure each message ID is only used once
|
// ensure each message ID is only used once
|
||||||
if (seen_ids[logstructure->msg_type]) {
|
if (seen_ids[logstructure->msg_type]) {
|
||||||
Debug("ID %d used twice (LogStructure offset=%d)", logstructure->msg_type, i);
|
Debug("ID %d used twice (LogStructure offset=%d)", logstructure->msg_type, offset);
|
||||||
passed = false;
|
passed = false;
|
||||||
}
|
}
|
||||||
seen_ids[logstructure->msg_type] = true;
|
seen_ids[logstructure->msg_type] = true;
|
||||||
@ -299,6 +294,17 @@ void DataFlash_Class::validate_structures(const struct LogStructure *logstructur
|
|||||||
passed = false;
|
passed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return passed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataFlash_Class::validate_structures(const struct LogStructure *logstructures, const uint8_t num_types)
|
||||||
|
{
|
||||||
|
Debug("Validating structures");
|
||||||
|
bool passed = true;
|
||||||
|
|
||||||
|
for (uint16_t i=0; i<num_types; i++) {
|
||||||
|
const struct LogStructure *logstructure = &logstructures[i];
|
||||||
|
passed = validate_structure(logstructure, i) && passed;
|
||||||
}
|
}
|
||||||
if (!passed) {
|
if (!passed) {
|
||||||
Debug("Log structures are invalid");
|
Debug("Log structures are invalid");
|
||||||
|
@ -319,11 +319,15 @@ private:
|
|||||||
private:
|
private:
|
||||||
static DataFlash_Class *_instance;
|
static DataFlash_Class *_instance;
|
||||||
|
|
||||||
|
bool validate_structure(const struct LogStructure *logstructure, int16_t offset);
|
||||||
void validate_structures(const struct LogStructure *logstructures, const uint8_t num_types);
|
void validate_structures(const struct LogStructure *logstructures, const uint8_t num_types);
|
||||||
void dump_structure_field(const struct LogStructure *logstructure, const char *label, const uint8_t fieldnum);
|
void dump_structure_field(const struct LogStructure *logstructure, const char *label, const uint8_t fieldnum);
|
||||||
void dump_structures(const struct LogStructure *logstructures, const uint8_t num_types);
|
void dump_structures(const struct LogStructure *logstructures, const uint8_t num_types);
|
||||||
const char* unit_name(const uint8_t unit_id);
|
const char* unit_name(const uint8_t unit_id);
|
||||||
double multiplier_name(const uint8_t multiplier_id);
|
double multiplier_name(const uint8_t multiplier_id);
|
||||||
|
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
||||||
|
bool seen_ids[256] = { };
|
||||||
|
#endif
|
||||||
|
|
||||||
void Log_Write_EKF_Timing(const char *name, uint64_t time_us, const struct ekf_timing &timing);
|
void Log_Write_EKF_Timing(const char *name, uint64_t time_us, const struct ekf_timing &timing);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user