logger: choose logged instances by logger_topics file

new versions of logger does not allow to log multiple instances of a topic when using 'logger_topics.txt'

This commit restores the default behavior (log all instances of a topic) and ad the option to specify an instance to log
This commit is contained in:
Nicolas Martin
2020-01-17 11:08:14 +01:00
committed by Beat Küng
parent a8c3944485
commit cfa74b9106
+5 -3
View File
@@ -230,10 +230,11 @@ int LoggedTopics::add_topics_from_file(const char *fname)
continue;
}
// read line with format: <topic_name>[, <interval>]
// read line with format: <topic_name>[ <interval>[ <instance>]]
char topic_name[80];
uint32_t interval_ms = 0;
int nfields = sscanf(line, "%s %u", topic_name, &interval_ms);
uint32_t instance = 0;
int nfields = sscanf(line, "%s %u %u", topic_name, &interval_ms, &instance);
if (nfields > 0) {
int name_len = strlen(topic_name);
@@ -243,7 +244,8 @@ int LoggedTopics::add_topics_from_file(const char *fname)
}
/* add topic with specified interval_ms */
if (add_topic(topic_name, interval_ms)) {
if ((nfields > 2 && add_topic(topic_name, interval_ms, instance))
|| add_topic_multi(topic_name, interval_ms)) {
ntopics++;
} else {