Public Access
Peak stack use was measured through each task's worst case (an ECDSA-checked install over Wi-Fi and from SD, get/put, a core dump fetch, an IRC TLS handshake); stacks are now peak plus about 2 KB: loop 8 -> 6 KB, update 8 -> 5, storage 10 -> 6, irc 8 -> 6. The Debug Build's console ring goes 6 -> 4 KB, serial TX 2 -> 1 KB, the GNSS UART buffer 1 KB -> 512 B. On the device, with IRC on TLS: 46 KB free (was 31), an 18 KB low (was 9.4). The re-run of every worst case left at least 1.6 KB of stack free in each task. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
41 lines
1.5 KiB
C++
41 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <Print.h>
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
|
|
namespace roro {
|
|
|
|
// Where the firmware's console output goes: the USB serial port, and in a Debug Build also a ring
|
|
// buffer the Debug Console sends over Wi-Fi (with what came before the connection, so boot messages
|
|
// aren't lost). Use `console` instead of Serial for anything a human should be able to read remotely.
|
|
class Console : public Print {
|
|
public:
|
|
size_t write(uint8_t c) override { return write(&c, 1); }
|
|
size_t write(const uint8_t* data, size_t len) override;
|
|
using Print::write;
|
|
|
|
#ifdef RORO_DEBUG
|
|
static constexpr size_t kRingBytes = 4096;
|
|
|
|
// Also copies ESP-IDF's own log lines into the ring (they still reach the serial port).
|
|
void captureEspLogs();
|
|
// Copies bytes written since `pos` into `out`, and advances `pos`. A reader that fell more than
|
|
// the ring behind gets the oldest bytes still there, and `skipped` says how many it missed.
|
|
size_t readSince(uint32_t& pos, uint8_t* out, size_t max, uint32_t& skipped);
|
|
// The position of the oldest byte still in the ring: a new reader starts there.
|
|
uint32_t oldest() const;
|
|
// The ring only, for output that already reaches the serial port another way.
|
|
void toRing(const uint8_t* data, size_t len);
|
|
|
|
private:
|
|
uint8_t ring_[kRingBytes];
|
|
uint32_t head_ = 0; // total bytes ever written; the ring holds the last kRingBytes of them
|
|
#endif
|
|
};
|
|
|
|
extern Console console;
|
|
|
|
} // namespace roro
|