|
SatCat5
|
Buffered COBS encoder / decoder pair with opposite polarity.
Suitable for use in unit testing and verification. This configuration is not typically useful in deployed hardware.
Rx path: Write (*this) -> COBS decode (parent) -> Write (*dst)
Tx path: Read (*src) -> COBS encode -> Buffer -> Read (*this)
Definition at line 128 of file codec_cobs.h.
#include <codec_cobs.h>
Public Member Functions | |
| CobsCodecInverse (satcat5::io::Writeable *dst, satcat5::io::Readable *src) | |
| Constructor links to specified source and destination. More... | |
| unsigned | get_write_space () const override |
| How many bytes can be written without blocking? More... | |
| 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... | |
| virtual bool | write_finalize () |
| Mark end of frame and release temporary working data. More... | |
| virtual void | write_abort () |
| If possible, abort the current partially-written packet. 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 | set_callback (satcat5::io::EventListener *callback) override |
| Update registered callback for data_rcvd() events. More... | |
| unsigned | get_read_ready () const override |
| How many bytes can be read without blocking? More... | |
| bool | read_bytes (unsigned nbytes, void *dst) override |
| Read 0 or more bytes into a buffer. More... | |
| bool | read_consume (unsigned nbytes) override |
| Read and discard 0 or more bytes. More... | |
| void | read_finalize () override |
| Consume any remaining bytes in this frame, if applicable. More... | |
| u8 | read_u8 () |
| One of many functions for reading integer/floating point values, see details. More... | |
| unsigned | read_str (unsigned dst_size, char *dst) |
| Safely read a null-terminated input string. More... | |
| template<class T > | |
| bool | read_obj (T &t) |
Templated wrapper for any object with the following method: bool read_from(satcat5::io::Readable* rd); | |
| unsigned | copy_to (satcat5::io::Writeable *dst) |
| Copy data to a Writeable object, without finalizing. More... | |
| bool | copy_and_finalize (satcat5::io::Writeable *dst, satcat5::io::CopyMode mode=CopyMode::PACKET) |
| Copy data to a Writeable object, then finalize. More... | |
| void | request_poll () |
| Call this method to request polling at a later time. More... | |
| void | request_cancel () |
| Call this method to cancel a previous request_poll(). | |
Static Public Member Functions | |
| static unsigned | count_ondemand () |
| Count queued objects of this type (i.e., non-idle). | |
Protected Member Functions | |
| u8 | read_next () override |
| Read the next byte from the underlying buffer or device. More... | |
| void | read_underflow () override |
| Optional error handling for read underflow. More... | |
| void | read_src (satcat5::io::Readable *src) |
| Children may reset the source object as needed. | |
| void | read_notify () |
Attempt notification by calling m_callback->data_rcvd(). More... | |
Protected Attributes | |
| satcat5::io::PacketBuffer | m_buff |
| Encoder writes to buffer. | |
| satcat5::io::CobsEncoder | m_encode |
| Encoder object. | |
| satcat5::io::BufferedCopy | m_copy |
| Push/pull adapter. | |
| u8 | m_rawbuff [SATCAT5_COBS_BUFFSIZE] |
| Working buffer for m_rx. | |
| 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... | |
| void | write_overflow () override |
| Optional error handling for write overflow. More... | |
| void | poll_demand () |
| Event handler for on-demand polling. | |
Private Attributes | |
| satcat5::io::Writeable *const | m_dst |
| u8 | m_blk |
| u8 | m_ctr |
| u8 | m_ovr |
| satcat5::io::Readable * | m_src |
| satcat5::io::EventListener * | m_callback |
| Pointer to the callback object, or NULL. More... | |
| satcat5::poll::OnDemand * | m_next |
| bool | m_idle |
| CobsCodecInverse::CobsCodecInverse | ( | satcat5::io::Writeable * | dst, |
| satcat5::io::Readable * | src | ||
| ) |
Constructor links to specified source and destination.
In many cases, dst and src are the same BufferedIO object.
Definition at line 148 of file codec_cobs.cc.
|
inherited |
Copy data to a Writeable object, then finalize.
As copy_to(), but also calls read_finalize() and/or write_finalize() depending on the input/output mode.
In packet mode (the default), call both read_finalize() and write_finalize() if the operation copies all available data. Use this mode whenever the input is packetized.
In byte-stream mode, call write_finalize() if the operation copies any data, but never call read_finalize(). Use this mode for inputs that do not delimit packet boundaries.
| dst | The destination object. |
| mode | Select packet mode or stream mode. |
Definition at line 234 of file io_readable.cc.
|
inherited |
Copy data to a Writeable object, without finalizing.
Copy the contents of this Readable to a Writeable object, stopping at end-of-input, end-of-frame, or the capacity of the destination buffer (whichever comes first). This method does not call read_finalize or write_finalize(). To automatically make finalize calls,
Definition at line 214 of file io_readable.cc.
|
overridevirtualinherited |
How many bytes can be read without blocking?
Child objects of io::Readable MUST override this method.
Implements satcat5::io::Readable.
Definition at line 336 of file io_readable.cc.
|
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 98 of file codec_cobs.cc.
|
overridevirtualinherited |
Read 0 or more bytes into a buffer.
Child objects of io::Readable MAY override this method for improved performance.
Reimplemented from satcat5::io::Readable.
Definition at line 339 of file io_readable.cc.
|
overridevirtualinherited |
Read and discard 0 or more bytes.
Child objects of io::Readable MAY override this method for improved performance.
Reimplemented from satcat5::io::Readable.
Definition at line 342 of file io_readable.cc.
|
overridevirtualinherited |
Consume any remaining bytes in this frame, if applicable.
Child objects of io::Readable SHOULD override this method if they support framing.
Reimplemented from satcat5::io::Readable.
Definition at line 345 of file io_readable.cc.
|
overrideprotectedvirtualinherited |
Read the next byte from the underlying buffer or device.
Child objects of io::Readable MUST override this method.
Implements satcat5::io::Readable.
Definition at line 348 of file io_readable.cc.
|
protectedinherited |
Attempt notification by calling m_callback->data_rcvd().
Child objects of io::Readable MAY call this to override default notifications.
Definition at line 254 of file io_readable.cc.
|
inherited |
Safely read a null-terminated input string.
The input is always consumed up to the end-of-input or the first zero byte, whichever comes first.
Definition at line 179 of file io_readable.cc.
|
inherited |
One of many functions for reading 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.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 44 of file io_readable.cc.
|
overrideprotectedvirtualinherited |
Optional error handling for read underflow.
Child objects of io::Readable MAY override this method.
Reimplemented from satcat5::io::Readable.
Definition at line 351 of file io_readable.cc.
|
inherited |
Call this method to request polling at a later time.
Safe to stack requests, but only one call to poll().
Definition at line 208 of file polling.cc.
|
overridevirtualinherited |
Update registered callback for data_rcvd() events.
Child objects of io::Readable SHOULD usually leave this method as-is.
Reimplemented from satcat5::io::Readable.
Definition at line 331 of file io_readable.cc.
|
virtualinherited |
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 in satcat5::port::Mailmap, satcat5::io::PacketBuffer, satcat5::io::MultiWriter, satcat5::io::WriteableRedirect, satcat5::io::ArrayWrite, satcat5::io::CounterInline, satcat5::io::ChecksumRxCommon, satcat5::io::ChecksumTxCommon, satcat5::io::WriteableBroadcast, satcat5::eth::SwitchPort, satcat5::io::HdlcEncoder::ByteStuff, and satcat5::io::FileWriter.
Definition at line 186 of file io_writeable.cc.
|
virtualinherited |
Write 0 or more bytes from a buffer.
Child objects of io::Writeable MAY override write_bytes as needed for performance.
Reimplemented in satcat5::port::MailmapAligned, satcat5::port::Mailmap, satcat5::io::PacketBuffer, satcat5::io::MultiWriter, satcat5::io::MultiPacket::Overwriter, satcat5::io::NullWrite, satcat5::io::WriteableRedirect, satcat5::io::LimitedWrite, satcat5::io::CounterInline, satcat5::io::WriteableBroadcast, and satcat5::io::FileWriter.
Definition at line 170 of file io_writeable.cc.
|
virtualinherited |
Mark end of frame and release temporary working data.
Child objects of io::Writeable SHOULD override this method to mark frame bounds.
Reimplemented in satcat5::port::Mailmap, satcat5::io::PacketBuffer, satcat5::io::MultiWriterBypass, satcat5::io::MultiWriter, satcat5::io::WriteableRedirect, satcat5::io::ArrayWrite, satcat5::io::WriteableThrottle, satcat5::io::CounterInline, satcat5::io::WriteableBroadcastAny, satcat5::io::WriteableBroadcast, satcat5::eth::SwitchPort, satcat5::eth::ChecksumRx, satcat5::eth::ChecksumTx, satcat5::crc16::XmodemRx, satcat5::crc16::XmodemTx, satcat5::crc16::KermitRx, satcat5::crc16::KermitTx, satcat5::io::SlipEncoder, satcat5::io::HdlcEncoder::ByteStuff, satcat5::io::CobsEncoder, satcat5::coap::Connection, satcat5::test::EthernetInterface, satcat5::io::BufferedTee, satcat5::io::WritePcapInterface, satcat5::io::WritePcap, satcat5::io::FileWriter, and satcat5::util::ChatPrinter.
Definition at line 185 of file io_writeable.cc.
|
overrideprivatevirtualinherited |
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 103 of file codec_cobs.cc.
|
overrideprivatevirtualinherited |
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 132 of file codec_cobs.cc.
|
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.
|
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.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.
|
privateinherited |
Pointer to the callback object, or NULL.
This can only be modified through the set_callback(...) method.
Definition at line 199 of file io_readable.h.