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:
Beat Küng
2016-05-02 15:07:15 +02:00
committed by Lorenz Meier
parent 04f38b9197
commit 8b5a325644
4 changed files with 39 additions and 15 deletions
+6 -4
View File
@@ -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) {