Fixposition SDK 0.0.0-heads/main-0-g90a51ff
Collection of c++ libraries and apps for use with Fixposition products
Loading...
Searching...
No Matches
fpb.hpp
Go to the documentation of this file.
1/**
2 * \verbatim
3 * ___ ___
4 * \ \ / /
5 * \ \/ / Copyright (c) Fixposition AG (www.fixposition.com) and contributors
6 * / /\ \ License: see the LICENSE file
7 * /__/ \__\
8 *
9 * Based on work by flipflip (https://github.com/phkehl)
10 * \endverbatim
11 *
12 * @file
13 * @brief Fixposition SDK: Parser FP_B routines and types
14 *
15 * @page FPSDK_COMMON_PARSER_FPB Parser FP_B routines and types
16 *
17 * **API**: fpsdk_common/parser/fpb.hpp and fpsdk::common::parser::fpb
18 *
19 * @fp_msgspec_begin{FP_B-Protocol}
20 *
21 * **Framing:**
22 *
23 * The structure of a FP_B message (frame) is:
24 *
25 * | Offs | Size | Type | Content |
26 * |-----:|:----:|----------|-----------------|
27 * | 0 | 1 | uint8_t | Sync 1: `f` = 102 = 0x66 = 0b0110'0110 |
28 * | 1 | 1 | uint8_t | Sync 1: `!` = 33 = 0x21 = 0b0010'0001 |
29 * | 2 | 2 | uint16_t | Message ID (`message_id`), 1...65534 |
30 * | 4 | 2 | uint16_t | Payload size (`payload_size`) |
31 * | 6 | 2 | uint16_t | Monotonic time [ms] (`message_time`), overflows/wraps around at ~65s |
32 * | 8… | … | … | Payload |
33 * | 8 + `payload_size` | 4 | uint32_t | Checksum |
34 *
35 * The checksum is a 32 bit cyclic redundancy check (CRC) with the polynomial 0x32c00699. See Koopman's *CRC polynomial
36 * zoo* at <http://users.ece.cmu.edu/~koopman/crc/crc32.html> for details.
37 *
38 * **Payload:**
39 *
40 * The payload encoding can be:
41 *
42 * - Fixed structure (for example, FP_B-MEASUREMENTS) using little-endian signed and unsigned integers of 8, 16, 32 or
43 * 64 bits, as well as IEEE 754 single (32 bits) or double (64 bits) precision.
44 * - Serialised data of a t.b.d. interface description language (e.g. Protobuf, Capn' Proto, Flatbuffers, ....)
45 *
46 * **Example:**
47 *
48 * A short FP_B frame with the bytes in order they appear on the wire:
49 *
50 * First byte Last byte
51 * | |
52 * 66 21 34 12 04 00 21 43 01 02 03 04 61 c4 c5 9c
53 * ^^ ^^ ^^^^^ ^^^^^ ^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^
54 * | | | | | | |
55 * | | | | | | CRC (= 0x9cc5c461)
56 * | | | | | Payload (= [ 0x01, 0x02, 0x03, 0x04 ])
57 * | | | | Message time (= 0x4321 = 17185 = 17.185s)
58 * | | | Payload size = (=x0004 = 4)
59 * | | Message ID (= 0x1234)
60 * | Sync 2
61 * Sync 1
62 *
63 * @fp_msgspec_end
64 *
65 * @fp_msgspec_begin{FP_B-Payload-Rules}
66 *
67 * **Fixed payload definition:**
68 *
69 * A short and incomplete guideline:
70 *
71 * - All fields must be aligned
72 * - Padding must be explicitly added as reserved fields: e.g. `uint8_t reserved[3] //!< Reserved for future use. Set to
73 * 0.`
74 * - Fields can only be basic types (no enums!)
75 * - Decoding must be doable with a single pass. I.e. repeated parts must follow static parts.
76 * - Repeated parts of the payload mus have a `num_foo` field in the static part.
77 * - For enums the value 0 must always be "unspecified" or "unknown"
78 * - Don't use bitfields. Waste some space (e.g. `uint8_t` for a bool, instead of a bit in a bitfield)
79 * - Values that may or may not be valid must be accompanied by a `foo_valid` flag field.
80 * - No strings! Not ever. With some exceptions, probably... :-)
81 * - ...and more...
82 *
83 * @fp_msgspec_end
84 *
85 */
86#ifndef __FPSDK_COMMON_PARSER_FPB_HPP__
87#define __FPSDK_COMMON_PARSER_FPB_HPP__
88
89/* LIBC/STL */
90#include <cstdint>
91#include <cstring>
92#include <vector>
93
94/* EXTERNAL */
95
96/* PACKAGE */
97#include "../types.hpp"
98
99namespace fpsdk {
100namespace common {
101namespace parser {
102/**
103 * @brief Parser FP_B routines and types
104 */
105namespace fpb {
106/* ****************************************************************************************************************** */
107
108static constexpr std::size_t FP_B_FRAME_SIZE = 12; //!< Size (in bytes) of FP_B frame
109static constexpr std::size_t FP_B_HEAD_SIZE = 8; //!< Size of FP_B frame header
110static constexpr uint8_t FP_B_SYNC_1 = 0x66; //!< FP_B frame sync char 1 ('f', 102, 0b0110'0110)
111static constexpr uint8_t FP_B_SYNC_2 = 0x21; //!< FP_B frame sync char 2 ('!', 33, 0b0010'0001)
112
113/**
114 * @brief Get message ID
115 *
116 * @param[in] msg Pointer to the start of the message
117 *
118 * @note No check on the data provided is done. The caller must ensure that the data is a valid FP_B message.
119 *
120 * @returns message ID
121 */
122constexpr uint16_t FpbMsgId(const uint8_t* msg)
123{
124 return (((uint16_t)((uint8_t*)msg)[3] << 8) | (uint16_t)((uint8_t*)msg)[2]);
125}
126
127/**
128 * @brief Get message time
129 *
130 * @param[in] msg Pointer to the start of the message
131 *
132 * @note No check on the data provided is done. The caller must ensure that the data is a valid FP_B message.
133 *
134 * @returns message time
135 */
136constexpr uint16_t FpbMsgTime(const uint8_t* msg)
137{
138 return (((uint16_t)((uint8_t*)msg)[7] << 8) | (uint16_t)((uint8_t*)msg)[6]);
139}
140
141/**
142 * @brief Get FP_B message name
143 *
144 * Generates a name (string) in the form "FP_B-NAME", where NAME is a suitable stringifications of the message ID if
145 * known (for example, "FP_B-SYSTEMSTATUS", respectively "%05u" formatted message ID if unknown (for example,
146 * "FP_B-MSG01234").
147 *
148 * @param[out] name String to write the name to
149 * @param[in] size Size of \c name (incl. nul termination)
150 * @param[in] msg Pointer to the FP_B message
151 * @param[in] msg_size Size of the \c msg
152 *
153 * @note No check on the data provided is done. The caller must ensure that the data is a valid FP_B message.
154 *
155 * @returns true if message name was generated, false if \c name buffer was too small
156 */
157bool FpbGetMessageName(char* name, const std::size_t size, const uint8_t* msg, const std::size_t msg_size);
158
159/**
160 * @brief Get FP_B message info
161 *
162 * This stringifies the content of some FP_B messages, for debugging.
163 *
164 * @param[out] info String to write the info to
165 * @param[in] size Size of \c name (incl. nul termination)
166 * @param[in] msg Pointer to the FP_B message
167 * @param[in] msg_size Size of the \c msg
168 *
169 * @note No check on the data provided is done. The caller must ensure that the data is a valid FP_B message.
170 *
171 * @returns true if message info was generated (even if info is empty), false if \c name buffer was too small
172 */
173bool FpbGetMessageInfo(char* info, const std::size_t size, const uint8_t* msg, const std::size_t msg_size);
174
175/**
176 * @brief Make a FP_B message
177 *
178 * @param[out] msg The message frame
179 * @param[in] msg_id Message ID
180 * @param[in] msg_time Message time [ms]
181 * @param[in] payload The message payload (up to MAX_FP_B_SIZE - FP_B_FRAME_SIZE bytes, can be empty)
182 *
183 * @returns true if the message was successfully constructed (\c msg now contains the message),
184 * false if failed contructing the message (payload too large)
185 */
187 std::vector<uint8_t>& msg, const uint16_t msg_id, const uint16_t msg_time, const std::vector<uint8_t>& payload);
188
189/**
190 * @brief Make a FP_B message
191 *
192 * @param[out] msg The message frame
193 * @param[in] msg_id Message ID
194 * @param[in] msg_time Message time [ms]
195 * @param[in] payload The message payload (up to MAX_FP_B_SIZE - FP_B_FRAME_SIZE bytes, can be NULL)
196 * @param[in] payload_size The message payload (up to MAX_FP_B_SIZE - FP_B_FRAME_SIZE, can be 0, even if payload is
197 * not NULL)
198 *
199 * @returns true if the message was successfully constructed (\c msg now contains the message),
200 * false if failed contructing the message (payload too large, bad arguments)
201 */
202bool FpbMakeMessage(std::vector<uint8_t>& msg, const uint16_t msg_id, const uint16_t msg_time, const uint8_t* payload,
203 const std::size_t payload_size);
204
205/**
206 * @name FP_B messages (names and IDs)
207 *
208 * - 1- 999: unused
209 * - 1000-1999: messages with payload binary serialised data
210 * - 1101-1199: Fusion
211 * - 1201-1299: GNSS
212 * - 1301-1399: System
213 * - 1401-1499: Configuration
214 * - 1501-1599: Sensor data
215 * - 1601-1699: Reserved
216 * - 1701-1699: Reserved
217 * - 1801-1699: Reserved
218 * - 1901-1999: Reserved
219 * - 2000-3000: messages with static payload
220 * - 2001-2099: Input data messages (measurements, ...)
221 * - 2101-2199: Input command message
222 * - 2201-2299: Input config message
223 * - 2301-2399: System
224 * - 2401-2499: Reserved
225 * - 2501-2599: Reserved
226 * - 2601-2699: Reserved
227 * - 2701-2799: Reserved
228 * - 2801-2899: Reserved
229 * - 2901-2999: Reserved
230 * - 3000-65000: Reserved
231 * - 65001-...: Test messages
232 * @{
233 */
234// clang-format off
235// @fp_codegen_begin{FPSDK_COMMON_PARSER_FPB_MESSAGES}
236static constexpr uint16_t FP_B_GNSSSTATUS_MSGID = 1201; //!< FP_B-GNSSSTATUS message ID
237static constexpr const char* FP_B_GNSSSTATUS_STRID = "FP_B-GNSSSTATUS"; //!< FP_B-GNSSSTATUS message name
238static constexpr uint16_t FP_B_SYSTEMSTATUS_MSGID = 1301; //!< FP_B-SYSTEMSTATUS message ID
239static constexpr const char* FP_B_SYSTEMSTATUS_STRID = "FP_B-SYSTEMSTATUS"; //!< FP_B-SYSTEMSTATUS message name
240static constexpr uint16_t FP_B_MEASUREMENTS_MSGID = 2001; //!< FP_B-MEASUREMENTS message ID
241static constexpr const char* FP_B_MEASUREMENTS_STRID = "FP_B-MEASUREMENTS"; //!< FP_B-MEASUREMENTS message name
242static constexpr uint16_t FP_B_VERSION_MSGID = 2301; //!< FP_B-VERSION message ID
243static constexpr const char* FP_B_VERSION_STRID = "FP_B-VERSION"; //!< FP_B-VERSION message name
244static constexpr uint16_t FP_B_UNITTEST1_MSGID = 65001; //!< FP_B-UNITTEST1 message ID
245static constexpr const char* FP_B_UNITTEST1_STRID = "FP_B-UNITTEST1"; //!< FP_B-UNITTEST1 message name
246static constexpr uint16_t FP_B_UNITTEST2_MSGID = 65002; //!< FP_B-UNITTEST2 message ID
247static constexpr const char* FP_B_UNITTEST2_STRID = "FP_B-UNITTEST2"; //!< FP_B-UNITTEST2 message name
248// @fp_codegen_end{FPSDK_COMMON_PARSER_FPB_MESSAGES}
249// clang-format off
250///@}
251
252// ---------------------------------------------------------------------------------------------------------------------
253// clang-format off
254// Note: the formatting here is optimised for the wiki, not for Doxygen!
255/**
256 * @name FP_B-MEASUREMENTS
257 *
258 * @fp_msgspec_begin{FP_B_MEASUREMENTS}
259 *
260 * **Description:**
261 *
262 * This message is used to input measurements, such as wheelspeeds, to the sensor.
263 *
264 * **Notes:**
265 *
266 * - The supported `meas_type`, `meas_loc` and `timestamp_type` values depend on the sensor software and configuration
267 * used. Refer to the sensor documentation for valid combinations of values for these fields.
268 *
269 * **Payload fields:**
270 *
271 * | # | Offset | Field | Type | Unit | Description |
272 * |----------:|----------:|-------------------|----------------|------|------------------------------------------------------------------------|
273 * | 1 | 0 | `version` | uint8_t | - | Version of the FP_B_MEASUREMENTS message (currently 1) |
274 * | 2 | 1 | `num_meas` | uint8_t | - | Number of measurements present in the body of the message (1…10) |
275 * | 3 | 2 | `reserved0` | uint8_t[6] | - | Reserved for future use. Set to 0. |
276 * | | | | | | *The following fields are repeated `num_meas` times (i = 0…`num_meas`-1):* |
277 * | 4 + i·12 | 8 + i·28 | `meas_x` | int32_t | * | Measurement x axis (for example, [mm/s]) |
278 * | 5 + i·12 | 12 + i·28 | `meas_y` | int32_t | * | Measurement y axis (for example, [mm/s]) |
279 * | 6 + i·12 | 16 + i·28 | `meas_z` | int32_t | * | Measurement z axis (for example, [mm/s]) |
280 * | 7 + i·12 | 20 + i·28 | `meas_x_valid` | uint8_t | - | Validity of `meas_x` (1 = valid data, 0 = invalid data or n/a) |
281 * | 8 + i·12 | 21 + i·28 | `meas_y_valid` | uint8_t | - | Validity of `meas_y` (1 = valid data, 0 = invalid data or n/a) |
282 * | 9 + i·12 | 22 + i·28 | `meas_z_valid` | uint8_t | - | Validity of `meas_z` (1 = valid data, 0 = invalid data or n/a) |
283 * | 10 + i·12 | 23 + i·28 | `meas_type` | uint8_t | - | Type of measurement (see below) |
284 * | 11 + i·12 | 24 + i·28 | `meas_loc` | uint8_t | - | Location of measurement (see below) |
285 * | 12 + i·12 | 25 + i·28 | `reserved1` | uint8_t[4] | - | Reserved for future use. Set to 0. |
286 * | 13 + i·12 | 29 + i·28 | `timestamp_type` | uint8_t | - | Type of timestamp (see below) |
287 * | 14 + i·12 | 30 + i·28 | `gps_wno` | uint16_t | - | GPS week number |
288 * | 15 + i·12 | 32 + i·28 | `gps_tow` | uint32_t | * | GPS time of week [ms] or monotonic time [-] |
289 *
290 * Valid `meas_type` values are:
291 *
292 * | Value | Description |
293 * |:-----:|--------------------------|
294 * | `0` | Unspecified |
295 * | `1` | Velocity (wheel speed) |
296 *
297 * Valid `meas_loc` values are:
298 *
299 * | Value | Description |
300 * |:-----:|---------------------------------------------------|
301 * | `0` | Unspecified |
302 * | `1` | Measurement of a sensor at the rear-center (RC) |
303 * | `2` | Measurement of a sensor at the front-right (FR) |
304 * | `3` | Measurement of a sensor at the front-left (FL) |
305 * | `4` | Measurement of a sensor at the rear-right (RR) |
306 * | `5` | Measurement of a sensor at the rear-left (RL) |
307 *
308 * Valid `timestamp_type` values are:
309 *
310 * | Value | Description |
311 * |:-----:|-------------------------------------------------------------------------|
312 * | `0` | Unspecified |
313 * | `1` | Use time of arrival of the measurement (ignore `gps_wno` and `gps_tow`) |
314 * | `2` | Use monotonic time [any] (stored in the `gps_tow` field) |
315 * | `3` | Use GPS time (stored in `gps_wno` [-] and `gps_tow` [ms] fields) |
316 *
317 * @fp_msgspec_end
318 *
319 * @{
320 */
321// clang-format on
322
323//! FP_B-MEASUREMENTS.version value
324static constexpr uint8_t FP_B_MEASUREMENTS_V1 = 0x01;
325
326//! FP_B-MEASUREMENTS payload: head
328{
329 // clang-format off
330 uint8_t version = FP_B_MEASUREMENTS_V1; //!< Message version (= FP_B_MEASUREMENTS_V1 for this version of the message)
331 uint8_t num_meas = 0; //!< Number of measurements in the body (1..FP_B_MEASUREMENTS_MAX_NUM_MEAS)
332 uint8_t reserved0[6] = { 0 }; //!< Reserved for future use. Set to 0.
333 // clang-format on
334};
335
336//! FP_B-MEASUREMENTS payload head size
337static constexpr std::size_t FP_B_MEASUREMENTS_HEAD_SIZE = 8;
338
339//! FP_B-MEASUREMENTS measurement type
340enum class FpbMeasurementsMeasType : uint8_t // clang-format off
341{
342 UNSPECIFIED = 0, //!< Unspecified
343 VELOCITY = 1, //!< Velocity measuement (wheel speed)
344 // ....
345}; // clang-format on
346
347//! FP_B-MEASUREMENTS measurement location
348enum class FpbMeasurementsMeasLoc : uint8_t // clang-format off
349{
350 UNSPECIFIED = 0, //!< Unspecified
351 RC = 1, //!< Measurement of a sensor at the rear-center (RC)
352 FR = 2, //!< Measurement of a sensor at the front-right (FR)
353 FL = 3, //!< Measurement of a sensor at the front-left (FL)
354 RR = 4, //!< Measurement of a sensor at the rear-right (RR)
355 RL = 5, //!< Measurement of a sensor at the rear-left (RL)
356}; // clang-format on
357
358//! FP_B-MEASUREMENTS timestamp type
359enum class FpbMeasurementsTimestampType : uint8_t // clang-format off
360{
361 UNSPECIFIED = 0, //!< Unspecified
362 TIMEOFARRIVAL = 1, //!< Use time of arrival of the measurement (ignore gps_wno and gps_tow)
363 MONOTONIC = 2, //!< Use monotonic time [any] (stored in the gps_tow field)
364 GPS = 3, //!< Use GPS time (stored in gps_wno [-] and gps_tow [ms] fields)
365}; // clang-format on
366
367//! FP_B-MEASUREMENTS payload: measurement
369{
370 // clang-format off
371 int32_t meas_x = 0 ; //!< Measurement x
372 int32_t meas_y = 0 ; //!< Measurement y
373 int32_t meas_z = 0 ; //!< Measurement z
374 uint8_t meas_x_valid = 0; //!< Validity of measurement x (1 = meas_x contains valid data, 0 = data invalid or n/a)
375 uint8_t meas_y_valid = 0; //!< Validity of measurement y (1 = meas_x contains valid data, 0 = data invalid or n/a)
376 uint8_t meas_z_valid = 0; //!< Validity of measurement z (1 = meas_x contains valid data, 0 = data invalid or n/a)
377 uint8_t meas_type //! See #FpbMeasurementsMeasType
379 uint8_t meas_loc //! See #FpbMeasurementsMeasLoc
381 uint8_t reserved1[4] = { 0 }; //!< Reserved for future use. Set to 0.
382 uint8_t timestamp_type //! See #FpbMeasurementsTimestampType
384 uint16_t gps_wno = 0; //!< GPS week number [-]
385 uint32_t gps_tow = 0; //!< GPS time of week [ms] or monotonic time [-]
386 // clang-format on
387};
388
389//! Size of FpbMeasurementsMeas
390static constexpr std::size_t FP_B_MEASUREMENTS_MEAS_SIZE = 28;
391
392//! Maximum number of measurements
393static constexpr std::size_t FP_B_MEASUREMENTS_MAX_NUM_MEAS = 10; // Keep in sync with the docu above!
394
395static_assert(sizeof(FpbMeasurementsHead) == FP_B_MEASUREMENTS_HEAD_SIZE, "");
396static_assert(sizeof(FpbMeasurementsMeas) == FP_B_MEASUREMENTS_MEAS_SIZE, "");
397
398///@}
399// ---------------------------------------------------------------------------------------------------------------------
400// clang-format off
401/**
402 * @name FP_B-VERSION
403 *
404 * @fp_msgspec_begin{FP_B-VERSION}
405 *
406 * **Description:**
407 *
408 * This message contains version strings.
409 *
410 * **Payload fields:**
411 *
412 * | # | Offset | Field | Type | Unit | Description |
413 * |---:|--------:|-------------------|----------------|------|------------------------------------------------------|
414 * | 1 | 0 | `version` | uint8_t | - | Version of the FP_B_VERSION message (currently 1) |
415 * | 2 | 1 | `reserved0` | uint8_t[7] | - | Reserved for future use. Set to 0. |
416 * | 3 | 8 | `sw_version` | uint8_t[64] | - | Software version (nul-terminated string) |
417 * | 4 | 72 | `hw_name` | uint8_t[32] | - | Hardware name string (nul-terminated string) |
418 * | 5 | 104 | `hw_ver` | uint8_t[32] | - | Hardware version (nul-terminated string) |
419 * | 6 | 136 | `hw_uid` | uint8_t[32] | - | Hardware UID (nul-terminated string) |
420* | 7 | 168 | `reserved1` | uint8_t[64] | - | Reserved for future use. Set to 0. |
421 * @fp_msgspec_end
422 *
423 * @{
424 */
425// clang-format on
426
427//! FP_B-VERSION.version value
428static constexpr uint8_t FP_B_VERSION_V1 = 0x01;
429
430//! FP_B-VERSION payload: head
432{ // clang-format off
433 uint8_t version = FP_B_VERSION_V1; //!< Message version (= FP_B_VERSION_V1 for this version of the message)
434 uint8_t reserved0[7] = { 0 }; //!< Reserved for future use. Set to 0.
435 uint8_t sw_version[64] = { 0 }; //!< Software version (nul-terminated string)
436 uint8_t hw_name[32] = { 0 }; //!< Hardware name string (nul-terminated string)
437 uint8_t hw_ver[32] = { 0 }; //!< Hardware version (nul-terminated string)
438 uint8_t hw_uid[32] = { 0 }; //!< Hardware UID (nul-terminated string)
439 uint8_t reserved1[64] = { 0 }; //!< Reserved for future use. Set to 0.
440}; // clang-format on
441
442//! Size of FpbVersionPayload
443static constexpr std::size_t FP_B_VERSION_PAYLOAD_SIZE = 232;
444static_assert(sizeof(FpbVersionPayload) == FP_B_VERSION_PAYLOAD_SIZE, "");
445
446///@}
447
448/* ****************************************************************************************************************** */
449} // namespace fpb
450} // namespace parser
451} // namespace common
452} // namespace fpsdk
453#endif // __FPSDK_COMMON_PARSER_FPB_HPP__
static constexpr uint16_t FP_B_VERSION_MSGID
FP_B-VERSION message ID.
Definition fpb.hpp:242
static constexpr const char * FP_B_GNSSSTATUS_STRID
FP_B-GNSSSTATUS message name.
Definition fpb.hpp:237
static constexpr const char * FP_B_VERSION_STRID
FP_B-VERSION message name.
Definition fpb.hpp:243
static constexpr const char * FP_B_UNITTEST1_STRID
FP_B-UNITTEST1 message name.
Definition fpb.hpp:245
static constexpr uint8_t FP_B_MEASUREMENTS_V1
FP_B-MEASUREMENTS.version value.
Definition fpb.hpp:324
static constexpr const char * FP_B_SYSTEMSTATUS_STRID
FP_B-SYSTEMSTATUS message name.
Definition fpb.hpp:239
static constexpr uint8_t FP_B_VERSION_V1
FP_B-VERSION.version value.
Definition fpb.hpp:428
bool FpbGetMessageName(char *name, const std::size_t size, const uint8_t *msg, const std::size_t msg_size)
Get FP_B message name.
static constexpr uint16_t FP_B_GNSSSTATUS_MSGID
FP_B-GNSSSTATUS message ID.
Definition fpb.hpp:236
static constexpr std::size_t FP_B_MEASUREMENTS_MAX_NUM_MEAS
Maximum number of measurements.
Definition fpb.hpp:393
static constexpr uint16_t FP_B_UNITTEST2_MSGID
FP_B-UNITTEST2 message ID.
Definition fpb.hpp:246
bool FpbMakeMessage(std::vector< uint8_t > &msg, const uint16_t msg_id, const uint16_t msg_time, const std::vector< uint8_t > &payload)
Make a FP_B message.
static constexpr std::size_t FP_B_MEASUREMENTS_HEAD_SIZE
FP_B-MEASUREMENTS payload head size.
Definition fpb.hpp:337
static constexpr uint8_t FP_B_SYNC_1
FP_B frame sync char 1 ('f', 102, 0b0110'0110)
Definition fpb.hpp:110
static constexpr std::size_t FP_B_VERSION_PAYLOAD_SIZE
Size of FpbVersionPayload.
Definition fpb.hpp:443
static constexpr uint16_t FP_B_SYSTEMSTATUS_MSGID
FP_B-SYSTEMSTATUS message ID.
Definition fpb.hpp:238
static constexpr uint16_t FP_B_UNITTEST1_MSGID
FP_B-UNITTEST1 message ID.
Definition fpb.hpp:244
static constexpr std::size_t FP_B_FRAME_SIZE
Size (in bytes) of FP_B frame.
Definition fpb.hpp:108
static constexpr std::size_t FP_B_HEAD_SIZE
Size of FP_B frame header.
Definition fpb.hpp:109
FpbMeasurementsTimestampType
FP_B-MEASUREMENTS timestamp type.
Definition fpb.hpp:360
@ MONOTONIC
Use monotonic time [any] (stored in the gps_tow field)
@ TIMEOFARRIVAL
Use time of arrival of the measurement (ignore gps_wno and gps_tow)
@ GPS
Use GPS time (stored in gps_wno [-] and gps_tow [ms] fields)
static constexpr const char * FP_B_UNITTEST2_STRID
FP_B-UNITTEST2 message name.
Definition fpb.hpp:247
FpbMeasurementsMeasType
FP_B-MEASUREMENTS measurement type.
Definition fpb.hpp:341
@ VELOCITY
Velocity measuement (wheel speed)
constexpr uint16_t FpbMsgId(const uint8_t *msg)
Get message ID.
Definition fpb.hpp:122
static constexpr const char * FP_B_MEASUREMENTS_STRID
FP_B-MEASUREMENTS message name.
Definition fpb.hpp:241
FpbMeasurementsMeasLoc
FP_B-MEASUREMENTS measurement location.
Definition fpb.hpp:349
@ FR
Measurement of a sensor at the front-right (FR)
@ RC
Measurement of a sensor at the rear-center (RC)
@ RL
Measurement of a sensor at the rear-left (RL)
@ FL
Measurement of a sensor at the front-left (FL)
@ RR
Measurement of a sensor at the rear-right (RR)
constexpr uint16_t FpbMsgTime(const uint8_t *msg)
Get message time.
Definition fpb.hpp:136
static constexpr uint16_t FP_B_MEASUREMENTS_MSGID
FP_B-MEASUREMENTS message ID.
Definition fpb.hpp:240
static constexpr std::size_t FP_B_MEASUREMENTS_MEAS_SIZE
Size of FpbMeasurementsMeas.
Definition fpb.hpp:390
bool FpbGetMessageInfo(char *info, const std::size_t size, const uint8_t *msg, const std::size_t msg_size)
Get FP_B message info.
static constexpr uint8_t FP_B_SYNC_2
FP_B frame sync char 2 ('!', 33, 0b0010'0001)
Definition fpb.hpp:111
constexpr std::underlying_type< T >::type EnumToVal(T enum_val)
Convert enum class constant to the underlying integral type value.
Definition types.hpp:46
Fixposition SDK.
FP_B-MEASUREMENTS payload: head.
Definition fpb.hpp:328
uint8_t version
Message version (= FP_B_MEASUREMENTS_V1 for this version of the message)
Definition fpb.hpp:330
uint8_t num_meas
Number of measurements in the body (1..FP_B_MEASUREMENTS_MAX_NUM_MEAS)
Definition fpb.hpp:331
uint8_t reserved0[6]
Reserved for future use. Set to 0.
Definition fpb.hpp:332
FP_B-MEASUREMENTS payload: measurement.
Definition fpb.hpp:369
uint8_t timestamp_type
See FpbMeasurementsTimestampType.
Definition fpb.hpp:383
uint8_t meas_y_valid
Validity of measurement y (1 = meas_x contains valid data, 0 = data invalid or n/a)
Definition fpb.hpp:375
uint8_t meas_z_valid
Validity of measurement z (1 = meas_x contains valid data, 0 = data invalid or n/a)
Definition fpb.hpp:376
uint8_t meas_type
See FpbMeasurementsMeasType.
Definition fpb.hpp:378
uint8_t meas_x_valid
Validity of measurement x (1 = meas_x contains valid data, 0 = data invalid or n/a)
Definition fpb.hpp:374
uint32_t gps_tow
GPS time of week [ms] or monotonic time [-].
Definition fpb.hpp:385
uint16_t gps_wno
GPS week number [-].
Definition fpb.hpp:384
uint8_t reserved1[4]
Reserved for future use. Set to 0.
Definition fpb.hpp:381
uint8_t meas_loc
See FpbMeasurementsMeasLoc.
Definition fpb.hpp:380
FP_B-VERSION payload: head.
Definition fpb.hpp:432
uint8_t reserved1[64]
Reserved for future use. Set to 0.
Definition fpb.hpp:439
uint8_t hw_ver[32]
Hardware version (nul-terminated string)
Definition fpb.hpp:437
uint8_t hw_name[32]
Hardware name string (nul-terminated string)
Definition fpb.hpp:436
uint8_t reserved0[7]
Reserved for future use. Set to 0.
Definition fpb.hpp:434
uint8_t hw_uid[32]
Hardware UID (nul-terminated string)
Definition fpb.hpp:438
uint8_t sw_version[64]
Software version (nul-terminated string)
Definition fpb.hpp:435
uint8_t version
Message version (= FP_B_VERSION_V1 for this version of the message)
Definition fpb.hpp:433
Fixposition SDK: Common types.