|
void | init (uint8_t buflen) |
| Allocate and reset buffer. More...
|
|
template<typename T > |
void | write (const T &value) |
| Write any basic data type to the buffer at the current position and increment the position pointer according to the type's size. More...
|
|
template<typename T > |
void | read (T &value) |
| Read any basic data type from the buffer from the current position and increment the position pointer according to the type's size. More...
|
|
void | reset () |
| Reset the position pointer to the start of the buffer (which is[1] as [0] is the CRC8 chcksum) without changing the buffer contents. Usually, this will be called before writing new data and before reading it. More...
|
|
void | setCRC8 () |
| Calculate CRC8 checksum for the currently used buffer ([1]...[idx-1]) and store it in the first byte [0]. More...
|
|
bool | checkCRC8 () |
| Check for correct CRC8 checksum. First byte [0] holds the checksum, rest of the currently used buffer is checked. More...
|
|
|
uint8_t * | buffer |
| The allocated buffer. More...
|
|
uint8_t | idx |
| The position pointer. Remember, [0] holds the CRC8 checksum, so for an empty buffer, idx is 1. More...
|
|
uint8_t | maxLen |
| Maximum length of buffer in bytes. Read and write operations use this to check for sufficient space (no error handling, though). More...
|
|
◆ checkCRC8()
bool SimpleBuffer::checkCRC8 |
( |
| ) |
|
Check for correct CRC8 checksum. First byte [0] holds the checksum, rest of the currently used buffer is checked.
- Returns
- true if CRC8 matches the rest of the used buffer.
◆ init()
void SimpleBuffer::init |
( |
uint8_t |
buflen | ) |
|
Allocate and reset buffer.
- Parameters
-
buflen | Maximum length of buffer in bytes. Take into account that the first byte [0] is used as CRC8 checksum. |
◆ read()
template<typename T >
void SimpleBuffer::read |
( |
T & |
value | ) |
|
Read any basic data type from the buffer from the current position and increment the position pointer according to the type's size.
- Parameters
-
value | Variable to read to. Amount of data read depends on size of this type. As reading could fail, you best initialize the variable with some default value. |
◆ reset()
void SimpleBuffer::reset |
( |
| ) |
|
Reset the position pointer to the start of the buffer (which is[1] as [0] is the CRC8 chcksum) without changing the buffer contents. Usually, this will be called before writing new data and before reading it.
◆ setCRC8()
void SimpleBuffer::setCRC8 |
( |
| ) |
|
Calculate CRC8 checksum for the currently used buffer ([1]...[idx-1]) and store it in the first byte [0].
◆ write()
template<typename T >
void SimpleBuffer::write |
( |
const T & |
value | ) |
|
Write any basic data type to the buffer at the current position and increment the position pointer according to the type's size.
- Parameters
-
◆ buffer
uint8_t* SimpleBuffer::buffer |
◆ idx
uint8_t SimpleBuffer::idx |
The position pointer. Remember, [0] holds the CRC8 checksum, so for an empty buffer, idx is 1.
◆ maxLen
uint8_t SimpleBuffer::maxLen |
Maximum length of buffer in bytes. Read and write operations use this to check for sufficient space (no error handling, though).
The documentation for this class was generated from the following files: