Fixposition SDK 0.0.0-heads/main-0-g90a51ff
Collection of c++ libraries and apps for use with Fixposition products
Loading...
Searching...
No Matches
spartn.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 * The information on message structures, IDs, descriptions etc. in this file are from publicly available data, such as:
11 * - Secure Position Augmentation for Real-Time Navigation (SPARTN) Interface Control Document
12 * (https://www.spartnformat.org)
13 * \endverbatim
14 *
15 * @file
16 * @brief Fixposition SDK: Parser SPARTN routines and types
17 *
18 * @page FPSDK_COMMON_PARSER_SPARTN Parser SPARTN routines and types
19 *
20 * **API**: fpsdk_common/parser/spartn.hpp and fpsdk::common::parser::spartn
21 *
22 */
23#ifndef __FPSDK_COMMON_PARSER_SPARTN_HPP__
24#define __FPSDK_COMMON_PARSER_SPARTN_HPP__
25
26/* LIBC/STL */
27#include <cstdint>
28
29/* EXTERNAL */
30
31/* PACKAGE */
32
33namespace fpsdk {
34namespace common {
35namespace parser {
36/**
37 * @brief Parser SPARTN routines and types
38 */
39namespace spartn {
40/* ****************************************************************************************************************** */
41
42static constexpr uint8_t SPARTN_PREAMBLE = 0x73; //!< SPARTN protocol preamble
43static constexpr std::size_t SPARTN_MIN_HEAD_SIZE = 8; //!< Minimal header size of a SPARTN message
44
45/**
46 * @brief Get SPARTN message type
47 *
48 * @param[in] msg Pointer to the start of the message
49 *
50 * @note No check on the data provided is done. The caller must ensure that the data is a valid SPARTN message.
51 *
52 * @returns the SPARTN message type
53 */
54constexpr uint8_t SpartnType(const uint8_t* msg)
55{
56 return (msg[1] & 0xfe) >> 1;
57}
58
59/**
60 * @brief Get SPARTN message sub-type
61 *
62 * @param[in] msg Pointer to the start of the message
63 *
64 * @note No check on the data provided is done. The caller must ensure that the data is a valid SPARTN message.
65 *
66 * @returns the SPARTN message sub-type
67 */
68constexpr uint8_t SpartnSubType(const uint8_t* msg)
69{
70 return (msg[4] & 0xf0) >> 4;
71}
72
73/**
74 * @brief Get SPARTN message name
75 *
76 * Generates a name (string) in the form "SPARTN-TYPEN_S", where N is the message type and S is the sub-type. For
77 * example: "SPARTN-TYPE1_2".
78 *
79 * @param[out] name String to write the name to
80 * @param[in] size Size of \c name (incl. nul termination)
81 * @param[in] msg Pointer to the SPARTN message
82 * @param[in] msg_size Size of the \c msg
83 *
84 * @note No check on the data provided is done. The caller must ensure that the data is a valid SPARTN message.
85 *
86 * @returns true if message name was generated, false if \c name buffer was too small
87 */
88bool SpartnGetMessageName(char* name, const std::size_t size, const uint8_t* msg, const std::size_t msg_size);
89
90/**
91 * @brief Get SPARTN message info
92 *
93 * This stringifies the content of some SPARTN messages, for debugging.
94 *
95 * @param[out] info String to write the info to
96 * @param[in] size Size of \c name (incl. nul termination)
97 * @param[in] msg Pointer to the SPARTN message
98 * @param[in] msg_size Size of the \c msg
99 *
100 * @note No check on the data provided is done. The caller must ensure that the data is a valid SPARTN message.
101 *
102 * @returns true if message info was generated (even if info is empty), false if \c name buffer was too small
103 */
104bool SpartnGetMessageInfo(char* info, const std::size_t size, const uint8_t* msg, const std::size_t msg_size);
105
106/**
107 * @brief Get description for a SPARTN message type
108 *
109 * @param[in] type Message type
110 * @param[in] subtype Message sub-type (if appropriate)
111 *
112 * @return the description of the message type, if available, NULL otherwise
113 */
114const char* SpartnGetTypeDesc(const uint16_t type, const uint16_t subtype = 0xffff);
115
116/**
117 * @name SPARTN messages (names and IDs)
118 *
119 * @{
120 */
121// clang-format off
122// @fp_codegen_begin{FPSDK_COMMON_PARSER_SPARTN_MESSAGES}
123static constexpr uint16_t SPARTN_OCB_MSGID = 0; //!< SPARTN-OCB message ID
124static constexpr const char* SPARTN_OCB_STRID = "SPARTN-OCB"; //!< SPARTN-OCB message name
125static constexpr uint16_t SPARTN_HPAC_MSGID = 1; //!< SPARTN-HPAC message ID
126static constexpr const char* SPARTN_HPAC_STRID = "SPARTN-HPAC"; //!< SPARTN-HPAC message name
127static constexpr uint16_t SPARTN_GAD_MSGID = 2; //!< SPARTN-GAD message ID
128static constexpr const char* SPARTN_GAD_STRID = "SPARTN-GAD"; //!< SPARTN-GAD message name
129static constexpr uint16_t SPARTN_BPAC_MSGID = 3; //!< SPARTN-BPAC message ID
130static constexpr const char* SPARTN_BPAC_STRID = "SPARTN-BPAC"; //!< SPARTN-BPAC message name
131static constexpr uint16_t SPARTN_EAS_MSGID = 4; //!< SPARTN-EAS message ID
132static constexpr const char* SPARTN_EAS_STRID = "SPARTN-EAS"; //!< SPARTN-EAS message name
133static constexpr uint16_t SPARTN_PROP_MSGID = 120; //!< SPARTN-PROP message ID
134static constexpr const char* SPARTN_PROP_STRID = "SPARTN-PROP"; //!< SPARTN-PROP message name
135static constexpr uint16_t SPARTN_OCB_GPS_SUBID = 0; //!< SPARTN-OCB-GPS message ID
136static constexpr const char* SPARTN_OCB_GPS_STRID = "SPARTN-OCB-GPS"; //!< SPARTN-OCB-GPS message name
137static constexpr uint16_t SPARTN_OCB_GLO_SUBID = 1; //!< SPARTN-OCB-GLO message ID
138static constexpr const char* SPARTN_OCB_GLO_STRID = "SPARTN-OCB-GLO"; //!< SPARTN-OCB-GLO message name
139static constexpr uint16_t SPARTN_OCB_GAL_SUBID = 2; //!< SPARTN-OCB-GAL message ID
140static constexpr const char* SPARTN_OCB_GAL_STRID = "SPARTN-OCB-GAL"; //!< SPARTN-OCB-GAL message name
141static constexpr uint16_t SPARTN_OCB_BDS_SUBID = 3; //!< SPARTN-OCB-BDS message ID
142static constexpr const char* SPARTN_OCB_BDS_STRID = "SPARTN-OCB-BDS"; //!< SPARTN-OCB-BDS message name
143static constexpr uint16_t SPARTN_OCB_QZSS_SUBID = 4; //!< SPARTN-OCB-QZSS message ID
144static constexpr const char* SPARTN_OCB_QZSS_STRID = "SPARTN-OCB-QZSS"; //!< SPARTN-OCB-QZSS message name
145static constexpr uint16_t SPARTN_HPAC_GPS_SUBID = 0; //!< SPARTN-HPAC-GPS message ID
146static constexpr const char* SPARTN_HPAC_GPS_STRID = "SPARTN-HPAC-GPS"; //!< SPARTN-HPAC-GPS message name
147static constexpr uint16_t SPARTN_HPAC_GLO_SUBID = 1; //!< SPARTN-HPAC-GLO message ID
148static constexpr const char* SPARTN_HPAC_GLO_STRID = "SPARTN-HPAC-GLO"; //!< SPARTN-HPAC-GLO message name
149static constexpr uint16_t SPARTN_HPAC_GAL_SUBID = 2; //!< SPARTN-HPAC-GAL message ID
150static constexpr const char* SPARTN_HPAC_GAL_STRID = "SPARTN-HPAC-GAL"; //!< SPARTN-HPAC-GAL message name
151static constexpr uint16_t SPARTN_HPAC_BDS_SUBID = 3; //!< SPARTN-HPAC-BDS message ID
152static constexpr const char* SPARTN_HPAC_BDS_STRID = "SPARTN-HPAC-BDS"; //!< SPARTN-HPAC-BDS message name
153static constexpr uint16_t SPARTN_HPAC_QZSS_SUBID = 4; //!< SPARTN-HPAC-QZSS message ID
154static constexpr const char* SPARTN_HPAC_QZSS_STRID = "SPARTN-HPAC-QZSS"; //!< SPARTN-HPAC-QZSS message name
155static constexpr uint16_t SPARTN_GAD_GAD_SUBID = 0; //!< SPARTN-GAD-GAD message ID
156static constexpr const char* SPARTN_GAD_GAD_STRID = "SPARTN-GAD-GAD"; //!< SPARTN-GAD-GAD message name
157static constexpr uint16_t SPARTN_BPAC_POLY_SUBID = 0; //!< SPARTN-BPAC-POLY message ID
158static constexpr const char* SPARTN_BPAC_POLY_STRID = "SPARTN-BPAC-POLY"; //!< SPARTN-BPAC-POLY message name
159static constexpr uint16_t SPARTN_EAS_KEY_SUBID = 0; //!< SPARTN-EAS-KEY message ID
160static constexpr const char* SPARTN_EAS_KEY_STRID = "SPARTN-EAS-KEY"; //!< SPARTN-EAS-KEY message name
161static constexpr uint16_t SPARTN_EAS_GROUP_SUBID = 1; //!< SPARTN-EAS-GROUP message ID
162static constexpr const char* SPARTN_EAS_GROUP_STRID = "SPARTN-EAS-GROUP"; //!< SPARTN-EAS-GROUP message name
163static constexpr uint16_t SPARTN_PROP_EST_SUBID = 0; //!< SPARTN-PROP-EST message ID
164static constexpr const char* SPARTN_PROP_EST_STRID = "SPARTN-PROP-EST"; //!< SPARTN-PROP-EST message name
165static constexpr uint16_t SPARTN_PROP_UBLOX_SUBID = 1; //!< SPARTN-PROP-UBLOX message ID
166static constexpr const char* SPARTN_PROP_UBLOX_STRID = "SPARTN-PROP-UBLOX"; //!< SPARTN-PROP-UBLOX message name
167static constexpr uint16_t SPARTN_PROP_SWIFT_SUBID = 2; //!< SPARTN-PROP-SWIFT message ID
168static constexpr const char* SPARTN_PROP_SWIFT_STRID = "SPARTN-PROP-SWIFT"; //!< SPARTN-PROP-SWIFT message name
169// @fp_codegen_end{FPSDK_COMMON_PARSER_SPARTN_MESSAGES}
170// clang-format on
171
172///@}
173
174/* ****************************************************************************************************************** */
175} // namespace spartn
176} // namespace parser
177} // namespace common
178} // namespace fpsdk
179#endif // __FPSDK_COMMON_PARSER_SPARTN_HPP__
static constexpr const char * SPARTN_PROP_STRID
SPARTN-PROP message name.
Definition spartn.hpp:134
static constexpr uint16_t SPARTN_PROP_EST_SUBID
SPARTN-PROP-EST message ID.
Definition spartn.hpp:163
static constexpr const char * SPARTN_HPAC_STRID
SPARTN-HPAC message name.
Definition spartn.hpp:126
static constexpr const char * SPARTN_HPAC_QZSS_STRID
SPARTN-HPAC-QZSS message name.
Definition spartn.hpp:154
static constexpr uint16_t SPARTN_OCB_BDS_SUBID
SPARTN-OCB-BDS message ID.
Definition spartn.hpp:141
static constexpr const char * SPARTN_EAS_STRID
SPARTN-EAS message name.
Definition spartn.hpp:132
constexpr uint8_t SpartnSubType(const uint8_t *msg)
Get SPARTN message sub-type.
Definition spartn.hpp:68
bool SpartnGetMessageName(char *name, const std::size_t size, const uint8_t *msg, const std::size_t msg_size)
Get SPARTN message name.
static constexpr const char * SPARTN_OCB_BDS_STRID
SPARTN-OCB-BDS message name.
Definition spartn.hpp:142
static constexpr const char * SPARTN_OCB_QZSS_STRID
SPARTN-OCB-QZSS message name.
Definition spartn.hpp:144
static constexpr const char * SPARTN_PROP_EST_STRID
SPARTN-PROP-EST message name.
Definition spartn.hpp:164
static constexpr const char * SPARTN_OCB_GAL_STRID
SPARTN-OCB-GAL message name.
Definition spartn.hpp:140
static constexpr const char * SPARTN_PROP_SWIFT_STRID
SPARTN-PROP-SWIFT message name.
Definition spartn.hpp:168
static constexpr const char * SPARTN_HPAC_GPS_STRID
SPARTN-HPAC-GPS message name.
Definition spartn.hpp:146
static constexpr uint16_t SPARTN_EAS_KEY_SUBID
SPARTN-EAS-KEY message ID.
Definition spartn.hpp:159
static constexpr uint16_t SPARTN_HPAC_BDS_SUBID
SPARTN-HPAC-BDS message ID.
Definition spartn.hpp:151
static constexpr const char * SPARTN_OCB_STRID
SPARTN-OCB message name.
Definition spartn.hpp:124
const char * SpartnGetTypeDesc(const uint16_t type, const uint16_t subtype=0xffff)
Get description for a SPARTN message type.
static constexpr const char * SPARTN_HPAC_GLO_STRID
SPARTN-HPAC-GLO message name.
Definition spartn.hpp:148
static constexpr uint16_t SPARTN_PROP_SWIFT_SUBID
SPARTN-PROP-SWIFT message ID.
Definition spartn.hpp:167
static constexpr uint16_t SPARTN_PROP_MSGID
SPARTN-PROP message ID.
Definition spartn.hpp:133
static constexpr const char * SPARTN_BPAC_POLY_STRID
SPARTN-BPAC-POLY message name.
Definition spartn.hpp:158
static constexpr uint16_t SPARTN_HPAC_GPS_SUBID
SPARTN-HPAC-GPS message ID.
Definition spartn.hpp:145
static constexpr const char * SPARTN_OCB_GPS_STRID
SPARTN-OCB-GPS message name.
Definition spartn.hpp:136
static constexpr const char * SPARTN_OCB_GLO_STRID
SPARTN-OCB-GLO message name.
Definition spartn.hpp:138
static constexpr const char * SPARTN_GAD_GAD_STRID
SPARTN-GAD-GAD message name.
Definition spartn.hpp:156
static constexpr uint16_t SPARTN_HPAC_GLO_SUBID
SPARTN-HPAC-GLO message ID.
Definition spartn.hpp:147
static constexpr const char * SPARTN_PROP_UBLOX_STRID
SPARTN-PROP-UBLOX message name.
Definition spartn.hpp:166
static constexpr uint16_t SPARTN_GAD_MSGID
SPARTN-GAD message ID.
Definition spartn.hpp:127
static constexpr uint16_t SPARTN_BPAC_POLY_SUBID
SPARTN-BPAC-POLY message ID.
Definition spartn.hpp:157
constexpr uint8_t SpartnType(const uint8_t *msg)
Get SPARTN message type.
Definition spartn.hpp:54
static constexpr const char * SPARTN_HPAC_BDS_STRID
SPARTN-HPAC-BDS message name.
Definition spartn.hpp:152
static constexpr const char * SPARTN_EAS_GROUP_STRID
SPARTN-EAS-GROUP message name.
Definition spartn.hpp:162
static constexpr const char * SPARTN_BPAC_STRID
SPARTN-BPAC message name.
Definition spartn.hpp:130
static constexpr uint16_t SPARTN_EAS_MSGID
SPARTN-EAS message ID.
Definition spartn.hpp:131
static constexpr uint16_t SPARTN_PROP_UBLOX_SUBID
SPARTN-PROP-UBLOX message ID.
Definition spartn.hpp:165
static constexpr uint16_t SPARTN_BPAC_MSGID
SPARTN-BPAC message ID.
Definition spartn.hpp:129
static constexpr uint16_t SPARTN_HPAC_QZSS_SUBID
SPARTN-HPAC-QZSS message ID.
Definition spartn.hpp:153
static constexpr uint16_t SPARTN_EAS_GROUP_SUBID
SPARTN-EAS-GROUP message ID.
Definition spartn.hpp:161
static constexpr uint16_t SPARTN_OCB_GLO_SUBID
SPARTN-OCB-GLO message ID.
Definition spartn.hpp:137
static constexpr uint16_t SPARTN_HPAC_GAL_SUBID
SPARTN-HPAC-GAL message ID.
Definition spartn.hpp:149
static constexpr uint16_t SPARTN_OCB_GPS_SUBID
SPARTN-OCB-GPS message ID.
Definition spartn.hpp:135
static constexpr std::size_t SPARTN_MIN_HEAD_SIZE
Minimal header size of a SPARTN message.
Definition spartn.hpp:43
bool SpartnGetMessageInfo(char *info, const std::size_t size, const uint8_t *msg, const std::size_t msg_size)
Get SPARTN message info.
static constexpr const char * SPARTN_GAD_STRID
SPARTN-GAD message name.
Definition spartn.hpp:128
static constexpr uint16_t SPARTN_OCB_GAL_SUBID
SPARTN-OCB-GAL message ID.
Definition spartn.hpp:139
static constexpr uint16_t SPARTN_OCB_QZSS_SUBID
SPARTN-OCB-QZSS message ID.
Definition spartn.hpp:143
static constexpr uint16_t SPARTN_HPAC_MSGID
SPARTN-HPAC message ID.
Definition spartn.hpp:125
static constexpr const char * SPARTN_HPAC_GAL_STRID
SPARTN-HPAC-GAL message name.
Definition spartn.hpp:150
static constexpr uint8_t SPARTN_PREAMBLE
SPARTN protocol preamble.
Definition spartn.hpp:42
static constexpr uint16_t SPARTN_OCB_MSGID
SPARTN-OCB message ID.
Definition spartn.hpp:123
static constexpr uint16_t SPARTN_GAD_GAD_SUBID
SPARTN-GAD-GAD message ID.
Definition spartn.hpp:155
static constexpr const char * SPARTN_EAS_KEY_STRID
SPARTN-EAS-KEY message name.
Definition spartn.hpp:160
Fixposition SDK.