SBB Host
Host communication with the self balancing bike.
Loading...
Searching...
No Matches
Packet.h
Go to the documentation of this file.
1
2#ifndef PACKET_H
3#define PACKET_H
4
5#include "config.h"
6#include <string>
7
16template<typename T, size_t Size>
17class Packet {
18public:
19 T value[Size] = { 0 };
20
21 unsigned int id[Size];
22
23 const unsigned int size = Size;
24
25 const unsigned int bytes = Size * sizeof(T);
26
30 Packet() { for (int i = 0; i < size; i++) id[i] = i; };
31
37 T getValue(unsigned int i) { return value[i]; };
38};
39
40#endif
A templated-class for managing data packet.
Definition: Packet.h:17
T getValue(unsigned int i)
Get a value of the packet.
Definition: Packet.h:37
const unsigned int bytes
Number of bytes of the packet according to sizeof(T) and Size.
Definition: Packet.h:25
T value[Size]
Buffer with base type T and size Size.
Definition: Packet.h:19
Packet()
Constructor.
Definition: Packet.h:30
const unsigned int size
Number of element of the packet.
Definition: Packet.h:23
A configuration file for the source code.