Browse Source

DataFlash: added a perf counter for microSD overruns

this allows us to tell if a microSD can handle a high logging rate
mission-4.1.18
Andrew Tridgell 10 years ago
parent
commit
2dfe3cb844
  1. 6
      libraries/DataFlash/DataFlash_File.cpp
  2. 1
      libraries/DataFlash/DataFlash_File.h

6
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 #if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
,_perf_write(perf_alloc(PC_ELAPSED, "DF_write")), ,_perf_write(perf_alloc(PC_ELAPSED, "DF_write")),
_perf_fsync(perf_alloc(PC_ELAPSED, "DF_fsync")), _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 #endif
{} {}
@ -194,6 +195,7 @@ void DataFlash_File::WriteBlock(const void *pBuffer, uint16_t size)
uint16_t space = BUF_SPACE(_writebuf); uint16_t space = BUF_SPACE(_writebuf);
if (space < size) { if (space < size) {
// discard the whole write, to keep the log consistent // discard the whole write, to keep the log consistent
perf_count(_perf_overruns);
return; return;
} }
@ -648,10 +650,10 @@ void DataFlash_File::_io_timer(void)
chunk, ensuring the directory entry is updated after each chunk, ensuring the directory entry is updated after each
write. write.
*/ */
BUF_ADVANCEHEAD(_writebuf, nwritten);
#if CONFIG_HAL_BOARD != HAL_BOARD_AVR_SITL && CONFIG_HAL_BOARD_SUBTYPE != HAL_BOARD_SUBTYPE_LINUX_NONE #if CONFIG_HAL_BOARD != HAL_BOARD_AVR_SITL && CONFIG_HAL_BOARD_SUBTYPE != HAL_BOARD_SUBTYPE_LINUX_NONE
::fsync(_write_fd); ::fsync(_write_fd);
#endif #endif
BUF_ADVANCEHEAD(_writebuf, nwritten);
} }
perf_end(_perf_write); perf_end(_perf_write);
} }

1
libraries/DataFlash/DataFlash_File.h

@ -89,6 +89,7 @@ private:
perf_counter_t _perf_write; perf_counter_t _perf_write;
perf_counter_t _perf_fsync; perf_counter_t _perf_fsync;
perf_counter_t _perf_errors; perf_counter_t _perf_errors;
perf_counter_t _perf_overruns;
#endif #endif
}; };

Loading…
Cancel
Save