mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
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
This commit is contained in:
parent
4f8d16cc4d
commit
623fe7ca2c
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user