SatCat5
satcat5::port::RecoveryEgress Class Reference

Detailed Description

MultiWriter that slips packets written to it into the port's egress buffer.

Definition at line 44 of file port_recovery.h.

#include <port_recovery.h>

Inheritance diagram for satcat5::port::RecoveryEgress:
[legend]
Collaboration diagram for satcat5::port::RecoveryEgress:
[legend]

Public Member Functions

 RecoveryEgress (satcat5::eth::SwitchPort *port)
 Egress interface attaches to an Ethernet port.
 
bool write_finalize () override
 Override redirects to write_bypass().
 
void set_max_packet (unsigned max_bytes)
 Update the maximum allowed packet length. More...
 
void set_priority (u16 priority)
 Set priority of the current packet. More...
 
void set_timeout (unsigned timeout_msec)
 Update the watchdog timeout. More...
 
unsigned get_write_partial () const
 Get current write length.
 
unsigned get_write_space () const override
 How many bytes can be written without blocking? More...
 
void write_bytes (unsigned nbytes, const void *src) override
 Write 0 or more bytes from a buffer. More...
 
void write_abort () override
 If possible, abort the current partially-written packet. More...
 
bool write_bypass (satcat5::io::MultiReader *dst)
 Deliver data directly to the designated MultiReader. More...
 
void write_u8 (u8 data)
 One of many functions for writing integer/floating point values, see details. 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;
 
void timer_once (unsigned msec)
 Configure a one-time notification after X milliseconds.
 
void timer_every (unsigned msec)
 Configure a repeating notification every X milliseconds.
 
void timer_stop ()
 Stop all future notifications.
 
unsigned timer_interval () const
 Accessor for recurring timer interval, if one is set.
 
unsigned timer_remaining () const
 Accessor for time to next event, if one is set.
 

Static Public Member Functions

static unsigned count_timer ()
 Count all objects of this type, including idle timers.
 

Protected Member Functions

void timer_event () override
 Timeouts help prevent resource-hogging.
 
void write_next (u8 data) override
 Write the next byte to the underlying buffer or device. More...
 
void write_overflow () override
 Optional error handling for write overflow. More...
 
unsigned write_prep ()
 Open a new packet or allocate additional buffers. More...
 
satcat5::io::MultiPacketprepare_pkt ()
 Prepare packet for delivery and reset internal state.
 

Protected Attributes

satcat5::io::MultiReader *const m_dst
 
u16 m_priority
 
friend LimitedWrite
 
friend WriteableBroadcast
 
friend WriteableRedirect
 
satcat5::io::MultiPacketm_write_pkt
 Current write state.
 
satcat5::io::MultiChunkm_write_tail
 Current write state.
 
unsigned m_write_pos
 Current write state.
 
unsigned m_write_len
 Current write state.
 
unsigned m_write_maxlen
 Current write state.
 
unsigned m_write_timeout
 Current write state.
 

Private Member Functions

void query (unsigned elapsed_msec)
 

Private Attributes

satcat5::poll::Timerm_next
 
unsigned m_trem
 
unsigned m_tnext
 

Member Function Documentation

◆ get_write_space()

unsigned MultiWriter::get_write_space ( ) const
overridevirtualinherited

How many bytes can be written without blocking?

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

Implements satcat5::io::Writeable.

Definition at line 465 of file multi_buffer.cc.

◆ set_max_packet()

void satcat5::io::MultiWriter::set_max_packet ( unsigned  max_bytes)
inlineinherited

Update the maximum allowed packet length.

(Longer packets are terminated to avoid resource hogging.)

Definition at line 413 of file multi_buffer.h.

◆ set_priority()

void MultiWriter::set_priority ( u16  priority)
inherited

Set priority of the current packet.

Call this method after writing data, but before calling write_finalize or write_bypass. Priority affects readout order for recipient(s) using the MultiReaderPriority class.

Definition at line 461 of file multi_buffer.cc.

◆ set_timeout()

void satcat5::io::MultiWriter::set_timeout ( unsigned  timeout_msec)
inlineinherited

Update the watchdog timeout.

The watchdog is reset each time a byte is written; if a partial packet is not finalized or aborted within the time limit, then it is dicarded.

Definition at line 425 of file multi_buffer.h.

◆ write_abort()

void MultiWriter::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 504 of file multi_buffer.cc.

◆ write_bypass()

bool MultiWriter::write_bypass ( satcat5::io::MultiReader dst)
inherited

Deliver data directly to the designated MultiReader.

The write_finalize method delivers the current packet to the MultiBuffer, which then decides which port(s) should receive that packet.

See also
MultiBuffer::deliver

This alternative method delivers the packet directly to the designated MultiReader, bypassing MultiBuffer delivery logic.

Definition at line 521 of file multi_buffer.cc.

◆ write_bytes()

void MultiWriter::write_bytes ( unsigned  nbytes,
const void *  src 
)
overridevirtualinherited

Write 0 or more bytes from a buffer.

Child objects of io::Writeable MAY override write_bytes as needed for performance.

Reimplemented from satcat5::io::Writeable.

Definition at line 474 of file multi_buffer.cc.

◆ write_next()

void MultiWriter::write_next ( u8  data)
overrideprotectedvirtualinherited

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 531 of file multi_buffer.cc.

◆ write_overflow()

void MultiWriter::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 547 of file multi_buffer.cc.

◆ write_prep()

unsigned MultiWriter::write_prep ( )
protectedinherited

Open a new packet or allocate additional buffers.

Returns
The number of bytes that can be written.

Definition at line 558 of file multi_buffer.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: