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) : @@ -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) @@ -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) @@ -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);
}

1
libraries/DataFlash/DataFlash_File.h

@ -89,6 +89,7 @@ private: @@ -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
};

Loading…
Cancel
Save