PX4 Firmware
PX4 Autopilot Software http://px4.io
|
Manages starting, stopping & writing of logged data using the configured backend. More...
#include <log_writer.h>
Public Types | |
typedef uint8_t | Backend |
bitfield to specify a backend More... | |
Public Member Functions | |
LogWriter (Backend configured_backend, size_t file_buffer_size) | |
~LogWriter () | |
bool | init () |
Backend | backend () const |
void | thread_stop () |
stop all running threads and wait for them to exit More... | |
void | start_log_file (LogType type, const char *filename) |
void | stop_log_file (LogType type) |
void | start_log_mavlink () |
void | stop_log_mavlink () |
bool | is_started (LogType type) const |
whether logging is currently active or not (any of the selected backends). More... | |
bool | is_started (LogType type, Backend query_backend) const |
whether logging is currently active or not for a specific backend. More... | |
int | write_message (LogType type, void *ptr, size_t size, uint64_t dropout_start=0) |
Write a single ulog message (including header). More... | |
void | select_write_backend (Backend sel_backend) |
Select a backend, so that future calls to write_message() only write to the selected sel_backend, until unselect_write_backend() is called. More... | |
void | unselect_write_backend () |
void | lock () |
void | unlock () |
void | notify () |
size_t | get_total_written_file (LogType type) const |
size_t | get_buffer_size_file (LogType type) const |
size_t | get_buffer_fill_count_file (LogType type) const |
pthread_t | thread_id_file () const |
void | set_need_reliable_transfer (bool need_reliable) |
Indicate to the underlying backend whether future write_message() calls need a reliable transfer. More... | |
bool | need_reliable_transfer () const |
Static Public Attributes | |
static constexpr Backend | BackendFile = 1 << 0 |
static constexpr Backend | BackendMavlink = 1 << 1 |
static constexpr Backend | BackendAll = BackendFile | BackendMavlink |
Private Attributes | |
LogWriterFile * | _log_writer_file = nullptr |
LogWriterMavlink * | _log_writer_mavlink = nullptr |
LogWriterFile * | _log_writer_file_for_write |
pointer that is used for writing, to temporarily select write backends More... | |
LogWriterMavlink * | _log_writer_mavlink_for_write = nullptr |
const Backend | _backend |
Manages starting, stopping & writing of logged data using the configured backend.
Definition at line 48 of file log_writer.h.
typedef uint8_t px4::logger::LogWriter::Backend |
bitfield to specify a backend
Definition at line 53 of file log_writer.h.
px4::logger::LogWriter::LogWriter | ( | Backend | configured_backend, |
size_t | file_buffer_size | ||
) |
Definition at line 41 of file log_writer.cpp.
References _log_writer_file, _log_writer_file_for_write, _log_writer_mavlink, _log_writer_mavlink_for_write, BackendFile, and BackendMavlink.
px4::logger::LogWriter::~LogWriter | ( | ) |
Definition at line 87 of file log_writer.cpp.
References _log_writer_file, and _log_writer_mavlink.
|
inline |
Definition at line 63 of file log_writer.h.
References _backend, is_started(), select_write_backend(), start_log_file(), start_log_mavlink(), stop_log_file(), stop_log_mavlink(), thread_stop(), and write_message().
Referenced by px4::logger::Logger::configured_backend_mode(), px4::logger::Logger::run(), and px4::logger::Logger::start_log_file().
|
inline |
Definition at line 134 of file log_writer.h.
References _log_writer_file, and px4::logger::LogWriterFile::get_buffer_fill_count().
Referenced by px4::logger::Logger::run().
|
inline |
Definition at line 127 of file log_writer.h.
References _log_writer_file, and px4::logger::LogWriterFile::get_buffer_size().
|
inline |
Definition at line 120 of file log_writer.h.
References _log_writer_file, and px4::logger::LogWriterFile::get_total_written().
bool px4::logger::LogWriter::init | ( | ) |
Definition at line 61 of file log_writer.cpp.
References _log_writer_file, _log_writer_mavlink, px4::logger::LogWriterMavlink::init(), px4::logger::LogWriterFile::init(), and px4::logger::LogWriterFile::thread_start().
Referenced by px4::logger::Logger::run().
bool px4::logger::LogWriter::is_started | ( | LogType | type | ) | const |
whether logging is currently active or not (any of the selected backends).
Definition at line 98 of file log_writer.cpp.
References _log_writer_file, _log_writer_mavlink, px4::logger::Full, px4::logger::LogWriterMavlink::is_started(), and px4::logger::LogWriterFile::is_started().
Referenced by backend(), px4::logger::Logger::run(), px4::logger::Logger::start_log_file(), and px4::logger::Logger::stop_log_file().
whether logging is currently active or not for a specific backend.
Definition at line 113 of file log_writer.cpp.
References _log_writer_file, _log_writer_mavlink, BackendFile, BackendMavlink, px4::logger::Full, px4::logger::LogWriterMavlink::is_started(), and px4::logger::LogWriterFile::is_started().
|
inline |
Definition at line 105 of file log_writer.h.
References _log_writer_file, and px4::logger::LogWriterFile::lock().
Referenced by px4::logger::Logger::run(), px4::logger::Logger::write_all_add_logged_msg(), px4::logger::Logger::write_changed_parameters(), px4::logger::Logger::write_formats(), px4::logger::Logger::write_header(), px4::logger::Logger::write_info(), px4::logger::Logger::write_info_multiple(), px4::logger::Logger::write_info_template(), and px4::logger::Logger::write_parameters().
|
inline |
Definition at line 160 of file log_writer.h.
References _log_writer_file, _log_writer_mavlink, px4::logger::LogWriterMavlink::need_reliable_transfer(), and px4::logger::LogWriterFile::need_reliable_transfer().
Referenced by px4::logger::Logger::write_add_logged_msg().
|
inline |
Definition at line 115 of file log_writer.h.
References _log_writer_file, and px4::logger::LogWriterFile::notify().
Referenced by px4::logger::Logger::run(), px4::logger::Logger::start_log_file(), px4::logger::Logger::start_log_mavlink(), px4::logger::Logger::write_changed_parameters(), and px4::logger::Logger::write_parameters().
void px4::logger::LogWriter::select_write_backend | ( | Backend | sel_backend | ) |
Select a backend, so that future calls to write_message() only write to the selected sel_backend, until unselect_write_backend() is called.
backend |
Definition at line 181 of file log_writer.cpp.
References _log_writer_file, _log_writer_file_for_write, _log_writer_mavlink, _log_writer_mavlink_for_write, BackendFile, and BackendMavlink.
Referenced by backend(), px4::logger::Logger::start_log_file(), px4::logger::Logger::start_log_mavlink(), and unselect_write_backend().
|
inline |
Indicate to the underlying backend whether future write_message() calls need a reliable transfer.
Needed for header integrity.
Definition at line 153 of file log_writer.h.
References _log_writer_file, _log_writer_mavlink, px4::logger::LogWriterMavlink::set_need_reliable_transfer(), and px4::logger::LogWriterFile::set_need_reliable_transfer().
Referenced by px4::logger::Logger::start_log_file(), px4::logger::Logger::start_log_mavlink(), px4::logger::Logger::stop_log_file(), px4::logger::Logger::write_add_logged_msg(), and px4::logger::Logger::write_load_output().
void px4::logger::LogWriter::start_log_file | ( | LogType | type, |
const char * | filename | ||
) |
Definition at line 126 of file log_writer.cpp.
References _log_writer_file, and px4::logger::LogWriterFile::start_log().
Referenced by backend(), and px4::logger::Logger::start_log_file().
void px4::logger::LogWriter::start_log_mavlink | ( | ) |
Definition at line 140 of file log_writer.cpp.
References _log_writer_mavlink, and px4::logger::LogWriterMavlink::start_log().
Referenced by backend(), and px4::logger::Logger::start_log_mavlink().
void px4::logger::LogWriter::stop_log_file | ( | LogType | type | ) |
Definition at line 133 of file log_writer.cpp.
References _log_writer_file, and px4::logger::LogWriterFile::stop_log().
Referenced by backend(), and px4::logger::Logger::stop_log_file().
void px4::logger::LogWriter::stop_log_mavlink | ( | ) |
Definition at line 147 of file log_writer.cpp.
References _log_writer_mavlink, and px4::logger::LogWriterMavlink::stop_log().
Referenced by backend(), and px4::logger::Logger::stop_log_mavlink().
|
inline |
Definition at line 141 of file log_writer.h.
References _log_writer_file, and px4::logger::LogWriterFile::thread_id().
Referenced by px4::logger::Logger::run().
void px4::logger::LogWriter::thread_stop | ( | ) |
stop all running threads and wait for them to exit
Definition at line 154 of file log_writer.cpp.
References _log_writer_file, and px4::logger::LogWriterFile::thread_stop().
Referenced by backend(), and px4::logger::Logger::run().
|
inline |
Definition at line 110 of file log_writer.h.
References _log_writer_file, and px4::logger::LogWriterFile::unlock().
Referenced by px4::logger::Logger::run(), px4::logger::Logger::write_all_add_logged_msg(), px4::logger::Logger::write_changed_parameters(), px4::logger::Logger::write_formats(), px4::logger::Logger::write_header(), px4::logger::Logger::write_info(), px4::logger::Logger::write_info_multiple(), px4::logger::Logger::write_info_template(), and px4::logger::Logger::write_parameters().
|
inline |
Definition at line 101 of file log_writer.h.
References select_write_backend().
Referenced by px4::logger::Logger::start_log_file(), and px4::logger::Logger::start_log_mavlink().
int px4::logger::LogWriter::write_message | ( | LogType | type, |
void * | ptr, | ||
size_t | size, | ||
uint64_t | dropout_start = 0 |
||
) |
Write a single ulog message (including header).
The caller must call lock() before calling this.
dropout_start | timestamp when lastest dropout occured. 0 if no dropout at the moment. |
Definition at line 161 of file log_writer.cpp.
References _log_writer_file_for_write, _log_writer_mavlink_for_write, px4::logger::Full, px4::logger::LogWriterMavlink::write_message(), and px4::logger::LogWriterFile::write_message().
Referenced by backend(), and px4::logger::Logger::write_message().
|
private |
Definition at line 178 of file log_writer.h.
Referenced by backend().
|
private |
Definition at line 171 of file log_writer.h.
Referenced by get_buffer_fill_count_file(), get_buffer_size_file(), get_total_written_file(), init(), is_started(), lock(), LogWriter(), need_reliable_transfer(), notify(), select_write_backend(), set_need_reliable_transfer(), start_log_file(), stop_log_file(), thread_id_file(), thread_stop(), unlock(), and ~LogWriter().
|
private |
pointer that is used for writing, to temporarily select write backends
Definition at line 174 of file log_writer.h.
Referenced by LogWriter(), select_write_backend(), and write_message().
|
private |
Definition at line 172 of file log_writer.h.
Referenced by init(), is_started(), LogWriter(), need_reliable_transfer(), select_write_backend(), set_need_reliable_transfer(), start_log_mavlink(), stop_log_mavlink(), and ~LogWriter().
|
private |
Definition at line 176 of file log_writer.h.
Referenced by LogWriter(), select_write_backend(), and write_message().
|
static |
Definition at line 56 of file log_writer.h.
Referenced by px4::logger::Logger::configured_backend_mode(), and px4::logger::Logger::instantiate().
|
static |
Definition at line 54 of file log_writer.h.
Referenced by px4::logger::Logger::configured_backend_mode(), px4::logger::Logger::instantiate(), is_started(), LogWriter(), px4::logger::Logger::print_statistics(), px4::logger::Logger::print_status(), px4::logger::Logger::run(), select_write_backend(), px4::logger::Logger::start_log_file(), and px4::logger::Logger::stop_log_file().
|
static |
Definition at line 55 of file log_writer.h.
Referenced by px4::logger::Logger::can_start_mavlink_log(), px4::logger::Logger::configured_backend_mode(), px4::logger::Logger::instantiate(), is_started(), LogWriter(), px4::logger::Logger::print_status(), select_write_backend(), and px4::logger::Logger::start_log_mavlink().