21#ifndef LSH_CORE_COMMUNICATION_MSGPACK_SERIAL_FRAMING_HPP
22#define LSH_CORE_COMMUNICATION_MSGPACK_SERIAL_FRAMING_HPP
26namespace lsh::core::transport
49 char *
const frameBuffer;
50 const uint16_t frameCapacity;
51 uint16_t frameLengthBytes = 0U;
52 uint32_t lastByteTimeMs = 0U;
53 bool escapePending =
false;
54 bool discardUntilFrameEnd =
false;
56 [[nodiscard]]
auto appendByte(uint8_t
byte) -> bool;
57 void startDiscarding()
noexcept;
62 void reset()
noexcept;
63 void resetIfIdle(uint32_t nowMs, uint32_t idleTimeoutMs)
noexcept;
65 [[nodiscard]]
auto frameData()
const ->
const uint8_t *;
Incremental receiver for the SLIP-like MsgPack framing used on the bridge serial link.
Definition msgpack_serial_framing.hpp:47
auto frameData() const -> const uint8_t *
Return the beginning of the completed payload buffer.
Definition msgpack_serial_framing.cpp:190
auto frameLength() const -> uint16_t
Return the current payload length assembled by the receiver.
Definition msgpack_serial_framing.cpp:200
auto consumeByte(uint8_t byte, uint32_t nowMs) -> MsgPackFrameConsumeResult
Feed one raw serial byte into the framed MsgPack receiver.
Definition msgpack_serial_framing.cpp:115
void resetIfIdle(uint32_t nowMs, uint32_t idleTimeoutMs) noexcept
Drop a partially received frame that has been silent for too long.
Definition msgpack_serial_framing.cpp:55
void reset() noexcept
Forget the current receive state and return to the idle state.
Definition msgpack_serial_framing.cpp:39
constexpr uint8_t MSGPACK_FRAME_END
Delimiter byte that separates adjacent framed MsgPack payloads.
Definition msgpack_serial_framing.hpp:28
constexpr uint8_t MSGPACK_FRAME_ESCAPED_END
Escaped representation of MSGPACK_FRAME_END.
Definition msgpack_serial_framing.hpp:30
constexpr uint8_t MSGPACK_FRAME_ESCAPE
Escape marker emitted before reserved payload bytes.
Definition msgpack_serial_framing.hpp:29
constexpr uint8_t MSGPACK_FRAME_ESCAPED_ESCAPE
Escaped representation of MSGPACK_FRAME_ESCAPE.
Definition msgpack_serial_framing.hpp:31
MsgPackFrameConsumeResult
Outcome of feeding one raw serial byte into the MsgPack frame receiver.
Definition msgpack_serial_framing.hpp:37
@ FrameDiscarded
One corrupted or oversized frame has just been dropped at its closing delimiter.
@ Incomplete
The byte has been consumed, but no full payload is ready yet.
@ FrameComplete
One complete deframed payload is ready in the destination buffer.