SatCat5
satcat5::crc16::XmodemTx Class Reference

Detailed Description

Append FCS to each outgoing frame ("XMODEM" variant).

See also
crc16_checksum.h, crc16::XmodemRx.

Definition at line 67 of file crc16_checksum.h.

#include <crc16_checksum.h>

Inheritance diagram for satcat5::crc16::XmodemTx:
[legend]
Collaboration diagram for satcat5::crc16::XmodemTx:
[legend]

Public Member Functions

 XmodemTx (satcat5::io::Writeable *dst, u16 init=0, u16 xorout=0)
 
bool write_finalize () override
 Mark end of frame and release temporary working data. More...
 
unsigned get_write_space () const override
 How many bytes can be written without blocking? More...
 
void write_abort () override
 If possible, abort the current partially-written packet. More...
 
unsigned byte_count (bool reset=true) override
 Bytes transferred since the last query.
 
unsigned frame_count (bool reset=true) override
 Frames transferred since the last query.
 
unsigned error_count (bool reset=true) override
 (Optional) Error events since the last query.
 
void byte_incr (unsigned incr)
 Increment any of the internal counters.
 
void frame_incr (unsigned incr)
 
void error_incr (unsigned incr)
 
void write_u8 (u8 data)
 One of many functions for writing integer/floating point values, see details. More...
 
virtual void write_bytes (unsigned nbytes, const void *src)
 Write 0 or more bytes from a buffer. More...
 
void write_str (const char *str)
 Write the contents of a null-terminated string. More...
 
template<class T >
void write_obj (const T &obj)
 Templated wrapper for any object with the following method: void write_to(satcat5::io::Writeable* wr) const;
 

Protected Member Functions

void chk_reset () override
 Reset checksum calculation to its initial state.
 
bool chk_finalize ()
 Reset internal state and return true if the frame is valid. More...
 
void write_overflow () override
 Optional error handling for write overflow. More...
 

Protected Attributes

u16 m_chk
 Checksum state.
 
const u16 m_init
 State after reset.
 
satcat5::io::Writeable *const m_dst
 Output object.
 
bool m_ovr
 Overflow flag.
 
unsigned m_byte_ct
 Cumulative byte count.
 
unsigned m_err_ct
 Cumulative error count.
 
unsigned m_frm_ct
 Cumulative frame count.
 
unsigned m_frm_len
 Length of current frame.
 
friend LimitedWrite
 
friend WriteableBroadcast
 
friend WriteableRedirect
 

Private Member Functions

void write_next (u8 data) override
 Write the next byte to the underlying buffer or device. More...
 

Private Attributes

const u16 m_xorout
 

Member Function Documentation

◆ chk_finalize()

bool ChecksumTxCommon::chk_finalize ( )
protectedinherited

Reset internal state and return true if the frame is valid.

i.e., If false, do not forward the write_finalize() event.

Definition at line 24 of file io_checksum.cc.

◆ get_write_space()

unsigned satcat5::io::ChecksumTx< u16 , N >::get_write_space ( ) const
inlineoverridevirtualinherited

How many bytes can be written without blocking?

Child objects of io::Writeable MUST override this method.

Implements satcat5::io::Writeable.

Definition at line 86 of file io_checksum.h.

◆ write_abort()

void ChecksumTxCommon::write_abort ( )
overridevirtualinherited

If possible, abort the current partially-written packet.

Child objects of io::Writeable SHOULD override this method if it is practical to prevent in-progress data from being relayed downstream.

Reimplemented from satcat5::io::Writeable.

Definition at line 16 of file io_checksum.cc.

◆ write_bytes()

void Writeable::write_bytes ( unsigned  nbytes,
const void *  src 
)
virtualinherited

◆ write_finalize()

bool XmodemTx::write_finalize ( )
overridevirtual

Mark end of frame and release temporary working data.

Child objects of io::Writeable SHOULD override this method to mark frame bounds.

Returns
True if successful, false on error.

Reimplemented from satcat5::io::Writeable.

Definition at line 210 of file crc16_checksum.cc.

◆ write_next()

void XmodemTx::write_next ( u8  data)
overrideprivatevirtual

Write the next byte to the underlying buffer or device.

Child objects of io::Writeable MUST override this method.

Implements satcat5::io::Writeable.

Definition at line 216 of file crc16_checksum.cc.

◆ write_overflow()

void ChecksumTxCommon::write_overflow ( )
overrideprotectedvirtualinherited

Optional error handling for write overflow.

Child objects of io::Writeable MAY override this method for error handling.

Reimplemented from satcat5::io::Writeable.

Definition at line 12 of file io_checksum.cc.

◆ write_str()

void Writeable::write_str ( const char *  str)
inherited

Write the contents of a null-terminated string.

Note: Null-termination is not copied to the output.

Definition at line 180 of file io_writeable.cc.

◆ write_u8()

void Writeable::write_u8 ( u8  data)
inherited

One of many functions for writing integer/floating point values, see details.

Several functions are provided for reading and writing scalar types to/from io::Readable and io::Writeable instances. Since there are many of these that are frequently inherited, they are hidden from documentation. These functions follow a shared template:

  • read_ or write_ prefix.
  • u for unsigned, s for signed, f for floating-point.
  • Data-type width in bits.
    • Available widths for ints: 8/16/24/32/48/64.
    • Available widths for floats: 32/64.
  • l suffix if little-endian, no suffix if big-endian.

Example: write_s48l is "Write 48 bits (6 bytes) to this io::Writeable as a signed value in little-endian order".

Definition at line 20 of file io_writeable.cc.


The documentation for this class was generated from the following files: