JM9 UART packet unpacker. More...
#include <Serial_unpacker.h>
Public Member Functions | |
| Serial_unpacker (HardwareSerial &init_uart, const uint8_t init_start_byte) | |
| Creates an unpacker. | |
| ~Serial_unpacker () | |
| Destroys this unpacker. | |
| bool | update () |
| Checks if a new packet is received. | |
| const uint8_t * | get_packet_ptr () |
| Gets the pointer to the received data. | |
| uint8_t | get_packet_len () |
| Gets the length of the received data. | |
| HardwareSerial & | get_uart () |
| Gets the UART object to read packets from. | |
JM9 UART packet unpacker.
| Serial_unpacker::Serial_unpacker | ( | HardwareSerial & | init_uart, |
| const uint8_t | init_start_byte ) |
Creates an unpacker.
| init_uart | the UART object to read packets from |
| init_start_byte | the start byte of each packet |
| Serial_unpacker::~Serial_unpacker | ( | ) |
Destroys this unpacker.
Releases the used memory.
| uint8_t Serial_unpacker::get_packet_len | ( | ) |
Gets the length of the received data.
Only call this method after update() returns true.
To be used with get_packet_ptr().
| const uint8_t * Serial_unpacker::get_packet_ptr | ( | ) |
Gets the pointer to the received data.
The byte array pointed by this pointer contains data bytes only.
Only call this method after update() returns true,
otherwise the packet is incomplete and unusable.
To be used with get_packet_len().
| HardwareSerial & Serial_unpacker::get_uart | ( | ) |
Gets the UART object to read packets from.
| bool Serial_unpacker::update | ( | ) |
Checks if a new packet is received.
true if a new packet is completely received, checksumed and accepted, false otherwise