From fe3c1d0a92a202a8f1428aea1028bcc0aca2333e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Fri, 17 Feb 2023 12:16:48 +0100 Subject: [PATCH] logger: do not try to wait for mavlink ack when writing watchdog data As it might block for 2.5s (if mavlink is blocked) and therefore would not write to file before restoring the priorities. --- src/modules/logger/log_writer.h | 4 ++-- src/modules/logger/logger.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/logger/log_writer.h b/src/modules/logger/log_writer.h index 504d35b767..9635d22dad 100644 --- a/src/modules/logger/log_writer.h +++ b/src/modules/logger/log_writer.h @@ -150,11 +150,11 @@ public: * Indicate to the underlying backend whether future write_message() calls need a reliable * transfer. Needed for header integrity. */ - void set_need_reliable_transfer(bool need_reliable) + void set_need_reliable_transfer(bool need_reliable, bool mavlink_backed_too = true) { if (_log_writer_file) { _log_writer_file->set_need_reliable_transfer(need_reliable); } - if (_log_writer_mavlink) { _log_writer_mavlink->set_need_reliable_transfer(need_reliable); } + if (_log_writer_mavlink) { _log_writer_mavlink->set_need_reliable_transfer(need_reliable && mavlink_backed_too); } } bool need_reliable_transfer() const diff --git a/src/modules/logger/logger.cpp b/src/modules/logger/logger.cpp index 267a5e6699..d2a6b906d7 100644 --- a/src/modules/logger/logger.cpp +++ b/src/modules/logger/logger.cpp @@ -1601,6 +1601,8 @@ void Logger::initialize_load_output(PrintLoadReason reason) void Logger::write_load_output() { + _writer.set_need_reliable_transfer(true, _print_load_reason != PrintLoadReason::Watchdog); + if (_print_load_reason == PrintLoadReason::Watchdog) { PX4_ERR("Writing watchdog data"); // this is just that we see it easily in the log write_perf_data(PrintLoadReason::Watchdog); @@ -1611,7 +1613,6 @@ void Logger::write_load_output() callback_data.logger = this; callback_data.counter = 0; callback_data.buffer = buffer; - _writer.set_need_reliable_transfer(true); // TODO: maybe we should restrict the output to a selected backend (eg. when file logging is running // and mavlink log is started, this will be added to the file as well) print_load_buffer(buffer, sizeof(buffer), print_load_callback, &callback_data, &_load);