|
| | PacketStream () |
| | PacketStream (Stream &io) |
| | send and receive
|
| | PacketStream (Print &out) |
| | send only
|
| void | setStream (Stream &io) |
| | Defines the stream for sending and receiving.
|
| void | setOutput (Print &out) |
| | Defines the output (send only).
|
| bool | begin () |
| | Resets the receive state and the statistics.
|
| 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 and flushes the underlying stream.
|
| int | available () override |
| int | read () override |
| int | peek () override |
| size_t | readBytes (uint8_t *data, size_t len) |
| | Reads the available data (does not wait for more data).
|
| size_t | readBytes (char *data, size_t len) |
| void | update () |
| | Reads the available data from the underlying stream.
|
| const PacketStatistics & | statistics () const |
| | Statistics of the received packets.
|
template<uint8_t MAX_PAYLOAD = 64, uint8_t ECC_BYTES = 16>
class tinymodem::PacketStream< MAX_PAYLOAD, ECC_BYTES >
Reliable data transfer over any Stream (e.g. a ModemStream, an MFSKStream or a Serial): the written data is sent in packets with CRC-16 and Reed-Solomon forward error correction, and only correct data can be read. Corrupted packets which can't be corrected are dropped.
A packet is sent when MAX_PAYLOAD bytes were written or when you call flush(), which also calls flush() of the underlying stream (which ends the transmission of a modem). Both sides must use the same template parameters.
- Template Parameters
-
| MAX_PAYLOAD | maximum number of data bytes per packet |
| ECC_BYTES | number of Reed-Solomon parity bytes: up to ECC_BYTES / 2 wrong bytes per packet are corrected |
- Copyright
- GPLv3