2016-02-17 21:26:01 -04:00
|
|
|
#pragma once
|
2015-06-12 09:52:52 -03:00
|
|
|
|
2019-01-18 00:23:42 -04:00
|
|
|
#include <AP_Logger/AP_Logger.h>
|
2015-06-12 09:52:52 -03:00
|
|
|
|
2015-06-29 23:48:49 -03:00
|
|
|
#define LOGREADER_MAX_FORMATS 255 // must be >= highest MESSAGE
|
|
|
|
|
2019-01-18 00:23:42 -04:00
|
|
|
class AP_LoggerFileReader
|
2015-06-12 09:52:52 -03:00
|
|
|
{
|
|
|
|
public:
|
2016-08-25 00:00:41 -03:00
|
|
|
|
2019-01-18 00:23:42 -04:00
|
|
|
AP_LoggerFileReader();
|
|
|
|
~AP_LoggerFileReader();
|
2016-08-25 00:00:41 -03:00
|
|
|
|
2015-06-12 09:52:52 -03:00
|
|
|
bool open_log(const char *logfile);
|
2020-11-05 19:25:17 -04:00
|
|
|
bool update();
|
2015-06-12 09:52:52 -03:00
|
|
|
|
|
|
|
virtual bool handle_log_format_msg(const struct log_Format &f) = 0;
|
2020-11-05 19:25:17 -04:00
|
|
|
virtual bool handle_msg(const struct log_Format &f, uint8_t *msg) = 0;
|
2015-06-12 09:52:52 -03:00
|
|
|
|
2015-06-29 23:48:49 -03:00
|
|
|
void format_type(uint16_t type, char dest[5]);
|
|
|
|
void get_packet_counts(uint64_t dest[]);
|
|
|
|
|
2015-06-12 09:52:52 -03:00
|
|
|
protected:
|
2015-07-04 09:43:54 -03:00
|
|
|
int fd = -1;
|
2015-06-12 09:52:52 -03:00
|
|
|
|
2015-07-04 09:43:54 -03:00
|
|
|
struct log_Format formats[LOGREADER_MAX_FORMATS] {};
|
2016-08-25 00:00:41 -03:00
|
|
|
|
|
|
|
private:
|
|
|
|
ssize_t read_input(void *buf, size_t count);
|
|
|
|
|
|
|
|
uint64_t bytes_read = 0;
|
|
|
|
uint32_t message_count = 0;
|
|
|
|
uint64_t start_micros;
|
|
|
|
|
2015-06-29 23:48:49 -03:00
|
|
|
uint64_t packet_counts[LOGREADER_MAX_FORMATS] = {};
|
2015-06-12 09:52:52 -03:00
|
|
|
};
|