Replay: added in_list() method

neaten up code
This commit is contained in:
Andrew Tridgell 2015-05-19 20:22:36 +10:00
parent 34fe39f17d
commit dc1ff9a757
2 changed files with 17 additions and 5 deletions

View File

@ -87,6 +87,19 @@ static const char *passthrough_types[] = { "MODE", "EV", "POWR", "RCIN", "RCOU",
"CMD", "CAM", "CURR", "SIM", "TERR", "STRT", "PM",
"STAT", NULL };
/*
see if a type is in a list of types
*/
bool LogReader::in_list(const char *type, const char *list[])
{
for (uint8_t i=0; list[i] != NULL; i++) {
if (strcmp(type, list[i]) == 0) {
return true;
}
}
return false;
}
bool LogReader::update(char type[5])
{
uint8_t hdr[3];
@ -214,11 +227,8 @@ bool LogReader::update(char type[5])
MsgHandler *p = msgparser[f.type];
if (p == NULL) {
for (uint8_t i=0; passthrough_types[i]; i++) {
if (strcmp(passthrough_types[i], type) == 0) {
dataflash.WriteBlock(msg, f.length);
break;
}
if (in_list(type, passthrough_types)) {
dataflash.WriteBlock(msg, f.length);
}
return true;
}

View File

@ -87,4 +87,6 @@ private:
bool installed_vehicle_specific_parsers;
void maybe_install_vehicle_specific_parsers();
bool in_list(const char *type, const char *list[]);
};