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

Parallel mavlink logging for LMC #525

Merged
merged 8 commits into from
Oct 25, 2023
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
2 changes: 1 addition & 1 deletion boards/ssrc/saluki-v2
1 change: 0 additions & 1 deletion msg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ set(msg_files
UavcanParameterValue.msg
UlogStream.msg
UlogStreamAck.msg
UlogStreamAcked.msg
VehicleAcceleration.msg
VehicleAirData.msg
VehicleAngularAccelerationSetpoint.msg
Expand Down
1 change: 1 addition & 0 deletions msg/UlogStream.msg
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ uint8 flags # see FLAGS_*
uint8[249] data # ulog data

uint8 ORB_QUEUE_LENGTH = 16 # TODO: we might be able to reduce this if mavlink polled on the topic
# TOPICS ulog_stream ulog_stream_acked
19 changes: 0 additions & 19 deletions msg/UlogStreamAcked.msg

This file was deleted.

2 changes: 1 addition & 1 deletion src/modules/logger/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#
############################################################################
if(CONFIG_LOGGER_PARALLEL_LOGGING)
set(LOGGER_PARALLEL_COMPILE_FLAG "-DLOGGER_PARALLEL_LOGGING")
set(LOGGER_PARALLEL_COMPILE_FLAG "-DLOGGER_PARALLEL_LOGGING")
endif()

px4_add_module(
Expand Down
2 changes: 1 addition & 1 deletion src/modules/logger/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ menuconfig USER_LOGGER
menuconfig LOGGER_PARALLEL_LOGGING
bool "Custom mavlink logging protocol in logger"
default n
depends on MAVLINK_PARALLEL_LOGGING && MODULES_LOGGER
depends on MODULES_LOGGER
---help---
Utilize custom mavlink logging protocol for speed up logging start phase
13 changes: 11 additions & 2 deletions src/modules/logger/log_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void LogWriter::thread_stop()
}
}

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

Expand All @@ -167,7 +167,16 @@ int LogWriter::write_message(LogType type, void *ptr, size_t size, uint64_t drop
}

if (_log_writer_mavlink_for_write && type == LogType::Full) {
ret_mavlink = _log_writer_mavlink_for_write->write_message(ptr, size, acked);
#ifdef LOGGER_PARALLEL_LOGGING

if (reliable) {
ret_mavlink = _log_writer_mavlink_for_write->write_reliable_message(ptr, size, wait);

} else
#endif
{
ret_mavlink = _log_writer_mavlink_for_write->write_message(ptr, size);
}
}

// file backend errors takes precedence
Expand Down
23 changes: 20 additions & 3 deletions src/modules/logger/log_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ class LogWriter

void stop_log_mavlink();

#ifdef LOGGER_PARALLEL_LOGGING
void wait_fifo_empty()
{
if (_log_writer_mavlink) {
_log_writer_mavlink->wait_fifo_count(0);

while (_log_writer_mavlink->reliable_fifo_is_sending()) {
usleep(10000);
}
}
}
#endif

/**
* whether logging is currently active or not (any of the selected backends).
*/
Expand All @@ -90,15 +103,16 @@ class LogWriter
* -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(LogType type, void *ptr, size_t size, uint64_t dropout_start = 0, bool acked = false);
int write_message(LogType type, void *ptr, size_t size, uint64_t dropout_start = 0, bool reliable = false,
bool wait = false);

/**
* Select a backend, so that future calls to write_message() only write to the selected
* sel_backend, until unselect_write_backend() is called.
* @param backend
*/
void select_write_backend(Backend sel_backend);
void unselect_write_backend() { select_write_backend(BackendAll); }
void unselect_write_backend() { select_write_backend(_backend); }

/* file logging methods */

Expand Down Expand Up @@ -154,7 +168,11 @@ class LogWriter
{
if (_log_writer_file) { _log_writer_file->set_need_reliable_transfer(need_reliable); }

#ifndef LOGGER_PARALLEL_LOGGING

if (_log_writer_mavlink) { _log_writer_mavlink->set_need_reliable_transfer(need_reliable && mavlink_backed_too); }

#endif
}

bool need_reliable_transfer() const
Expand All @@ -165,7 +183,6 @@ class LogWriter

return false;
}

#if defined(PX4_CRYPTO)
void set_encryption_parameters(px4_crypto_algorithm_t algorithm, uint8_t key_idx, uint8_t exchange_key_idx)
{
Expand Down
Loading