36 #include <satcat5/pkt_buffer.h>
42 constexpr u16 VERSION_MASK = 0xC000;
43 constexpr u16 SCID_MASK = 0x3FC0;
44 constexpr u16 VCID_MASK = 0x003F;
45 constexpr u8 REPLAY_MASK = 0x80;
46 constexpr u8 FRCT_EXT_MASK = 0x40;
47 constexpr u8 RSVD_MASK = 0x30;
48 constexpr u8 FRCT_VAL_MASK = 0x0F;
49 constexpr u16 VERSION_2 = (1 << 14);
53 constexpr u8 TM_SYNC_BYTES[] = {0x1A, 0xCF, 0xFC, 0x1D};
56 constexpr u16 VCID_DEFAULT = 0x0000;
57 constexpr u16 VCID_IDLE = 0x003F;
79 {
return (u16(
scid) << 6) & SCID_MASK; }
82 {
return u16(
vcid) & VCID_MASK; }
86 {
return id & VERSION_MASK; }
88 {
return u8((
id & SCID_MASK) >> 6); }
90 {
return u8(
id & VCID_MASK); }
92 {
return !!(
signal & REPLAY_MASK); }
119 u8 scid, u8 vcid,
bool pkt);
120 ~
Channel() SATCAT5_OPTIONAL_DTOR;
142 enum class State {RAW, RESYNC, HEADER, DATA, SKIP};
149 satcat5::ccsds_aos::Channel::State m_rx_state;
172 u8* buff,
unsigned dsize,
173 bool insert_sync =
false);
187 inline void error_incr()
190 {
return m_dsize + 6;}
192 {
return m_rcvd_hdr; }
206 const unsigned m_dsize;
223 template<
unsigned DSIZE=251>
229 bool insert_sync =
false)
230 :
Dispatch(src, dst, m_raw, DSIZE, insert_sync), m_raw{} {}
constexpr u32 TM_SYNC_WORD
Sync-word for CCSDS "TM Synchronization and Channel Coding".
CCSDS-AOS Virtual Channel.
void frame_rcvd(satcat5::io::LimitedRead &src) override
Process each received AOS frame.
void data_rcvd(satcat5::io::Readable *src) override
The data_rcvd() callback is polled whenever data is available.
Channel(satcat5::ccsds_aos::Dispatch *iface, satcat5::io::Readable *src, satcat5::io::Writeable *dst, u8 scid, u8 vcid, bool pkt)
Create a virtual channel, bound to an AOS interface.
void data_unlink(satcat5::io::Readable *src) override
Unlink this EventListener from the designated source, because the designated Readable object is being...
void set_wildcard()
Enable wildcard mode, ignoring incoming SCID and VCID.
void desync()
Force resynchronization after an error.
Implemention of "net::Dispatch" API for CCSDS-AOS protocol.
satcat5::io::TrafficStats stats()
Report packet statistics since the previous query.
void data_rcvd(satcat5::io::Readable *src) override
The data_rcvd() callback is polled whenever data is available.
satcat5::io::Writeable * open_write(const satcat5::ccsds_aos::Header &hdr)
Write CCSDS-AOS frame header and get Writeable object.
void data_unlink(satcat5::io::Readable *src) override
Unlink this EventListener from the designated source, because the designated Readable object is being...
satcat5::io::Writeable * open_reply(const satcat5::net::Type &type, unsigned len) override
Open a reply to the sender of the most recent message by writing frame header(s) and returning a stre...
unsigned tsize() const
< Total size = Header + Data
unsigned dsize() const
< Data field size
const satcat5::ccsds_aos::Header & rcvd_hdr() const
Most recent received header.
Dispatch with a statically-allocated working buffer.
Check and remove FCS from each incoming frame ("XMODEM" variant).
Append FCS to each outgoing frame ("XMODEM" variant).
Ephemeral Writeable interface for a simple array.
void error_incr()
Increment the internal error counter.
Event-handler interface for newly received data.
Limited read of next N bytes.
Abstract API for reading byte-streams and packets.
Abstract API for writing byte-streams and packets.
The "Dispatch" is a generic interface that knows how to read a designated protocol layer and sort inc...
Dispatch()
Constructor and destructor access restricted to children.
A net::Protocol is the counterpart to net::Dispatch that handles a particular data stream,...
Inline CRC16 Checksum insertion and verification.
Generic network Dispatch API.
Data structure for combined transmit and receive statistics.
static TrafficStats query(satcat5::io::Counter &rx, satcat5::io::Counter &tx)
Read updated statistics from a transmit/receive pair.
Multipurpose filter for matching fields in network packets.