Browse Source

logger: Refactor new boot_bat logic into separate function

Implements suggested fixes.

Signed-off-by: Tal Zaitsev <tal@corvus-robotics.com>
sbg
tzai 5 years ago committed by Kabir Mohammed
parent
commit
b9d85c7176
  1. 50
      src/modules/logger/logger.cpp
  2. 6
      src/modules/logger/logger.h

50
src/modules/logger/logger.cpp

@ -520,29 +520,6 @@ void Logger::run() @@ -520,29 +520,6 @@ void Logger::run()
{
PX4_INFO("logger started (mode=%s)", configured_backend_mode());
bool boot_logging_bat_only = false;
bool disable_boot_logging = false;
if (_boot_bat_only != PARAM_INVALID) {
param_get(_boot_bat_only, &boot_logging_bat_only);
}
if (boot_logging_bat_only) {
uORB::Subscription battery_status_sub{ORB_ID(battery_status)};
if (battery_status_sub.updated()) {
battery_status_s battery_status;
battery_status_sub.copy(&battery_status);
if (!battery_status.connected) {
disable_boot_logging = true;
}
} else {
PX4_WARN("battery_status not published. Logging anyway");
}
}
if (_writer.backend() & LogWriter::BackendFile) {
int mkdir_ret = mkdir(LOG_ROOT[(int)LogType::Full], S_IRWXU | S_IRWXG | S_IRWXO);
@ -627,6 +604,8 @@ void Logger::run() @@ -627,6 +604,8 @@ void Logger::run()
px4_register_shutdown_hook(&Logger::request_stop_static);
const bool disable_boot_logging = get_disable_boot_logging();
if ((_log_mode == LogMode::boot_until_disarm || _log_mode == LogMode::boot_until_shutdown) && !disable_boot_logging) {
start_log_file(LogType::Full);
}
@ -923,6 +902,31 @@ void Logger::debug_print_buffer(uint32_t &total_bytes, hrt_abstime &timer_start) @@ -923,6 +902,31 @@ void Logger::debug_print_buffer(uint32_t &total_bytes, hrt_abstime &timer_start)
#endif /* DBGPRINT */
}
bool Logger::get_disable_boot_logging()
{
int32_t boot_logging_bat_only = 0;
if (_boot_bat_only != PARAM_INVALID) {
param_get(_boot_bat_only, &boot_logging_bat_only);
}
if (boot_logging_bat_only) {
battery_status_s battery_status;
uORB::Subscription battery_status_sub{ORB_ID(battery_status)};
if (battery_status_sub.copy(&battery_status)) {
if (!battery_status.connected) {
return true;
}
} else {
PX4_WARN("battery_status not published. Logging anyway");
}
}
return false;
}
bool Logger::start_stop_logging(MissionLogType mission_log_type)
{
bool bret = false;

6
src/modules/logger/logger.h

@ -267,6 +267,12 @@ private: @@ -267,6 +267,12 @@ private:
*/
bool initialize_topics(MissionLogType mission_log_mode);
/**
* Determines if log-from-boot should be disabled, based on the value of SDLOG_BOOT_BAT and the battery status.
* @return true if log-from-boot should be disabled
*/
bool get_disable_boot_logging();
/**
* check current arming state or aux channel and start/stop logging if state changed and according to
* configured params.

Loading…
Cancel
Save