serial log on webserver
Some checks failed
ESP32 Build & Release / build (push) Failing after 15s

This commit is contained in:
2026-09-16 17:08:26 +02:00
parent dd04016fc3
commit 9c5f62b6de
7 changed files with 469 additions and 8 deletions

47
main/serial_log.h Normal file
View File

@@ -0,0 +1,47 @@
/*
* 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