17 #ifndef SATCAT5_SLIP_LOG_ERROR
18 #define SATCAT5_SLIP_LOG_ERROR 1
22 static const u8 SLIP_END = 0xC0;
23 static const u8 SLIP_ESC = 0xDB;
24 static const u8 SLIP_ESC_END = 0xDC;
25 static const u8 SLIP_ESC_ESC = 0xDD;
26 static const u16 SLIP_ESC_W_END = 0xDBDC;
27 static const u16 SLIP_ESC_W_ESC = 0xDBDD;
72 if (data == SLIP_END) {
73 m_dst->write_u16(SLIP_ESC_W_END);
74 }
else if (data == SLIP_ESC) {
75 m_dst->write_u16(SLIP_ESC_W_ESC);
84 , m_state(State::SLIP_EOF)
97 if (data == SLIP_END) {
100 if (m_state == State::SLIP_RDY) {
102 }
else if (m_state != State::SLIP_EOF) {
103 if (SATCAT5_SLIP_LOG_ERROR)
107 m_state = State::SLIP_EOF;
108 }
else if (m_state == State::SLIP_ERR) {
110 }
else if (data == SLIP_ESC) {
111 m_state = State::SLIP_ESC;
112 }
else if (m_state != State::SLIP_ESC) {
114 m_state = State::SLIP_RDY;
115 }
else if (data == SLIP_ESC_END) {
117 m_state = State::SLIP_RDY;
118 }
else if (data == SLIP_ESC_ESC) {
120 m_state = State::SLIP_RDY;
122 m_state = State::SLIP_ERR;
129 m_state = State::SLIP_ERR;
137 , m_buff(m_rawbuff, SATCAT5_SLIP_BUFFSIZE, SATCAT5_SLIP_PACKETS)
139 , m_copy(src, &m_decode)
147 , m_buff(m_rawbuff, SATCAT5_SLIP_BUFFSIZE, 0)
149 , m_copy(src, &m_encode)
Abstract API for reading byte-streams and packets.
Wrapper class for forwarding reads to another object.
Buffered SLIP encoder / decoder pair.
SlipCodec(satcat5::io::Writeable *dst, satcat5::io::Readable *src)
Constructor links to specified source and destination.
Buffered SLIP encoder / decoder pair with opposite polarity.
SlipCodecInverse(satcat5::io::Writeable *dst, satcat5::io::Readable *src)
Constructor links to specified source and destination.
unsigned get_write_space() const override
How many bytes can be written without blocking?
void write_next(u8 data) override
Write the next byte to the underlying buffer or device.
SlipDecoder(satcat5::io::Writeable *dst)
Permanently link this encoder to an output object.
void write_overflow() override
Optional error handling for write overflow.
void write_overflow() override
Optional error handling for write overflow.
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.
unsigned get_write_space() const override
How many bytes can be written without blocking?
Abstract API for writing byte-streams and packets.
virtual unsigned get_write_space() const =0
How many bytes can be written without blocking?
virtual void write_abort()
If possible, abort the current partially-written packet.
void write_u8(u8 data)
One of many functions for writing integer/floating point values, see details.
virtual bool write_finalize()
Mark end of frame and release temporary working data.
The Log class creates and formats one log message.
Inline SLIP encoder and decoder objects.
Diagnostic logging to UART and/or Ethernet ports.