mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-05 04:01:35 +08:00
logger: re-use subscribed topic id's, only set them once on first use
Will be necessary when using multiple backends in parallel.
This commit is contained in:
@@ -1086,7 +1086,6 @@ void Logger::start_log_file()
|
|||||||
|
|
||||||
/* print logging path, important to find log file later */
|
/* print logging path, important to find log file later */
|
||||||
mavlink_log_info(&_mavlink_log_pub, "[logger] file: %s", file_name);
|
mavlink_log_info(&_mavlink_log_pub, "[logger] file: %s", file_name);
|
||||||
_next_topic_id = 0;
|
|
||||||
|
|
||||||
_writer.start_log_file(file_name);
|
_writer.start_log_file(file_name);
|
||||||
_writer.set_need_reliable_transfer(true);
|
_writer.set_need_reliable_transfer(true);
|
||||||
@@ -1142,9 +1141,12 @@ void Logger::write_add_logged_msg(LoggerSubscription &subscription, int instance
|
|||||||
{
|
{
|
||||||
ulog_message_add_logged_s msg;
|
ulog_message_add_logged_s msg;
|
||||||
|
|
||||||
|
if (subscription.msg_ids[instance] == (uint16_t) - 1) {
|
||||||
|
subscription.msg_ids[instance] = _next_topic_id++;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.msg_id = subscription.msg_ids[instance];
|
||||||
msg.multi_id = instance;
|
msg.multi_id = instance;
|
||||||
subscription.msg_ids[instance] = _next_topic_id;
|
|
||||||
msg.msg_id = _next_topic_id;
|
|
||||||
|
|
||||||
int message_name_len = strlen(subscription.metadata->o_name);
|
int message_name_len = strlen(subscription.metadata->o_name);
|
||||||
|
|
||||||
@@ -1157,8 +1159,6 @@ void Logger::write_add_logged_msg(LoggerSubscription &subscription, int instance
|
|||||||
_writer.set_need_reliable_transfer(true);
|
_writer.set_need_reliable_transfer(true);
|
||||||
write_message(&msg, msg_size);
|
write_message(&msg, msg_size);
|
||||||
_writer.set_need_reliable_transfer(prev_reliable);
|
_writer.set_need_reliable_transfer(prev_reliable);
|
||||||
|
|
||||||
++_next_topic_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write info message */
|
/* write info message */
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ struct LoggerSubscription {
|
|||||||
for (int i = 1; i < ORB_MULTI_MAX_INSTANCES; i++) {
|
for (int i = 1; i < ORB_MULTI_MAX_INSTANCES; i++) {
|
||||||
fd[i] = -1;
|
fd[i] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < ORB_MULTI_MAX_INSTANCES; i++) {
|
||||||
|
msg_ids[i] = (uint16_t) - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -232,7 +236,7 @@ private:
|
|||||||
uint32_t _log_interval;
|
uint32_t _log_interval;
|
||||||
param_t _log_utc_offset;
|
param_t _log_utc_offset;
|
||||||
orb_advert_t _mavlink_log_pub = nullptr;
|
orb_advert_t _mavlink_log_pub = nullptr;
|
||||||
uint16_t _next_topic_id; ///< id of next subscribed topic
|
uint16_t _next_topic_id = 0; ///< id of next subscribed ulog topic
|
||||||
char *_replay_file_name = nullptr;
|
char *_replay_file_name = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user