14 unsigned CounterSimple::byte_count(
bool reset)
15 {
return satcat5::util::poll_counter(
m_byte_ct, reset); }
17 {
return satcat5::util::poll_counter(
m_frm_ct, reset); }
19 {
return satcat5::util::poll_counter(
m_err_ct, reset); }
Define a generic API for reporting traffic statistics.
virtual unsigned error_count(bool reset=true)
(Optional) Error events since the last query.
virtual unsigned frame_count(bool reset=true)=0
Frames transferred since the last query.
virtual unsigned byte_count(bool reset=true)=0
Bytes transferred since the last query.
Overlay class for adding counters to any Writeable interface.
void write_next(u8 data) override
Write the next byte to the underlying buffer or device.
bool write_finalize() override
Mark end of frame and release temporary working data.
void write_abort() override
If possible, abort the current partially-written packet.
void write_bytes(unsigned nbytes, const void *src) override
Write 0 or more bytes from a buffer.
Simple implementation of the Counter API.
unsigned m_err_ct
Cumulative error count.
unsigned error_count(bool reset=true) override
(Optional) Error events since the last query.
unsigned m_frm_ct
Cumulative frame count.
unsigned frame_count(bool reset=true) override
Frames transferred since the last query.
unsigned m_frm_len
Length of current frame.
unsigned m_byte_ct
Cumulative byte count.
void write_next(u8 data) override
Write the next byte to the underlying buffer or device.
bool write_finalize() override
Mark end of frame and release temporary working data.
void write_bytes(unsigned nbytes, const void *src) override
Write 0 or more bytes from a buffer.
void write_abort() override
If possible, abort the current partially-written packet.
Inline byte and packet counters for statistics and diagnostics.
Data structure for combined transmit and receive statistics.
bool any() const
Nonzero activity on any of the counters?
unsigned rcvd_bytes
Bytes received from remote device.
static TrafficStats query(satcat5::io::Counter &rx, satcat5::io::Counter &tx)
Read updated statistics from a transmit/receive pair.
unsigned sent_frames
Frames sent to remote device.
unsigned sent_bytes
Bytes sent to remote device.
unsigned rcvd_errors
Invalid frames received from device.
unsigned rcvd_frames
Valid frames received from device.
Miscellaneous mathematical utility functions.