JM9 XRCU Board 0.2.0a
Libraries API Reference
Loading...
Searching...
No Matches
Serial_unpacker.h
Go to the documentation of this file.
1
8
9#ifndef SERIAL_UNPACKER_H
10#define SERIAL_UNPACKER_H
11
12#include <Arduino.h>
13#include <HardwareSerial.h>
14
21 private:
25 HardwareSerial &uart;
26
30 const uint8_t start_byte;
31
35 enum state_t {
40 idle,
41
46 start_byte_received,
47
52 len_byte_received,
53
58 data_bytes_rx_done
59 };
60
64 state_t status;
65
69 uint8_t *buf_arr;
70
74 uint8_t buf_arr_idx;
75
79 uint8_t buf_arr_len;
80
84 uint8_t my_xor_byte;
85
93 void allocate_buffer (const uint8_t len);
94
99 void free_buffer ();
100
105 void put_byte_to_buffer (const uint8_t data);
106
115 bool is_start_byte_received ();
116
117 public:
124 Serial_unpacker (HardwareSerial &init_uart, const uint8_t init_start_byte);
125
131
136 bool update ();
137
148 const uint8_t *get_packet_ptr ();
149
158 uint8_t get_packet_len ();
159
166};
167
168
169#endif // #ifndef SERIAL_UNPACKER_H
Definition HardwareSerial.h:99
HardwareSerial & get_uart()
Gets the UART object to read packets from.
~Serial_unpacker()
Destroys this unpacker.
bool update()
Checks if a new packet is received.
Serial_unpacker(HardwareSerial &init_uart, const uint8_t init_start_byte)
Creates an unpacker.
uint8_t get_packet_len()
Gets the length of the received data.
const uint8_t * get_packet_ptr()
Gets the pointer to the received data.