mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 06:53:34 +08:00
mavlink ulog: advertise ulog_stream topic before subscribing to ulog_stream_ack
This reduces the maximum number of needed file descriptors by 1 when using ulog streaming.
This commit is contained in:
@@ -69,6 +69,13 @@ LogWriterMavlink::~LogWriterMavlink()
|
||||
|
||||
void LogWriterMavlink::start_log()
|
||||
{
|
||||
if (_ulog_stream_pub == nullptr) {
|
||||
memset(&_ulog_stream_data, 0, sizeof(_ulog_stream_data));
|
||||
// advertise before we subscribe: this is a trick to reduce the number of needed file descriptors
|
||||
// (the advertise temporarily opens a file descriptor)
|
||||
_ulog_stream_pub = orb_advertise_queue(ORB_ID(ulog_stream), &_ulog_stream_data, _queue_size);
|
||||
}
|
||||
|
||||
if (_ulog_stream_ack_sub == -1) {
|
||||
_ulog_stream_ack_sub = orb_subscribe(ORB_ID(ulog_stream_ack));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user