From 2dfe3cb844c71c0812f86283e56feb76020b55e8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 21 Apr 2015 20:42:08 +1000 Subject: [PATCH] DataFlash: added a perf counter for microSD overruns this allows us to tell if a microSD can handle a high logging rate --- libraries/DataFlash/DataFlash_File.cpp | 6 ++++-- libraries/DataFlash/DataFlash_File.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/DataFlash/DataFlash_File.cpp b/libraries/DataFlash/DataFlash_File.cpp index a5db45a21c..3b1e73a3cd 100644 --- a/libraries/DataFlash/DataFlash_File.cpp +++ b/libraries/DataFlash/DataFlash_File.cpp @@ -68,7 +68,8 @@ DataFlash_File::DataFlash_File(const char *log_directory) : #if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN ,_perf_write(perf_alloc(PC_ELAPSED, "DF_write")), _perf_fsync(perf_alloc(PC_ELAPSED, "DF_fsync")), - _perf_errors(perf_alloc(PC_COUNT, "DF_errors")) + _perf_errors(perf_alloc(PC_COUNT, "DF_errors")), + _perf_overruns(perf_alloc(PC_COUNT, "DF_overruns")) #endif {} @@ -194,6 +195,7 @@ void DataFlash_File::WriteBlock(const void *pBuffer, uint16_t size) uint16_t space = BUF_SPACE(_writebuf); if (space < size) { // discard the whole write, to keep the log consistent + perf_count(_perf_overruns); return; } @@ -648,10 +650,10 @@ void DataFlash_File::_io_timer(void) chunk, ensuring the directory entry is updated after each write. */ + BUF_ADVANCEHEAD(_writebuf, nwritten); #if CONFIG_HAL_BOARD != HAL_BOARD_AVR_SITL && CONFIG_HAL_BOARD_SUBTYPE != HAL_BOARD_SUBTYPE_LINUX_NONE ::fsync(_write_fd); #endif - BUF_ADVANCEHEAD(_writebuf, nwritten); } perf_end(_perf_write); } diff --git a/libraries/DataFlash/DataFlash_File.h b/libraries/DataFlash/DataFlash_File.h index ef472e1564..be341c5230 100644 --- a/libraries/DataFlash/DataFlash_File.h +++ b/libraries/DataFlash/DataFlash_File.h @@ -89,6 +89,7 @@ private: perf_counter_t _perf_write; perf_counter_t _perf_fsync; perf_counter_t _perf_errors; + perf_counter_t _perf_overruns; #endif };