Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mission Log #10738

Merged
merged 14 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmake/configs/nuttx_aerofc-v1_default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ set(config_module_list
#
modules/mc_att_control
modules/mc_pos_control
modules/vtol_att_control # FIXME: only required for params needed by Navigator

#
# Logging
Expand Down
1 change: 0 additions & 1 deletion cmake/configs/nuttx_crazyflie_default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ set(config_module_list
# modules/fw_att_control
modules/mc_att_control
modules/mc_pos_control
modules/vtol_att_control # FIXME: only required for params needed by Navigator

#
# Logging
Expand Down
6 changes: 3 additions & 3 deletions cmake/configs/nuttx_omnibus-f4sd_default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ set(config_module_list
#
# Vehicle Control
#
modules/fw_att_control
modules/fw_pos_control_l1
#modules/fw_att_control
#modules/fw_pos_control_l1
#modules/gnd_att_control
#modules/gnd_pos_control
modules/mc_att_control
modules/mc_pos_control
modules/vtol_att_control
#modules/vtol_att_control

#
# Logging
Expand Down
2 changes: 1 addition & 1 deletion cmake/configs/nuttx_px4fmu-v2_default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ set(config_module_list
drivers/distance_sensor/ll40ls
#drivers/distance_sensor/mb12xx
drivers/distance_sensor/sf0x
drivers/distance_sensor/sf1xx
#drivers/distance_sensor/sf1xx
#drivers/distance_sensor/srf02
#drivers/distance_sensor/teraranger
#drivers/distance_sensor/tfmini
Expand Down
1 change: 1 addition & 0 deletions src/modules/logger/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ px4_add_module(
log_writer.cpp
log_writer_file.cpp
log_writer_mavlink.cpp
util.cpp
watchdog.cpp
DEPENDS
version
Expand Down
26 changes: 13 additions & 13 deletions src/modules/logger/log_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,45 +95,45 @@ LogWriter::~LogWriter()
}
}

bool LogWriter::is_started() const
bool LogWriter::is_started(LogType type) const
{
bool ret = false;

if (_log_writer_file) {
ret = _log_writer_file->is_started();
ret = _log_writer_file->is_started(type);
}

if (_log_writer_mavlink) {
if (_log_writer_mavlink && type == LogType::Full) {
ret = ret || _log_writer_mavlink->is_started();
}

return ret;
}

bool LogWriter::is_started(Backend query_backend) const
bool LogWriter::is_started(LogType type, Backend query_backend) const
{
if (query_backend == BackendFile && _log_writer_file) {
return _log_writer_file->is_started();
return _log_writer_file->is_started(type);
}

if (query_backend == BackendMavlink && _log_writer_mavlink) {
if (query_backend == BackendMavlink && _log_writer_mavlink && type == LogType::Full) {
return _log_writer_mavlink->is_started();
}

return false;
}

void LogWriter::start_log_file(const char *filename)
void LogWriter::start_log_file(LogType type, const char *filename)
{
if (_log_writer_file) {
_log_writer_file->start_log(filename);
_log_writer_file->start_log(type, filename);
}
}

void LogWriter::stop_log_file()
void LogWriter::stop_log_file(LogType type)
{
if (_log_writer_file) {
_log_writer_file->stop_log();
_log_writer_file->stop_log(type);
}
}

Expand All @@ -158,15 +158,15 @@ void LogWriter::thread_stop()
}
}

int LogWriter::write_message(void *ptr, size_t size, uint64_t dropout_start)
int LogWriter::write_message(LogType type, void *ptr, size_t size, uint64_t dropout_start)
{
int ret_file = 0, ret_mavlink = 0;

if (_log_writer_file_for_write) {
ret_file = _log_writer_file_for_write->write_message(ptr, size, dropout_start);
ret_file = _log_writer_file_for_write->write_message(type, ptr, size, dropout_start);
}

if (_log_writer_mavlink_for_write) {
if (_log_writer_mavlink_for_write && type == LogType::Full) {
ret_mavlink = _log_writer_mavlink_for_write->write_message(ptr, size);
}

Expand Down
23 changes: 12 additions & 11 deletions src/modules/logger/log_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class LogWriter
/** stop all running threads and wait for them to exit */
void thread_stop();

void start_log_file(const char *filename);
void start_log_file(LogType type, const char *filename);

void stop_log_file();
void stop_log_file(LogType type);

void start_log_mavlink();

Expand All @@ -76,20 +76,21 @@ class LogWriter
/**
* whether logging is currently active or not (any of the selected backends).
*/
bool is_started() const;
bool is_started(LogType type) const;

/**
* whether logging is currently active or not for a specific backend.
*/
bool is_started(Backend query_backend) const;
bool is_started(LogType type, Backend query_backend) const;

/**
* Write a single ulog message (including header). The caller must call lock() before calling this.
* @param dropout_start timestamp when lastest dropout occured. 0 if no dropout at the moment.
* @return 0 on success (or if no logging started),
* -1 if not enough space in the buffer left (file backend), -2 mavlink backend failed
* add type -> pass through, but not to mavlink if mission log
*/
int write_message(void *ptr, size_t size, uint64_t dropout_start = 0);
int write_message(LogType type, void *ptr, size_t size, uint64_t dropout_start = 0);

/**
* Select a backend, so that future calls to write_message() only write to the selected
Expand All @@ -116,23 +117,23 @@ class LogWriter
if (_log_writer_file) { _log_writer_file->notify(); }
}

size_t get_total_written_file() const
size_t get_total_written_file(LogType type) const
{
if (_log_writer_file) { return _log_writer_file->get_total_written(); }
if (_log_writer_file) { return _log_writer_file->get_total_written(type); }

return 0;
}

size_t get_buffer_size_file() const
size_t get_buffer_size_file(LogType type) const
{
if (_log_writer_file) { return _log_writer_file->get_buffer_size(); }
if (_log_writer_file) { return _log_writer_file->get_buffer_size(type); }

return 0;
}

size_t get_buffer_fill_count_file() const
size_t get_buffer_fill_count_file(LogType type) const
{
if (_log_writer_file) { return _log_writer_file->get_buffer_fill_count(); }
if (_log_writer_file) { return _log_writer_file->get_buffer_fill_count(type); }

return 0;
}
Expand Down
Loading