Skip to content
Snippets Groups Projects
Commit 623fe7ca authored by Beat Küng's avatar Beat Küng Committed by Lorenz Meier
Browse files

logger + uorb msg template: rm msg name from o_fields to save space

Instead we use o_name to get the topic name. Now the topic names are not
upper case anymore in the log format. This makes it more consistent, eg.
if used as a nested topic
parent 4f8d16cc
No related branches found
No related tags found
No related merge requests found
......@@ -70,7 +70,8 @@ topic_fields = ["uint64_t timestamp"]+["%s %s" % (convert_type(field.type), fiel
@# join all msg files in one line e.g: "float[3] position;float[3] velocity;bool armed"
const char *__orb_@(topic_name)_fields = "@( topic_name.upper() ):@( ";".join(topic_fields) );";
@# This is used for the logger
const char *__orb_@(topic_name)_fields = "@( ";".join(topic_fields) );";
@[for multi_topic in topics]@
ORB_DEFINE(@multi_topic, struct @uorb_struct, @(struct_size-padding_end_size),
......
......@@ -330,7 +330,7 @@ int Logger::add_topic(const orb_metadata *topic)
}
size_t fields_len = strlen(topic->o_fields);
size_t fields_len = strlen(topic->o_fields) + strlen(topic->o_name) + 1; //1 for ':'
if (fields_len > sizeof(message_format_s::format)) {
PX4_WARN("skip topic %s, format string is too large: %zu (max is %zu)", topic->o_name, fields_len,
......@@ -842,7 +842,7 @@ void Logger::write_formats()
//write all known formats
for (size_t i = 0; i < orb_topics_count(); i++) {
int format_len = snprintf(msg.format, sizeof(msg.format), "%s", topics[i]->o_fields);
int format_len = snprintf(msg.format, sizeof(msg.format), "%s:%s", topics[i]->o_name, topics[i]->o_fields);
size_t msg_size = sizeof(msg) - sizeof(msg.format) + format_len;
msg.msg_size = msg_size - MSG_HEADER_LEN;
......@@ -875,12 +875,9 @@ void Logger::write_add_logged_msg(LoggerSubscription &subscription, int instance
subscription.msg_ids[instance] = _next_topic_id;
msg.msg_id = _next_topic_id;
int message_name_len = 0;
int message_name_len = strlen(subscription.metadata->o_name);
//we get the name from o_fields, it ends with ':'
while (subscription.metadata->o_fields[++message_name_len] != ':');
memcpy(msg.message_name, subscription.metadata->o_fields, message_name_len);
memcpy(msg.message_name, subscription.metadata->o_name, message_name_len);
size_t msg_size = sizeof(msg) - sizeof(msg.message_name) + message_name_len;
msg.msg_size = msg_size - MSG_HEADER_LEN;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment