48 lines
1.2 KiB
C
48 lines
1.2 KiB
C
/*
|
|
* MTG RFID Companion - In-memory Serial Log Ring Buffer
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include "esp_err.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* @brief Initialize the serial log ring buffer and hook into esp_log_set_vprintf.
|
|
*
|
|
* Hardware UART serial output remains active and unaffected.
|
|
*/
|
|
esp_err_t serial_log_init(void);
|
|
|
|
/**
|
|
* @brief Read logs starting from a specific byte offset.
|
|
*
|
|
* @param from_offset Monotonically increasing byte sequence offset previously read.
|
|
* If 0 or if the offset has fallen outside the ring buffer window,
|
|
* the available recent buffer content is returned.
|
|
* @param dest Output buffer to receive log bytes.
|
|
* @param max_len Maximum bytes to write into dest.
|
|
* @param next_offset Pointer to store the new byte offset cursor.
|
|
* @return Number of bytes copied into dest.
|
|
*/
|
|
size_t serial_log_read(uint32_t from_offset, char *dest, size_t max_len, uint32_t *next_offset);
|
|
|
|
/**
|
|
* @brief Clear the serial log buffer.
|
|
*/
|
|
void serial_log_clear(void);
|
|
|
|
/**
|
|
* @brief Get total lifetime log bytes written.
|
|
*/
|
|
uint32_t serial_log_get_total_bytes(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|