control.h
Go to the documentation of this file.
1 /**************************************************************************/ /**
2  * @brief Device operation control messages.
3  * @file
4  ******************************************************************************/
5 
6 #pragma once
7 
8 // If we are compiling under MSVC, disable warning C4200:
9 // nonstandard extension used: zero-sized array in struct/union
10 // Zero-sized arrays are supported by MSVC, GCC, and Clang, and we use them as
11 // convenience placeholders for variable sized message payloads.
12 #ifdef _MSC_VER
13 #pragma warning(push)
14 #pragma warning(disable: 4200)
15 #endif
16 
18 
19 namespace point_one {
20 namespace fusion_engine {
21 namespace messages {
22 
23 // Enforce 4-byte alignment and packing of all data structures and values.
24 // Floating point values are aligned on platforms that require it. This is done
25 // with a combination of setting struct attributes, and manual alignment
26 // within the definitions. See the "Message Packing" section of the README.
27 #pragma pack(push, 1)
28 
29 /**
30  * @defgroup config_and_ctrl_messages Device Configuration and Control Message Definitions
31  * @brief Messages for controlling device configuration and operation.
32  * @ingroup messages
33  *
34  * When a configuration/control message is received, a device typically responds
35  * with either a @ref CommandResponseMessage or another appropriate response.
36  * For example, a @ref MessageRequest requesting @ref MessageType::VERSION_INFO
37  * may result in a @ref VersionInfoMessage response, or a @ref
38  * CommandResponseMessage indicating that directly requesting version messages
39  * is not supported. See the documentation for the individual control messages
40  * for details on the expected response.
41  *
42  * See also @ref messages.
43  */
44 
45 /**
46  * @brief Response to indicate if command was processed successfully (@ref
47  * MessageType::COMMAND_RESPONSE, version 1.0).
48  * @ingroup config_and_ctrl_messages
49  */
50 struct alignas(4) CommandResponseMessage : public MessagePayload {
51  /** @brief Command response status indicators. */
52  enum class Response : uint8_t {
53  OK = 0,
54  /**
55  * A version specified in the command or subcommand could not be handled.
56  * This could mean that the version was too new, or it was old and there was
57  * not a translation for it.
58  */
60  /**
61  * The command interacts with a feature that is not present on the target
62  * device (e.g., Setting the baud rate on a device without a serial port).
63  */
65  /**
66  * One or more values in the command were not in acceptable ranges (e.g., An
67  * undefined enum value, or an invalid baud rate).
68  */
69  VALUE_ERROR = 3,
70  /**
71  * The command would require adding too many elements to an internal
72  * storage.
73  */
75  /**
76  * There was a runtime failure executing the command.
77  */
79  };
80 
82  static constexpr uint8_t MESSAGE_VERSION = 0;
83 
84  /** The sequence number of the command that triggered this response. */
85  uint32_t source_seq_number = 0;
86 
87  /** The response status (success, error, etc.). */
89 
90  uint8_t reserved[3] = {0};
91 };
92 
93 /**
94  * @brief Request transmission of a specified message type, (@ref
95  * MessageType::MESSAGE_REQUEST, version 1.0).
96  * @ingroup config_and_ctrl_messages
97  *
98  * On success, the device will output the requested message type.
99  *
100  * Not all message types may be requested explicitly. If a message type cannot
101  * be requested on demand or is not supported, the device will respond with a
102  * @ref CommandResponseMessage::Response::UNSUPPORTED_FEATURE message.
103  *
104  * @note
105  * The generated response may not immediately follow the request if other
106  * outbound messages are already enqueued to be sent.
107  */
108 struct alignas(4) MessageRequest : public MessagePayload {
110  static constexpr uint8_t MESSAGE_VERSION = 0;
111 
112  /** The desired message type. */
114 
115  uint8_t reserved[2] = {0};
116 };
117 
118 /**
119  * @brief Perform a software or hardware reset (@ref MessageType::RESET_REQUEST,
120  * version 1.0).
121  * @ingroup config_and_ctrl_messages
122  *
123  * This message contains a bitmask indicating the set of components to be reset.
124  * Helper bitmasks are provided for common reset operations.
125  */
126 struct alignas(4) ResetRequest : public MessagePayload {
128  static constexpr uint8_t MESSAGE_VERSION = 0;
129 
130  /**
131  * @name Runtime State Reset
132  * @{
133  */
134  /** Restart the navigation engine, but do not clear its position estimate. */
135  static constexpr uint32_t RESTART_NAVIGATION_ENGINE = 0x00000001;
136  /** Delete all GNSS corrections information. */
137  static constexpr uint32_t RESET_CORRECTIONS = 0x00000002;
138  /** @} */
139 
140  /**
141  * @name Clear Short Lived Data
142  * @{
143  */
144  /**
145  * Reset the navigation engine's estimate of position, velocity, and
146  * orientation.
147  */
148  static constexpr uint32_t RESET_POSITION_DATA = 0x00000100;
149  /** Delete all saved satellite ephemeris. */
150  static constexpr uint32_t RESET_EPHEMERIS = 0x00000200;
151  /** @} */
152 
153  /**
154  * @name Clear Long Lived Data
155  * @{
156  */
157  /**
158  * Reset all stored navigation engine data, including position, velocity, and
159  * orientation state, as well as training data.
160  */
161  static constexpr uint32_t RESET_NAVIGATION_ENGINE_DATA = 0x00001000;
162  /**
163  * Reset the device calibration data.
164  *
165  * @note
166  * This does _not_ reset any existing navigation engine state. It is
167  * recommended that you set @ref RESET_NAVIGATION_ENGINE_DATA as well under
168  * normal circumstances.
169  */
170  static constexpr uint32_t RESET_CALIBRATION_DATA = 0x00002000;
171  /** @} */
172 
173  /**
174  * @name Clear Configuration Data
175  * @{
176  */
177  /** Clear all configuration data. */
178  static constexpr uint32_t RESET_CONFIG = 0x00100000;
179  /** @} */
180 
181  /**
182  * @name Device Reset Bitmasks
183  * @{
184  */
185  /**
186  * Perform a device hot start: reload the navigation engine and clear all
187  * runtime data (GNSS corrections, etc.), but do not reset any saved state
188  * data (position, orientation, training parameters, calibration, etc.).
189  *
190  * A hot start is typically used to restart the navigation engine in a
191  * deterministic state, particularly for logging purposes.
192  */
193  static constexpr uint32_t HOT_START = 0x000000FF;
194 
195  /**
196  * Perform a device warm start: reload the navigation engine, resetting the
197  * saved position, velocity, and orientation, but do not reset training
198  * parameters or calibration data.
199  *
200  * A warm start is typically used to reset the device's position estimate in
201  * case of error.
202  */
203  static constexpr uint32_t WARM_START = 0x000001FF;
204 
205  /**
206  * Perform a device cold start: reset the navigation engine including saved
207  * position, velocity, and orientation state, but do not reset training data,
208  * calibration data, or user configuration parameters.
209  *
210  * @note
211  * To reset training or calibration data as well, set the @ref
212  * RESET_NAVIGATION_ENGINE_DATA and @ref RESET_CALIBRATION_DATA bits.
213  */
214  static constexpr uint32_t COLD_START = 0x00000FFF;
215 
216  /**
217  * Restart mask to set all persistent data, including calibration and user
218  * configuration, back to factory defaults.
219  *
220  * Note: Upper 8 bits reserved for future use (e.g., hardware reset).
221  */
222  static constexpr uint32_t FACTORY_RESET = 0x00FFFFFF;
223  /** @} */
224 
225  /** Bit mask of functionality to reset. */
226  uint32_t reset_mask = 0;
227 };
228 
229 /**
230  * @brief Software and hardware version information, (@ref
231  * MessageType::VERSION_INFO, version 1.0).
232  * @ingroup config_and_ctrl_messages
233  *
234  * This message contains version strings for each of the following, where
235  * available:
236  * - Firmware - The current version of the platform software/firmware being used
237  * - Engine - The version of Point One FusionEngine being used
238  * - Hardware - The version of the platform hardware being used
239  * - GNSS Receiver - The version of firmware being used by the device's GNSS
240  * receiver
241  *
242  * The message payload specifies the length of each string (in bytes). It is
243  * followed by each of the listed version strings consecutively. The strings are
244  * _not_ null terminated.
245  *
246  * ```
247  * {MessageHeader, VersionInfoMessage, "Firmware Version", "Engine Version",
248  * "Hardware Version", "Receiver Version"}
249  * ```
250  */
251 struct alignas(4) VersionInfoMessage : public MessagePayload {
253  static constexpr uint8_t MESSAGE_VERSION = 0;
254 
255  /** The current system timestamp (in ns).*/
256  int64_t system_time_ns = 0;
257 
258  /** The length of the firmware version string (in bytes). */
259  uint8_t fw_version_length = 0;
260 
261  /** The length of the FusionEngine version string (in bytes). */
263 
264  /** The length of the hardware version string (in bytes). */
265  uint8_t hw_version_length = 0;
266 
267  /** The length of the GNSS receiver version string (in bytes). */
268  uint8_t rx_version_length = 0;
269 
270  uint8_t reserved[4] = {0};
271 
272  /**
273  * The beginning of the firmware version string.
274  *
275  * All other version strings follow immediately after this one in the data
276  * buffer. For example, the FusionEngine version string can be obtained as
277  * follows:
278  * ```cpp
279  * std::string engine_version_str(
280  * fw_version_str + message.fw_version_length,
281  * message.engine_version_length);
282  * ```
283  */
284  char fw_version_str[0];
285 };
286 
287 /**
288  * @brief Notification of a system event for logging purposes (@ref
289  * MessageType::EVENT_NOTIFICATION, version 1.0).
290  * @ingroup config_and_ctrl_messages
291  */
292 struct alignas(4) EventNotificationMessage : public MessagePayload {
293  enum class EventType : uint8_t {
294  LOG = 0,
295  RESET = 1,
296  CONFIG_CHANGE = 2,
297  };
298 
299  static const char* to_string(EventType type) {
300  switch (type) {
301  case EventType::LOG:
302  return "Log";
303 
304  case EventType::RESET:
305  return "Reset";
306 
308  return "Config Change";
309 
310  default:
311  return "Unknown";
312  }
313  }
314 
316  static constexpr uint8_t MESSAGE_VERSION = 0;
317 
318  /** The type of event that occurred. */
320 
321  uint8_t reserved1[3] = {0};
322 
323  /** The current system timestamp (in ns).*/
324  int64_t system_time_ns = 0;
325 
326  /** A bitmask of flags associated with the event. */
327  uint64_t event_flags = 0;
328 
329  /** The number of bytes in the @ref event_description string. */
331 
332  uint8_t reserved2[2] = {0};
333 
334  /**
335  * This is a dummy entry to provide a pointer to this offset.
336  *
337  * This is used for populating string describing the event, where applicable.
338  */
340 };
341 
342 #pragma pack(pop)
343 
344 } // namespace messages
345 } // namespace fusion_engine
346 } // namespace point_one
347 
348 #ifdef _MSC_VER
349 #pragma warning(pop)
350 #endif
@ LOG
MessageType
Identifiers for the defined output message types.
Definition: defs.h:80
Response
Command response status indicators.
Definition: control.h:52
Request transmission of a specified message type, (MessageType::MESSAGE_REQUEST, version 1....
Definition: control.h:108
Response response
The response status (success, error, etc.).
Definition: control.h:88
@ COMMAND_RESPONSE
CommandResponseMessage
@ CONFIG_CHANGE
static constexpr uint32_t RESTART_NAVIGATION_ENGINE
Restart the navigation engine, but do not clear its position estimate.
Definition: control.h:135
@ INVALID
Invalid message type.
static constexpr uint32_t RESET_CALIBRATION_DATA
Reset the device calibration data.
Definition: control.h:170
uint8_t fw_version_length
The length of the firmware version string (in bytes).
Definition: control.h:259
Software and hardware version information, (MessageType::VERSION_INFO, version 1.0).
Definition: control.h:251
static constexpr uint32_t RESET_NAVIGATION_ENGINE_DATA
Reset all stored navigation engine data, including position, velocity, and orientation state,...
Definition: control.h:161
uint64_t event_flags
A bitmask of flags associated with the event.
Definition: control.h:327
@ INSUFFICIENT_SPACE
The command would require adding too many elements to an internal storage.
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:252
static constexpr uint32_t FACTORY_RESET
Restart mask to set all persistent data, including calibration and user configuration,...
Definition: control.h:222
uint8_t rx_version_length
The length of the GNSS receiver version string (in bytes).
Definition: control.h:268
uint16_t event_description_len_bytes
The number of bytes in the event_description string.
Definition: control.h:330
@ UNSUPPORTED_FEATURE
The command interacts with a feature that is not present on the target device (e.g....
Notification of a system event for logging purposes (MessageType::EVENT_NOTIFICATION,...
Definition: control.h:292
The base class for all message payloads.
Definition: defs.h:192
@ RESET_REQUEST
ResetRequest
@ VERSION_INFO
VersionInfoMessage
static constexpr uint32_t WARM_START
Perform a device warm start: reload the navigation engine, resetting the saved position,...
Definition: control.h:203
static constexpr uint32_t HOT_START
Perform a device hot start: reload the navigation engine and clear all runtime data (GNSS corrections...
Definition: control.h:193
Definition: configuration.h:21
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:316
int64_t system_time_ns
The current system timestamp (in ns).
Definition: control.h:324
static const char * to_string(EventType type)
Definition: control.h:299
Perform a software or hardware reset (MessageType::RESET_REQUEST, version 1.0).
Definition: control.h:126
EventType type
The type of event that occurred.
Definition: control.h:319
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:110
uint8_t hw_version_length
The length of the hardware version string (in bytes).
Definition: control.h:265
uint32_t source_seq_number
The sequence number of the command that triggered this response.
Definition: control.h:85
static constexpr uint32_t RESET_CONFIG
Clear all configuration data.
Definition: control.h:178
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:109
char * event_description[0]
This is a dummy entry to provide a pointer to this offset.
Definition: control.h:339
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:253
EventType
Definition: control.h:293
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:81
static constexpr uint32_t COLD_START
Perform a device cold start: reset the navigation engine including saved position,...
Definition: control.h:214
int64_t system_time_ns
The current system timestamp (in ns).
Definition: control.h:256
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:127
uint8_t engine_version_length
The length of the FusionEngine version string (in bytes).
Definition: control.h:262
static constexpr uint32_t RESET_CORRECTIONS
Delete all GNSS corrections information.
Definition: control.h:137
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:82
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:128
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:315
@ VALUE_ERROR
One or more values in the command were not in acceptable ranges (e.g., An undefined enum value,...
Response to indicate if command was processed successfully (MessageType::COMMAND_RESPONSE,...
Definition: control.h:50
Point One FusionEngine output message common definitions.
char fw_version_str[0]
The beginning of the firmware version string.
Definition: control.h:284
uint32_t reset_mask
Bit mask of functionality to reset.
Definition: control.h:226
@ EVENT_NOTIFICATION
EventNotificationMessage
static constexpr uint32_t RESET_EPHEMERIS
Delete all saved satellite ephemeris.
Definition: control.h:150
@ OK
static constexpr uint32_t RESET_POSITION_DATA
Reset the navigation engine's estimate of position, velocity, and orientation.
Definition: control.h:148
MessageType message_type
The desired message type.
Definition: control.h:113
@ MESSAGE_REQUEST
MessageRequest
@ EXECUTION_FAILURE
There was a runtime failure executing the command.
@ RESET
@ UNSUPPORTED_CMD_VERSION
A version specified in the command or subcommand could not be handled.