82 template <
class T,
unsigned N>
89 return (
m_ovr || nbytes < N) ? (0) : (nbytes - N);
132 virtual void chk_reset() = 0;
148 template <
class T,
unsigned N>
166 constexpr T MASK = satcat5::util::mask_lower<T>(8*N);
189 constexpr
unsigned SHIFT = 8 * (N - 1);
190 T tmp =
static_cast<T
>(data);
191 data = (u8)(
m_sreg >> SHIFT);
Parent class for non-template elements of ChecksumRx.
satcat5::io::Writeable *const m_dst
Output object.
void error_incr()
Increment the internal error counter.
void write_abort() override
If possible, abort the current partially-written packet.
unsigned get_write_space() const override
How many bytes can be written without blocking?
constexpr ChecksumRxCommon(satcat5::io::Writeable *dst)
Only the child class has access to the constructor.
Check and remove FCS from each incoming frame.
bool sreg_match(T fcs)
Child class MUST call sreg_match(...) during write_finalize().
ChecksumRx(satcat5::io::Writeable *dst, T init)
Only the child class has access to the constructor.
T m_sreg
Big-endian input buffer.
const T m_init
State after reset.
bool sreg_push(u8 &data)
Child class MUST call sreg_push(...) during write_next().
void chk_reset() override
Reset checksum calculation to its initial state.
Parent class for non-template elements of ChecksumTx.
constexpr ChecksumTxCommon(satcat5::io::Writeable *dst)
Only the child class has access to the constructor.
void write_overflow() override
Optional error handling for write overflow.
virtual void chk_reset()=0
Reset the checksum calculation to its initial state.
void write_abort() override
If possible, abort the current partially-written packet.
bool chk_finalize()
Reset internal state and return true if the frame is valid.
satcat5::io::Writeable *const m_dst
Output object.
Inline checksum insertion, appends FCS to each outgoing frame.
unsigned get_write_space() const override
How many bytes can be written without blocking?
const T m_init
State after reset.
ChecksumTx(satcat5::io::Writeable *dst, T init)
Only the child class has access to the constructor.
void chk_reset() override
Reset checksum calculation to its initial state.
Simple implementation of the Counter API.
unsigned m_err_ct
Cumulative error count.
unsigned m_frm_ct
Cumulative frame count.
unsigned m_frm_len
Length of current frame.
unsigned m_byte_ct
Cumulative byte count.
Abstract API for writing byte-streams and packets.
virtual unsigned get_write_space() const =0
How many bytes can be written without blocking?
virtual void write_abort()
If possible, abort the current partially-written packet.
void write_u8(u8 data)
One of many functions for writing integer/floating point values, see details.
virtual bool write_finalize()
Mark end of frame and release temporary working data.
Inline byte and packet counters for statistics and diagnostics.
"Writeable" I/O interface core definitions
Miscellaneous mathematical utility functions.