diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2015-01-11 11:41:29 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2015-01-11 11:41:29 +0100 |
commit | ae6198b0bad801535c879d3269920e12781cea92 (patch) | |
tree | 409793ebc9e0bc4d0157b0e1109fe4570744852b /src/modules/sdlog2 | |
parent | 6203c73ccc1426b4280fb23284a2f52e4425ef4d (diff) | |
download | px4-firmware-ae6198b0bad801535c879d3269920e12781cea92.tar.gz px4-firmware-ae6198b0bad801535c879d3269920e12781cea92.tar.bz2 px4-firmware-ae6198b0bad801535c879d3269920e12781cea92.zip |
sdlog2: Made sdlog writer performance available in log fiiles, reduced telemetry messages
Diffstat (limited to 'src/modules/sdlog2')
-rw-r--r-- | src/modules/sdlog2/sdlog2.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/modules/sdlog2/sdlog2.c b/src/modules/sdlog2/sdlog2.c index abc69a4b5..d35b70239 100644 --- a/src/modules/sdlog2/sdlog2.c +++ b/src/modules/sdlog2/sdlog2.c @@ -199,6 +199,8 @@ static bool space_warning_sent = false; static pthread_t logwriter_pthread = 0; static pthread_attr_t logwriter_attr; +static perf_counter_t perf_write; + /** * Log buffer writing thread. Open and close file here. */ @@ -451,10 +453,10 @@ int open_log_file() int fd = open(log_file_path, O_CREAT | O_WRONLY | O_DSYNC); if (fd < 0) { - mavlink_and_console_log_critical(mavlink_fd, "[sdlog2] failed opening log: %s", log_file_name); + mavlink_and_console_log_critical(mavlink_fd, "[sdlog2] failed opening: %s", log_file_name); } else { - mavlink_and_console_log_info(mavlink_fd, "[sdlog2] log file: %s", log_file_name); + mavlink_and_console_log_info(mavlink_fd, "[sdlog2] starting: %s", log_file_name); } return fd; @@ -515,8 +517,6 @@ static void *logwriter_thread(void *arg) /* set name */ prctl(PR_SET_NAME, "sdlog2_writer", 0); - perf_counter_t perf_write = perf_alloc(PC_ELAPSED, "sd write"); - int log_fd = open_log_file(); if (log_fd < 0) { @@ -620,16 +620,11 @@ static void *logwriter_thread(void *arg) fsync(log_fd); close(log_fd); - /* free performance counter */ - perf_free(perf_write); - return NULL; } void sdlog2_start_log() { - mavlink_and_console_log_info(mavlink_fd, "[sdlog2] start logging"); - /* create log dir if needed */ if (create_log_dir() != 0) { mavlink_and_console_log_critical(mavlink_fd, "[sdlog2] error creating log dir"); @@ -655,6 +650,9 @@ void sdlog2_start_log() logwriter_should_exit = false; + /* allocate write performance counter */ + perf_write = perf_alloc(PC_ELAPSED, "sd write"); + /* start log buffer emptying thread */ if (0 != pthread_create(&logwriter_pthread, &logwriter_attr, logwriter_thread, &lb)) { errx(1, "error creating logwriter thread"); @@ -674,8 +672,6 @@ void sdlog2_start_log() void sdlog2_stop_log() { - mavlink_and_console_log_info(mavlink_fd, "[sdlog2] stop logging"); - logging_enabled = false; /* wake up write thread one last time */ @@ -701,6 +697,11 @@ void sdlog2_stop_log() perf_print_all(perf_fd); close(perf_fd); + /* free log writer performance counter */ + perf_free(perf_write); + + mavlink_and_console_log_info(mavlink_fd, "[sdlog2] logging stopped"); + sdlog2_status(); } |