Arduino KVComm
master
Key-Value pair communication library for Arduino
|
Class that implements SLIP, a simple packet framing protocol, and that uses cyclic redundancy checks (CRCs) on transmitted and received packets. More...
#include <SLIPStream/SLIPStream.hpp>
Public Types | |
using | StreamSender = SLIPStream::StreamSender |
using | checksum_t = typename SLIPParserCRC< CRC >::checksum_t |
The integer type of the checksum. More... | |
Public Member Functions | |
SLIPStreamCRC (Stream &stream, CRC &&senderCRC, const SLIPParser &parser, CRC &&parserCRC) | |
size_t | writePacket (const uint8_t *data, size_t len) |
Sends a packet. More... | |
size_t | beginPacket () |
Start a packet. More... | |
size_t | write (const uint8_t *data, size_t len) |
Write some data as the body of a packet. More... | |
size_t | endPacket () |
Finish the packet. More... | |
size_t | readPacket () |
Receives a packet into the read buffer. More... | |
bool | wasTruncated () const |
Check if the previous packet was truncated. More... | |
size_t | numTruncated () const |
Get the number of bytes that were truncated due to the previous packet being too large for the buffer. More... | |
checksum_t | checksum () const |
Get the checksum of the previous packet. More... | |
Private Attributes | |
Stream * | stream |
SLIPSenderCRC< StreamSender, CRC > | sender |
SLIPParserCRC< CRC > | parser |
Class that implements SLIP, a simple packet framing protocol, and that uses cyclic redundancy checks (CRCs) on transmitted and received packets.
Definition at line 84 of file SLIPStream.hpp.
using StreamSender = SLIPStream::StreamSender |
Definition at line 86 of file SLIPStream.hpp.
using checksum_t = typename SLIPParserCRC<CRC>::checksum_t |
The integer type of the checksum.
Definition at line 122 of file SLIPStream.hpp.
|
inline |
Definition at line 88 of file SLIPStream.hpp.
size_t writePacket | ( | const uint8_t * | data, |
size_t | len | ||
) |
Sends a packet.
data | A pointer to the start of the data. |
len | The length of the data. |
len
, because of the delimiters, checksums and stuffing bytes. Definition at line 6 of file SLIPStream.ipp.
size_t beginPacket | ( | ) |
Start a packet.
Sends a SLIP END character to flush the buffer of the receiver.
Definition at line 20 of file SLIPStream.ipp.
size_t write | ( | const uint8_t * | data, |
size_t | len | ||
) |
Write some data as the body of a packet.
The data is encoded by SLIP before sending, so arbitrary binary data can be sent.
data | A pointer to the data to send. |
len | The number of bytes to send. |
Definition at line 15 of file SLIPStream.ipp.
size_t endPacket | ( | ) |
Finish the packet.
Encodes and sends the checksum of all data sent using the write function, followed by a SLIP END character.
Definition at line 25 of file SLIPStream.ipp.
size_t readPacket | ( | ) |
Receives a packet into the read buffer.
If more than len bytes are received, the packet will be truncated.
Definition at line 30 of file SLIPStream.ipp.
|
inline |
Check if the previous packet was truncated.
true | The previous packet didn't fit the buffer. The size returned by SLIPParser::parse was smaller than the actual size of the packet. |
false | The buffer was large enough to store the previous packet. |
Definition at line 117 of file SLIPStream.hpp.
|
inline |
Get the number of bytes that were truncated due to the previous packet being too large for the buffer.
Definition at line 119 of file SLIPStream.hpp.
|
inline |
Get the checksum of the previous packet.
A checksum of zero indicates that the packet was received correctly.
Definition at line 125 of file SLIPStream.hpp.
|
private |
Definition at line 128 of file SLIPStream.hpp.
|
private |
Definition at line 129 of file SLIPStream.hpp.
|
private |
Definition at line 130 of file SLIPStream.hpp.