forked from Archive/PX4-Autopilot
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:
parent
12ded377d1
commit
7a60c1296e
|
@ -1086,7 +1086,6 @@ void Logger::start_log_file()
|
|||
|
||||
/* print logging path, important to find log file later */
|
||||
mavlink_log_info(&_mavlink_log_pub, "[logger] file: %s", file_name);
|
||||
_next_topic_id = 0;
|
||||
|
||||
_writer.start_log_file(file_name);
|
||||
_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;
|
||||
|
||||
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;
|
||||
subscription.msg_ids[instance] = _next_topic_id;
|
||||
msg.msg_id = _next_topic_id;
|
||||
|
||||
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);
|
||||
write_message(&msg, msg_size);
|
||||
_writer.set_need_reliable_transfer(prev_reliable);
|
||||
|
||||
++_next_topic_id;
|
||||
}
|
||||
|
||||
/* write info message */
|
||||
|
|
|
@ -75,6 +75,10 @@ struct LoggerSubscription {
|
|||
for (int i = 1; i < ORB_MULTI_MAX_INSTANCES; i++) {
|
||||
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;
|
||||
param_t _log_utc_offset;
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue