diff --git a/ROMFS/px4fmu_common/init.d/rc.logging b/ROMFS/px4fmu_common/init.d/rc.logging index 86fc1e0421..d5a7bf293a 100644 --- a/ROMFS/px4fmu_common/init.d/rc.logging +++ b/ROMFS/px4fmu_common/init.d/rc.logging @@ -23,6 +23,12 @@ then set LOGGER_ARGS "${LOGGER_ARGS} -x" fi +if param compare SDLOG_MODE 4 +then + set LOGGER_ARGS "${LOGGER_ARGS} -a" +fi + + if ! param compare SDLOG_MODE -1 then logger start -b ${LOGGER_BUF} -t ${LOGGER_ARGS} diff --git a/src/modules/logger/logger.cpp b/src/modules/logger/logger.cpp index b4b458f5ff..ddb2ce9bf3 100644 --- a/src/modules/logger/logger.cpp +++ b/src/modules/logger/logger.cpp @@ -257,7 +257,7 @@ Logger *Logger::instantiate(int argc, char *argv[]) int ch; const char *myoptarg = nullptr; - while ((ch = px4_getopt(argc, argv, "r:b:etfm:p:xc:", &myoptind, &myoptarg)) != EOF) { + while ((ch = px4_getopt(argc, argv, "r:b:aetfm:p:xc:", &myoptind, &myoptarg)) != EOF) { switch (ch) { case 'r': { unsigned long r = strtoul(myoptarg, nullptr, 10); @@ -291,6 +291,10 @@ Logger *Logger::instantiate(int argc, char *argv[]) log_mode = Logger::LogMode::boot_until_shutdown; break; + case 'a': + log_mode = Logger::LogMode::arm_until_shutdown; + break; + case 'b': { unsigned long s = strtoul(myoptarg, nullptr, 10); @@ -1113,7 +1117,8 @@ bool Logger::start_stop_logging() if (_vehicle_status_sub.update(&vehicle_status)) { - desired_state = (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED); + desired_state = (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED) || (_prev_state + && _log_mode == LogMode::arm_until_shutdown); updated = true; } } @@ -2405,6 +2410,7 @@ $ logger on PRINT_MODULE_USAGE_COMMAND("start"); PRINT_MODULE_USAGE_PARAM_STRING('m', "all", "file|mavlink|all", "Backend mode", true); PRINT_MODULE_USAGE_PARAM_FLAG('x', "Enable/disable logging via Aux1 RC channel", true); + PRINT_MODULE_USAGE_PARAM_FLAG('a', "Log 1st armed until shutdown", true); PRINT_MODULE_USAGE_PARAM_FLAG('e', "Enable logging right after start until disarm (otherwise only when armed)", true); PRINT_MODULE_USAGE_PARAM_FLAG('f', "Log until shutdown (implies -e)", true); PRINT_MODULE_USAGE_PARAM_FLAG('t', "Use date/time for naming log directories and files", true); diff --git a/src/modules/logger/logger.h b/src/modules/logger/logger.h index c2ca821d2b..c397600ad2 100644 --- a/src/modules/logger/logger.h +++ b/src/modules/logger/logger.h @@ -87,7 +87,8 @@ public: while_armed = 0, boot_until_disarm, boot_until_shutdown, - rc_aux1 + rc_aux1, + arm_until_shutdown, }; Logger(LogWriter::Backend backend, size_t buffer_size, uint32_t log_interval, const char *poll_topic_name, diff --git a/src/modules/logger/params.c b/src/modules/logger/params.c index 2fe6b07c19..218ebf896c 100644 --- a/src/modules/logger/params.c +++ b/src/modules/logger/params.c @@ -60,6 +60,7 @@ PARAM_DEFINE_INT32(SDLOG_UTC_OFFSET, 0); * @value 1 from boot until disarm * @value 2 from boot until shutdown * @value 3 depending on AUX1 RC channel + * @value 4 from 1st armed until shutdown * * @reboot_required true * @group SD Logging