Fixposition SDK 0.0.0-heads/main-0-g6666cac
Collection of c++ libraries and apps for use with Fixposition products on Linux
Loading...
Searching...
No Matches
qgc.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 * - LG290P&LGx80P Series, GNSS Protocol Specification, copyright Quectel Wireless Solutions Co
12 * \endverbatim
13 *
14 * @file
15 * @brief Fixposition SDK: Parser QGC routines and types
16 *
17 * @page FPSDK_COMMON_PARSER_QGC Parser QGC routines and types
18 *
19 * **API**: fpsdk_common/parser/qgc.hpp and fpsdk::common::parser::qgc
20 *
21 */
22#ifndef __FPSDK_COMMON_PARSER_QGC_HPP__
23#define __FPSDK_COMMON_PARSER_QGC_HPP__
24
25/* LIBC/STL */
26#include <cstdint>
27
28/* EXTERNAL */
29
30/* PACKAGE */
31
32namespace fpsdk {
33namespace common {
34namespace parser {
35/**
36 * @brief Parser QGC routines and types
37 */
38namespace qgc {
39/* ****************************************************************************************************************** */
40
41static constexpr uint8_t QGC_SYNC_1 = 0x51; //!< Sync char 1 ('Q')
42static constexpr uint8_t QGC_SYNC_2 = 0x47; //!< Sync char 2 ('G')
43static constexpr std::size_t QGC_HEAD_SIZE = 6; //!< Size of the QGC header
44static constexpr std::size_t QGC_FRAME_SIZE = 8; //!< Size (in bytes) of QGC frame
45
46/**
47 * @brief Get group ID from message
48 *
49 * @param[in] msg Pointer to the start of the message
50 *
51 * @note No check on the data provided is done. This is meant for use as a helper in other functions. Checks on the
52 * \c msg and its data should be carried out there.
53 *
54 * @returns the QGC group ID
55 */
56constexpr uint8_t QgcGrpId(const uint8_t* msg)
57{
58 return (((uint8_t*)(msg))[2]);
59}
60
61/**
62 * @brief Get message ID from message
63 *
64 * @param[in] msg Pointer to the start of the message
65 *
66 * @note No check on the data provided is done. This is meant for use as a helper in other functions. Checks on the
67 * \c msg and its data should be carried out there.
68 *
69 * @returns the QGC message ID
70 */
71constexpr uint8_t QgcMsgId(const uint8_t* msg)
72{
73 return (((uint8_t*)(msg))[3]);
74}
75
76/**
77 * @brief Get QGC message name
78 *
79 * Generates a name (string) in the form "QGC-GRPID-MSGID", where GRPID and MSGID are suitable stringifications of the
80 * class ID and message ID if known (for example, "QGC-RAW-HASE6", respectively %02X formatted IDs if unknown (for
81 * example, "QGC-0A-FF").
82 *
83 * @param[out] name String to write the name to
84 * @param[in] size Size of \c name (incl. nul termination)
85 * @param[in] msg Pointer to the QGC message
86 * @param[in] msg_size Size of the \c msg
87 *
88 * @note No check on the data provided is done. The caller must ensure that the data is a valid QGC message.
89 *
90 * @returns true if message name was generated, false if \c name buffer was too small
91 */
92bool QgcGetMessageName(char* name, const std::size_t size, const uint8_t* msg, const std::size_t msg_size);
93
94/**
95 * @brief Get QGC message info
96 *
97 * This stringifies the content of some QGC messages, for debugging.
98 *
99 * @param[out] info String to write the info to
100 * @param[in] size Size of \c name (incl. nul termination)
101 * @param[in] msg Pointer to the QGC message
102 * @param[in] msg_size Size of the \c msg
103 *
104 * @note No check on the data provided is done. The caller must ensure that the data is a valid QGC message.
105 *
106 * @returns true if message info was generated (even if info is empty), false if \c name buffer was too small
107 */
108bool QgcGetMessageInfo(char* info, const std::size_t size, const uint8_t* msg, const std::size_t msg_size);
109
110// ---------------------------------------------------------------------------------------------------------------------
111
112/**
113 * @name QGC groups and messages (names and IDs)
114 *
115 * @{
116 */
117// clang-format off
118// @fp_codegen_begin{FPSDK_COMMON_PARSER_QGC_GROUPS}
119static constexpr uint8_t QGC_RAW_GRPID = 0x0a; //!< QGC-RAW group ID
120static constexpr const char* QGC_RAW_STRID = "QGC-RAW"; //!< QGC-RAW group name
121// @fp_codegen_end{FPSDK_COMMON_PARSER_QGC_GROUPS}
122// clang-format on
123
124// clang-format off
125// @fp_codegen_begin{FPSDK_COMMON_PARSER_QGC_MESSAGES}
126static constexpr uint8_t QGC_RAW_PPPB2B_MSGID = 0xb2; //!< QGC-RAW-PPPB2B message ID
127static constexpr const char* QGC_RAW_PPPB2B_STRID = "QGC-RAW-PPPB2B"; //!< QGC-RAW-PPPB2B message name
128static constexpr uint8_t QGC_RAW_QZSSL6_MSGID = 0xb6; //!< QGC-RAW-QZSSL6 message ID
129static constexpr const char* QGC_RAW_QZSSL6_STRID = "QGC-RAW-QZSSL6"; //!< QGC-RAW-QZSSL6 message name
130static constexpr uint8_t QGC_RAW_HASE6_MSGID = 0xe6; //!< QGC-RAW-HASE6 message ID
131static constexpr const char* QGC_RAW_HASE6_STRID = "QGC-RAW-HASE6"; //!< QGC-RAW-HASE6 message name
132// @fp_codegen_end{FPSDK_COMMON_PARSER_QGC_MESSAGES}
133// clang-format on
134///@}
135
136/* ****************************************************************************************************************** */
137} // namespace qgc
138} // namespace parser
139} // namespace common
140} // namespace fpsdk
141#endif // __FPSDK_COMMON_PARSER_QGC_HPP__
Parser QGC routines and types.
Definition qgc.hpp:38
static constexpr uint8_t QGC_RAW_HASE6_MSGID
QGC-RAW-HASE6 message ID.
Definition qgc.hpp:130
static constexpr uint8_t QGC_RAW_GRPID
QGC-RAW group ID.
Definition qgc.hpp:119
static constexpr const char * QGC_RAW_QZSSL6_STRID
QGC-RAW-QZSSL6 message name.
Definition qgc.hpp:129
static constexpr uint8_t QGC_RAW_PPPB2B_MSGID
QGC-RAW-PPPB2B message ID.
Definition qgc.hpp:126
static constexpr std::size_t QGC_FRAME_SIZE
Size (in bytes) of QGC frame.
Definition qgc.hpp:44
static constexpr uint8_t QGC_RAW_QZSSL6_MSGID
QGC-RAW-QZSSL6 message ID.
Definition qgc.hpp:128
static constexpr std::size_t QGC_HEAD_SIZE
Size of the QGC header.
Definition qgc.hpp:43
static constexpr const char * QGC_RAW_STRID
QGC-RAW group name.
Definition qgc.hpp:120
bool QgcGetMessageInfo(char *info, const std::size_t size, const uint8_t *msg, const std::size_t msg_size)
Get QGC message info.
static constexpr const char * QGC_RAW_HASE6_STRID
QGC-RAW-HASE6 message name.
Definition qgc.hpp:131
static constexpr uint8_t QGC_SYNC_1
Sync char 1 ('Q')
Definition qgc.hpp:41
constexpr uint8_t QgcGrpId(const uint8_t *msg)
Get group ID from message.
Definition qgc.hpp:56
constexpr uint8_t QgcMsgId(const uint8_t *msg)
Get message ID from message.
Definition qgc.hpp:71
static constexpr const char * QGC_RAW_PPPB2B_STRID
QGC-RAW-PPPB2B message name.
Definition qgc.hpp:127
bool QgcGetMessageName(char *name, const std::size_t size, const uint8_t *msg, const std::size_t msg_size)
Get QGC message name.
static constexpr uint8_t QGC_SYNC_2
Sync char 2 ('G')
Definition qgc.hpp:42
Fixposition SDK: Common library.
Definition doc.hpp:21
Fixposition SDK.