Browse Source

AP_Logger: initialise logger instance variables in header

zr-v5.1
Peter Barker 4 years ago committed by Peter Barker
parent
commit
e8d24a1f68
  1. 10
      libraries/AP_Logger/AP_Logger_File.cpp
  2. 12
      libraries/AP_Logger/AP_Logger_File.h

10
libraries/AP_Logger/AP_Logger_File.cpp

@ -29,10 +29,6 @@ extern const AP_HAL::HAL& hal;
#define LOGGER_PAGE_SIZE 1024UL #define LOGGER_PAGE_SIZE 1024UL
#ifndef HAL_LOGGER_WRITE_CHUNK_SIZE
#define HAL_LOGGER_WRITE_CHUNK_SIZE 4096
#endif
#define MB_to_B 1000000 #define MB_to_B 1000000
#define B_to_MB 0.000001 #define B_to_MB 0.000001
@ -46,11 +42,7 @@ AP_Logger_File::AP_Logger_File(AP_Logger &front,
LoggerMessageWriter_DFLogStart *writer, LoggerMessageWriter_DFLogStart *writer,
const char *log_directory) : const char *log_directory) :
AP_Logger_Backend(front, writer), AP_Logger_Backend(front, writer),
_write_fd(-1), _log_directory(log_directory)
_read_fd(-1),
_log_directory(log_directory),
_writebuf(0),
_writebuf_chunk(HAL_LOGGER_WRITE_CHUNK_SIZE)
{ {
df_stats_clear(); df_stats_clear();
} }

12
libraries/AP_Logger/AP_Logger_File.h

@ -13,6 +13,10 @@
#include <AP_HAL/utility/RingBuffer.h> #include <AP_HAL/utility/RingBuffer.h>
#include "AP_Logger_Backend.h" #include "AP_Logger_Backend.h"
#ifndef HAL_LOGGER_WRITE_CHUNK_SIZE
#define HAL_LOGGER_WRITE_CHUNK_SIZE 4096
#endif
class AP_Logger_File : public AP_Logger_Backend class AP_Logger_File : public AP_Logger_Backend
{ {
public: public:
@ -59,14 +63,14 @@ protected:
bool StartNewLogOK() const override; bool StartNewLogOK() const override;
private: private:
int _write_fd; int _write_fd = -1;
char *_write_filename; char *_write_filename;
uint32_t _last_write_ms; uint32_t _last_write_ms;
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS #if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
bool _need_rtc_update; bool _need_rtc_update;
#endif #endif
int _read_fd; int _read_fd = -1;
uint16_t _read_fd_log_num; uint16_t _read_fd_log_num;
uint32_t _read_offset; uint32_t _read_offset;
uint32_t _write_offset; uint32_t _write_offset;
@ -92,8 +96,8 @@ private:
bool log_exists(const uint16_t lognum) const; bool log_exists(const uint16_t lognum) const;
// write buffer // write buffer
ByteBuffer _writebuf; ByteBuffer _writebuf{0};
const uint16_t _writebuf_chunk; const uint16_t _writebuf_chunk = HAL_LOGGER_WRITE_CHUNK_SIZE;
uint32_t _last_write_time; uint32_t _last_write_time;
/* construct a file name given a log number. Caller must free. */ /* construct a file name given a log number. Caller must free. */

Loading…
Cancel
Save