|
|
@ -298,6 +298,44 @@ void AP_Logger::dump_structures(const struct LogStructure *logstructures, const |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool AP_Logger::labels_string_is_good(const char *labels) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// This goes through and slices labels up into substrings by
|
|
|
|
|
|
|
|
// changing commas to nulls - keeping references to each string in
|
|
|
|
|
|
|
|
// label_offsets.
|
|
|
|
|
|
|
|
bool passed = true; |
|
|
|
|
|
|
|
char *label_offsets[LS_LABELS_SIZE]; |
|
|
|
|
|
|
|
uint8_t label_offsets_offset = 0; |
|
|
|
|
|
|
|
char labels_copy[LS_LABELS_SIZE]; |
|
|
|
|
|
|
|
strncpy(labels_copy, labels, ARRAY_SIZE(labels_copy)); |
|
|
|
|
|
|
|
if (labels_copy[0] == ',') { |
|
|
|
|
|
|
|
Debug("Leading comma in (%s)", labels); |
|
|
|
|
|
|
|
passed = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
label_offsets[label_offsets_offset++] = labels_copy; |
|
|
|
|
|
|
|
const uint8_t len = strnlen(labels_copy, ARRAY_SIZE(labels_copy)); |
|
|
|
|
|
|
|
for (uint8_t i=0; i<len; i++) { |
|
|
|
|
|
|
|
if (labels_copy[i] == ',') { |
|
|
|
|
|
|
|
if (labels_copy[i+1] == '\0') { |
|
|
|
|
|
|
|
Debug("Trailing comma in (%s)", labels); |
|
|
|
|
|
|
|
passed = false; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
labels_copy[i] = '\0'; |
|
|
|
|
|
|
|
label_offsets[label_offsets_offset++] = &labels_copy[i+1]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (uint8_t i=0; i<label_offsets_offset-1; i++) { |
|
|
|
|
|
|
|
for (uint8_t j=i+1; j<label_offsets_offset; j++) { |
|
|
|
|
|
|
|
if (!strcmp(label_offsets[i], label_offsets[j])) { |
|
|
|
|
|
|
|
Debug("Duplicate label (%s) in (%s)", label_offsets[i], labels); |
|
|
|
|
|
|
|
passed = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return passed; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool AP_Logger::validate_structure(const struct LogStructure *logstructure, const int16_t offset) |
|
|
|
bool AP_Logger::validate_structure(const struct LogStructure *logstructure, const int16_t offset) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool passed = true; |
|
|
|
bool passed = true; |
|
|
@ -337,6 +375,10 @@ bool AP_Logger::validate_structure(const struct LogStructure *logstructure, cons |
|
|
|
passed = false; |
|
|
|
passed = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!labels_string_is_good(logstructure->labels)) { |
|
|
|
|
|
|
|
passed = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// check that the structure is of an appropriate length to take fields
|
|
|
|
// check that the structure is of an appropriate length to take fields
|
|
|
|
const int16_t msg_len = Write_calc_msg_len(logstructure->format); |
|
|
|
const int16_t msg_len = Write_calc_msg_len(logstructure->format); |
|
|
|
if (msg_len != logstructure->msg_len) { |
|
|
|
if (msg_len != logstructure->msg_len) { |
|
|
|