|
TinyModem
Header-only software audio modem library
|
Splits the written data into packets with a CRC-16 and Reed-Solomon forward error correction, which are framed with HDLC-style flags (0x7E) and byte stuffing, and writes them to the output (e.g. a ModemStream). More...
#include <PacketStream.h>


Public Member Functions | |
| PacketEncoder ()=default | |
| PacketEncoder (Print &out) | |
| void | setOutput (Print &out) |
| size_t | write (uint8_t ch) override |
| size_t | write (const uint8_t *data, size_t len) override |
| void | flush () override |
| Sends the buffered data as packet. | |
| int | pending () const |
| Number of buffered bytes which were not sent yet. | |
Protected Member Functions | |
| void | writePacket () |
| void | writeEscaped (uint8_t b) |
Protected Attributes | |
| Print * | p_out = nullptr |
| uint8_t | payload [MAX_PAYLOAD] |
| int | payload_len = 0 |
| RS::ReedSolomon< MSG_LEN, ECC_BYTES > | rs |
Static Protected Attributes | |
| static constexpr int | MSG_LEN = MAX_PAYLOAD + PacketFormat::CRC_BYTES |
Splits the written data into packets with a CRC-16 and Reed-Solomon forward error correction, which are framed with HDLC-style flags (0x7E) and byte stuffing, and writes them to the output (e.g. a ModemStream).
A packet is sent when MAX_PAYLOAD bytes were written or when you call flush(). The packet is transmitted as payload + CRC + ECC_BYTES parity bytes: shorter packets use a shortened Reed-Solomon code, so they don't need any padding. The receiver (PacketDecoder) corrects up to ECC_BYTES / 2 wrong bytes per packet.
| MAX_PAYLOAD | maximum number of data bytes per packet |
| ECC_BYTES | number of Reed-Solomon parity bytes per packet |
|
default |
|
inline |
|
inlineoverride |
Sends the buffered data as packet.
|
inline |
Number of buffered bytes which were not sent yet.
|
inline |
|
inlineoverride |
|
inlineoverride |
|
inlineprotected |
|
inlineprotected |
|
staticconstexprprotected |
|
protected |
|
protected |
|
protected |
|
protected |