![]() |
WarpTwin
Documentation for WarpTwin models and classes.
|
Header for generic telemetry packet struct generation and serialization. More...
#include <string.h>#include "communication/spacepacketutils.hpp"#include "utils/stringutils.hpp"#include "configuration.h"Go to the source code of this file.
Classes | |
| struct | cmd_tlm_base |
| Base struct in definition of command and telemetry packets. More... | |
Macros | |
| #define | CMD_APID_MIN_ALLOWABLE 0x1 |
| #define | CMD_APID_MAX_ALLOWABLE 0xB |
| #define | TLM_APID_MIN_ALLOWABLE 0xC |
| #define | TLM_APID_MAX_ALLOWABLE 0xF |
| #define | CMD_TLM_COMMON(NAME, APID, SIZE, ...) |
| #define | STRIP_PARENS(X) |
| #define | STRIP_PARENS_IMPL(...) |
| #define | DECLARE_FIELD(pair) |
| #define | DECLARE_FIELD_(type, name) |
| #define | PACKETIZE_FIELD(pair) |
| #define | PACKETIZE_FIELD_(type, name) |
| #define | DEPACKETIZE_FIELD(pair) |
| #define | DEPACKETIZE_FIELD_(type, name) |
| #define | STR_FIELD(pair) |
| #define | STR_FIELD_(type, name) |
| #define | EXPAND_VAL(x) |
| #define | FOR_EACH_1(M, x) |
| #define | FOR_EACH_2(M, x, ...) |
| #define | FOR_EACH_3(M, x, ...) |
| #define | FOR_EACH_4(M, x, ...) |
| #define | FOR_EACH_5(M, x, ...) |
| #define | FOR_EACH_6(M, x, ...) |
| #define | FOR_EACH_7(M, x, ...) |
| #define | FOR_EACH_8(M, x, ...) |
| #define | FOR_EACH_9(M, x, ...) |
| #define | FOR_EACH_10(M, x, ...) |
| #define | FOR_EACH_11(M, x, ...) |
| #define | FOR_EACH_12(M, x, ...) |
| #define | FOR_EACH_13(M, x, ...) |
| #define | FOR_EACH_14(M, x, ...) |
| #define | FOR_EACH_15(M, x, ...) |
| #define | FOR_EACH_16(M, x, ...) |
| #define | FOR_EACH_17(M, x, ...) |
| #define | FOR_EACH_18(M, x, ...) |
| #define | FOR_EACH_19(M, x, ...) |
| #define | FOR_EACH_20(M, x, ...) |
| #define | FOR_EACH_21(M, x, ...) |
| #define | FOR_EACH_22(M, x, ...) |
| #define | FOR_EACH_23(M, x, ...) |
| #define | FOR_EACH_24(M, x, ...) |
| #define | FOR_EACH_25(M, x, ...) |
| #define | FOR_EACH_26(M, x, ...) |
| #define | FOR_EACH_27(M, x, ...) |
| #define | FOR_EACH_28(M, x, ...) |
| #define | FOR_EACH_29(M, x, ...) |
| #define | FOR_EACH_30(M, x, ...) |
| #define | FOR_EACH_31(M, x, ...) |
| #define | FOR_EACH_32(M, x, ...) |
| #define | FOR_EACH_33(M, x, ...) |
| #define | FOR_EACH_34(M, x, ...) |
| #define | FOR_EACH_35(M, x, ...) |
| #define | FOR_EACH_36(M, x, ...) |
| #define | FOR_EACH_37(M, x, ...) |
| #define | FOR_EACH_38(M, x, ...) |
| #define | FOR_EACH_39(M, x, ...) |
| #define | FOR_EACH_40(M, x, ...) |
| #define | FOR_EACH_41(M, x, ...) |
| #define | FOR_EACH_42(M, x, ...) |
| #define | FOR_EACH_43(M, x, ...) |
| #define | FOR_EACH_44(M, x, ...) |
| #define | FOR_EACH_45(M, x, ...) |
| #define | FOR_EACH_46(M, x, ...) |
| #define | FOR_EACH_47(M, x, ...) |
| #define | FOR_EACH_48(M, x, ...) |
| #define | FOR_EACH_49(M, x, ...) |
| #define | FOR_EACH_50(M, x, ...) |
| #define | GET_FOR_EACH_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, NAME, ...) |
| #define | FOR_EACH(M, ...) |
| #define | TELEMETRY(NAME, APID, SIZE, ...) |
Header for generic telemetry packet struct generation and serialization.
This file defines a macro-based system to simplify the definition and serialization of telemetry packets in C++. It provides an easy and consistent way to define packet structures, serialize them into byte streams (packetize), and reconstruct them (depacketize) while respecting endianness in a robust manner.
The TELEMETRY(NAME, APID, SIZE, ...) macro expands to a struct named NAME with fields defined by the user. It also adds these methods:
The packetize/depacketize methods serialize and deserialize the fields into/from a binary format. Endianness is handled automatically depending on the IS_BIG_ENDIAN macro.
The apid function returns the apid of the packet
C++ does not support variadic field declaration or reflection natively. This macro-based approach allows you to declare telemetry structures with strong typing and automatic serialization logic without writing repetitive boilerplate code.
Endianness is managed at runtime by checking the IS_BIG_ENDIAN macro:
All multi-byte fields (e.g., uint16, float, double) are endianness-aware.
| #define CMD_APID_MAX_ALLOWABLE 0xB |
| #define CMD_APID_MIN_ALLOWABLE 0x1 |
| #define CMD_TLM_COMMON | ( | NAME, | |
| APID, | |||
| SIZE, | |||
| ... ) |
| #define DECLARE_FIELD | ( | pair | ) |
| #define DECLARE_FIELD_ | ( | type, | |
| name ) |
| #define DEPACKETIZE_FIELD | ( | pair | ) |
| #define DEPACKETIZE_FIELD_ | ( | type, | |
| name ) |
| #define EXPAND_VAL | ( | x | ) |
| #define FOR_EACH | ( | M, | |
| ... ) |
| #define FOR_EACH_1 | ( | M, | |
| x ) |
| #define FOR_EACH_10 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_11 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_12 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_13 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_14 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_15 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_16 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_17 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_18 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_19 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_2 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_20 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_21 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_22 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_23 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_24 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_25 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_26 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_27 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_28 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_29 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_3 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_30 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_31 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_32 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_33 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_34 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_35 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_36 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_37 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_38 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_39 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_4 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_40 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_41 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_42 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_43 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_44 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_45 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_46 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_47 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_48 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_49 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_5 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_50 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_6 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_7 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_8 | ( | M, | |
| x, | |||
| ... ) |
| #define FOR_EACH_9 | ( | M, | |
| x, | |||
| ... ) |
| #define GET_FOR_EACH_MACRO | ( | _1, | |
| _2, | |||
| _3, | |||
| _4, | |||
| _5, | |||
| _6, | |||
| _7, | |||
| _8, | |||
| _9, | |||
| _10, | |||
| _11, | |||
| _12, | |||
| _13, | |||
| _14, | |||
| _15, | |||
| _16, | |||
| _17, | |||
| _18, | |||
| _19, | |||
| _20, | |||
| _21, | |||
| _22, | |||
| _23, | |||
| _24, | |||
| _25, | |||
| _26, | |||
| _27, | |||
| _28, | |||
| _29, | |||
| _30, | |||
| _31, | |||
| _32, | |||
| _33, | |||
| _34, | |||
| _35, | |||
| _36, | |||
| _37, | |||
| _38, | |||
| _39, | |||
| _40, | |||
| _41, | |||
| _42, | |||
| _43, | |||
| _44, | |||
| _45, | |||
| _46, | |||
| _47, | |||
| _48, | |||
| _49, | |||
| _50, | |||
| NAME, | |||
| ... ) |
| #define PACKETIZE_FIELD | ( | pair | ) |
| #define PACKETIZE_FIELD_ | ( | type, | |
| name ) |
| #define STR_FIELD | ( | pair | ) |
| #define STR_FIELD_ | ( | type, | |
| name ) |
| #define STRIP_PARENS | ( | X | ) |
| #define STRIP_PARENS_IMPL | ( | ... | ) |
| #define TELEMETRY | ( | NAME, | |
| APID, | |||
| SIZE, | |||
| ... ) |
| #define TLM_APID_MAX_ALLOWABLE 0xF |
| #define TLM_APID_MIN_ALLOWABLE 0xC |