mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 10:27:34 +08:00
logger: remove _log_buffer from Logger, initialize it in the writer instead
it's not used in the logger, so don't store it there. It is accessed via LogWriter::write. This also makes sure the buffer size is >= _min_write_chunk and handles allocation failure properly.
This commit is contained in:
@@ -254,7 +254,7 @@ static constexpr size_t MAX_DATA_SIZE = 740;
|
||||
|
||||
Logger::Logger(size_t buffer_size, unsigned log_interval, bool log_on_start) :
|
||||
_log_on_start(log_on_start),
|
||||
_writer((_log_buffer = new uint8_t[buffer_size]), buffer_size),
|
||||
_writer(buffer_size),
|
||||
_log_interval(log_interval)
|
||||
{
|
||||
}
|
||||
@@ -280,9 +280,6 @@ Logger::~Logger()
|
||||
}
|
||||
} while (logger_task != -1);
|
||||
}
|
||||
|
||||
delete [] _log_buffer;
|
||||
logger_ptr = nullptr;
|
||||
}
|
||||
|
||||
int Logger::add_topic(const orb_metadata *topic)
|
||||
@@ -414,6 +411,11 @@ void Logger::run()
|
||||
// add_topic("estimator_status");
|
||||
add_topic("vehicle_status", 100);
|
||||
|
||||
if (!_writer.init()) {
|
||||
PX4_ERR("logger: init of writer failed");
|
||||
return;
|
||||
}
|
||||
|
||||
int ret = _writer.thread_start(_writer_thread);
|
||||
|
||||
if (ret) {
|
||||
|
||||
Reference in New Issue
Block a user