Class for parsing SLIP packets.
More...
#include <SLIPStream/SLIPParser.hpp>
Class for parsing SLIP packets.
Definition at line 17 of file SLIPParser.hpp.
◆ SLIPParser() [1/4]
Constructor.
- Parameters
-
buffer | The byte buffer to store the parsed packets. |
Definition at line 26 of file SLIPParser.hpp.
◆ SLIPParser() [2/4]
Default constructor for a parser without a buffer.
Definition at line 31 of file SLIPParser.hpp.
◆ SLIPParser() [3/4]
Constructor for a parser without a buffer.
Definition at line 36 of file SLIPParser.hpp.
◆ SLIPParser() [4/4]
SLIPParser |
( |
uint8_t * |
buffer, |
|
|
size_t |
bufferSize |
|
) |
| |
|
inline |
Constructor.
- Parameters
-
buffer | The byte buffer to store the parsed packets. |
bufferSize | The size of the buffer. |
Definition at line 46 of file SLIPParser.hpp.
◆ parse() [1/2]
size_t parse |
( |
uint8_t |
c, |
|
|
Callback |
callback |
|
) |
| |
Parse the given byte, and call the callback for each data byte.
- Template Parameters
-
Callback | The type of callback function. Should be a callable object that takes a data byte and the index of that byte in the packet:
void callback(uint8_t databyte, size_t index) |
- Parameters
-
c | The byte to parse. |
callback | The callback function to call for each data byte. |
- Return values
-
0 | The packet is not finished yet. |
>0 | The packet was received in its entirety, and the return value is the size of the packet in the buffer.
If the packet is not larger than the buffer, this will be the same as the size of the packet. If the packet was larger than the buffer, the return value will be the size of the buffer, and wasTruncated will return true. |
Definition at line 4 of file SLIPParser.ipp.
◆ parse() [2/2]
size_t parse |
( |
uint8_t |
c | ) |
|
|
inline |
Parse the given byte without using a callback function.
- Parameters
-
- Return values
-
0 | The packet is not finished yet. |
>0 | The packet was received in its entirety, and the return value is the size of the packet in the buffer.
If the packet is not larger than the buffer, this will be the same as the size of the packet. If the packet was larger than the buffer, the return value will be the size of the buffer, and wasTruncated will return true. |
Definition at line 91 of file SLIPParser.hpp.
◆ wasTruncated()
bool wasTruncated |
( |
| ) |
const |
|
inline |
Check if the previous packet was truncated.
- Return values
-
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 106 of file SLIPParser.hpp.
◆ numTruncated()
size_t numTruncated |
( |
| ) |
const |
|
inline |
Get the number of bytes that were truncated due to the previous packet being too large for the buffer.
Definition at line 112 of file SLIPParser.hpp.
◆ reset()
◆ buffer
uint8_t* buffer = nullptr |
|
private |
◆ write
◆ bufferSize
◆ truncated
◆ escape
The documentation for this class was generated from the following files: