Browse Source

logger: better status output with configured backend mode

sbg
Beat Küng 8 years ago committed by Lorenz Meier
parent
commit
8ea38bc278
  1. 33
      src/modules/logger/logger.cpp
  2. 6
      src/modules/logger/logger.h

33
src/modules/logger/logger.cpp

@ -217,21 +217,15 @@ int Logger::start(char *const *argv) @@ -217,21 +217,15 @@ int Logger::start(char *const *argv)
void Logger::status()
{
bool has_started_backends = false;
PX4_INFO("Running in mode: %s", configured_backend_mode());
if (_writer.is_started(LogWriter::BackendFile)) {
PX4_INFO("File Logging Running");
print_statistics();
has_started_backends = true;
}
if (_writer.is_started(LogWriter::BackendMavlink)) {
PX4_INFO("Mavlink Logging Running");
has_started_backends = true;
}
if (!has_started_backends) {
PX4_INFO("Running, but not logging");
}
}
@ -241,9 +235,10 @@ void Logger::print_statistics() @@ -241,9 +235,10 @@ void Logger::print_statistics()
return;
}
/* this is only for the file backend */
float kibibytes = _writer.get_total_written_file() / 1024.0f;
float mebibytes = kibibytes / 1024.0f;
float seconds = ((float)(hrt_absolute_time() - _start_time)) / 1000000.0f;
float seconds = ((float)(hrt_absolute_time() - _start_time_file)) / 1000000.0f;
PX4_INFO("Log file: %s/%s", _log_dir, _log_file_name);
PX4_INFO("Wrote %4.2f MiB (avg %5.2f KiB/s)", (double)mebibytes, (double)(kibibytes / seconds));
@ -607,14 +602,28 @@ int Logger::add_topics_from_file(const char *fname) @@ -607,14 +602,28 @@ int Logger::add_topics_from_file(const char *fname)
return ntopics;
}
const char *Logger::configured_backend_mode() const
{
switch (_writer.backend()) {
case LogWriter::BackendFile: return "file";
case LogWriter::BackendMavlink: return "mavlink";
case LogWriter::BackendAll: return "all";
default: return "several";
}
}
void Logger::run()
{
#ifdef DBGPRINT
struct mallinfo alloc_info = {};
#endif /* DBGPRINT */
PX4_INFO("logger started");
PX4_INFO("logger started (mode=%s)", configured_backend_mode());
if (_writer.backend() & LogWriter::BackendFile) {
int mkdir_ret = mkdir(LOG_ROOT, S_IRWXU | S_IRWXG | S_IRWXO);
if (mkdir_ret == 0) {
@ -628,6 +637,7 @@ void Logger::run() @@ -628,6 +637,7 @@ void Logger::run()
if (check_free_space() == 1) {
return;
}
}
uORB::Subscription<vehicle_status_s> vehicle_status_sub(ORB_ID(vehicle_status));
uORB::Subscription<parameter_update_s> parameter_update_sub(ORB_ID(parameter_update));
@ -1075,7 +1085,7 @@ void Logger::start_log_file() @@ -1075,7 +1085,7 @@ void Logger::start_log_file()
return;
}
PX4_INFO("start file log");
PX4_INFO("Start file log");
char file_name[LOG_DIR_LEN] = "";
@ -1096,7 +1106,8 @@ void Logger::start_log_file() @@ -1096,7 +1106,8 @@ void Logger::start_log_file()
write_all_add_logged_msg();
_writer.set_need_reliable_transfer(false);
_writer.notify();
_start_time = hrt_absolute_time();
_start_time_file = hrt_absolute_time();
}
void Logger::stop_log_file()

6
src/modules/logger/logger.h

@ -160,6 +160,10 @@ private: @@ -160,6 +160,10 @@ private:
void stop_log_file();
/** get the configured backend as string */
const char *configured_backend_mode() const;
/**
* write the file header with file magic and timestamp.
*/
@ -222,7 +226,7 @@ private: @@ -222,7 +226,7 @@ private:
// statistics
hrt_abstime _start_time; ///< Time when logging started (not the logger thread)
hrt_abstime _start_time_file; ///< Time when logging started, file backend (not the logger thread)
hrt_abstime _dropout_start = 0; ///< start of current dropout (0 = no dropout)
float _max_dropout_duration = 0.f; ///< max duration of dropout [s]
size_t _write_dropouts = 0; ///< failed buffer writes due to buffer overflow

Loading…
Cancel
Save