Skip to content

Commit 7f6a9e5

Browse files
bkuengdagar
authored andcommitted
logger: fix multiple format definitions for multi-instance topics
With #12123 all multi-instance topics lead to repeated format definitions in the ULog file.
1 parent 5c68880 commit 7f6a9e5

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/modules/logger/logger.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -1693,6 +1693,13 @@ void Logger::write_format(LogType type, const orb_metadata &meta, WrittenFormats
16931693
return;
16941694
}
16951695

1696+
// check if we already wrote the format
1697+
for (const auto &written_format : written_formats) {
1698+
if (written_format == &meta) {
1699+
return;
1700+
}
1701+
}
1702+
16961703
// Write the current format (we don't need to check if we already added it to written_formats)
16971704
int format_len = snprintf(msg.format, sizeof(msg.format), "%s:%s", meta.o_name, meta.o_fields);
16981705
size_t msg_size = sizeof(msg) - sizeof(msg.format) + format_len;
@@ -1764,17 +1771,8 @@ void Logger::write_format(LogType type, const orb_metadata &meta, WrittenFormats
17641771
}
17651772

17661773
if (found_topic) {
1767-
// check if we already wrote the format
1768-
for (const auto &written_format : written_formats) {
1769-
if (written_format == found_topic) {
1770-
found_topic = nullptr;
1771-
break;
1772-
}
1773-
}
17741774

1775-
if (found_topic) {
1776-
write_format(type, *found_topic, written_formats, msg, level + 1);
1777-
}
1775+
write_format(type, *found_topic, written_formats, msg, level + 1);
17781776

17791777
} else {
17801778
PX4_ERR("No definition for topic %s found", fmt);

0 commit comments

Comments
 (0)