Arduino KVComm
master
Key-Value pair communication library for Arduino
|
Class that implements SLIP, a simple packet framing protocol. More...
#include <SLIPStream/SLIPStream.hpp>
Classes | |
struct | StreamSender |
Functor that sends bytes over an Arduino Stream. More... | |
Public Member Functions | |
SLIPStream (Stream &stream, const SLIPParser &parser) | |
SLIPStream (Stream &stream) | |
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... | |
Private Attributes | |
Stream * | stream |
SLIPParser | parser |
Class that implements SLIP, a simple packet framing protocol.
Definition at line 15 of file SLIPStream.hpp.
|
inline |
Definition at line 26 of file SLIPStream.hpp.
|
inline |
Definition at line 28 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 and stuffing bytes. Definition at line 5 of file SLIPStream.cpp.
size_t beginPacket | ( | ) |
Start a packet.
Sends a SLIP END character to flush the buffer of the receiver.
Definition at line 17 of file SLIPStream.cpp.
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 13 of file SLIPStream.cpp.
size_t endPacket | ( | ) |
Finish the packet.
Sends a SLIP END character.
Definition at line 21 of file SLIPStream.cpp.
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 25 of file SLIPStream.cpp.
|
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 60 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 63 of file SLIPStream.hpp.
|
private |
Definition at line 66 of file SLIPStream.hpp.
|
private |
Definition at line 67 of file SLIPStream.hpp.