SatCat5
pkt_combiner.h
1 // Copyright 2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 // Combine packets
6 //
7 
8 #pragma once
9 
10 #include <satcat5/io_core.h>
11 #include <satcat5/pkt_buffer.h>
12 #include <satcat5/polling.h>
13 #include <satcat5/types.h>
14 
15 namespace satcat5 {
16  namespace io {
27  , public satcat5::poll::Timer
28  {
29  public:
32  u8* buff, unsigned buffbytes);
33  ~PacketCombiner() {}
34 
36  void send_now();
37 
41  void set_timeout(unsigned msec);
42  protected:
43  void data_rcvd(satcat5::io::Readable* src) override;
44  void timer_event() override;
45 
48  unsigned m_timeout;
49  };
50 
55  template<unsigned SIZE = SATCAT5_DEFAULT_PKTBUFF>
57  public:
60  : PacketCombiner(dst, m_raw, SIZE), m_raw{} {}
61  private:
62  u8 m_raw[SIZE];
63  };
64  }
65 }
Event-handler interface for newly received data.
Definition: io_readable.h:43
The PacketBuffer class is a wrapper for a circular buffer, with optional logic to support retention o...
Definition: pkt_buffer.h:66
The PacketCombiner class combines packets written to it into a single packet, and forwards it to a Wr...
Definition: pkt_combiner.h:28
void set_timeout(unsigned msec)
Set a timeout for automatic data forwarding after a period, if the buffer is not yet full.
Definition: pkt_combiner.cc:30
void send_now()
Send the buffer now.
Definition: pkt_combiner.cc:20
PacketCombiner(satcat5::io::Writeable *dst, u8 *buff, unsigned buffbytes)
Create an object that combines packets.
Definition: pkt_combiner.cc:10
void data_rcvd(satcat5::io::Readable *src) override
The data_rcvd() callback is polled whenever data is available.
Definition: pkt_combiner.cc:39
void timer_event() override
Child class MUST override this method.
Definition: pkt_combiner.cc:59
PacketCombiner with statically-allocated working memory.
Definition: pkt_combiner.h:56
PacketCombinerStatic(satcat5::io::Writeable *dst)
Link parent object to the statically allocated buffer.
Definition: pkt_combiner.h:59
Abstract API for reading byte-streams and packets.
Definition: io_readable.h:68
Abstract API for writing byte-streams and packets.
Definition: io_writeable.h:24
Wrapper class for forwarding writes to another object.
Definition: io_writeable.h:218
Timer objects are polled after a fixed delay or at a regular interval.
Definition: polling.h:213
I/O interface core definitions.
Core event-processing loop for SatCat5 software.
Basic type aliases and prototypes used throughout SatCat5.