control.h
Go to the documentation of this file.
1 /**************************************************************************/ /**
2  * @brief Device operation control messages.
3  * @file
4  ******************************************************************************/
5 
6 #pragma once
7 
10 
11 namespace point_one {
12 namespace fusion_engine {
13 namespace messages {
14 
15 // Enforce 4-byte alignment and packing of all data structures and values.
16 // Floating point values are aligned on platforms that require it. This is done
17 // with a combination of setting struct attributes, and manual alignment
18 // within the definitions. See the "Message Packing" section of the README.
19 #pragma pack(push, 1)
20 
21 /**
22  * @defgroup config_and_ctrl_messages Device Configuration and Control Message Definitions
23  * @brief Messages for controlling device configuration and operation.
24  * @ingroup messages
25  *
26  * When a configuration/control message is received, a device typically responds
27  * with either a @ref CommandResponseMessage or another appropriate response.
28  * For example, a @ref MessageRequest requesting @ref MessageType::VERSION_INFO
29  * may result in a @ref VersionInfoMessage response, or a @ref
30  * CommandResponseMessage indicating that directly requesting version messages
31  * is not supported. See the documentation for the individual control messages
32  * for details on the expected response.
33  *
34  * See also @ref messages.
35  */
36 
37 /**
38  * @brief Response to indicate if command was processed successfully (@ref
39  * MessageType::COMMAND_RESPONSE, version 1.0).
40  * @ingroup config_and_ctrl_messages
41  */
43  static constexpr MessageType MESSAGE_TYPE = MessageType::COMMAND_RESPONSE;
44  static constexpr uint8_t MESSAGE_VERSION = 0;
45 
46  /** The sequence number of the command that triggered this response. */
47  uint32_t source_seq_number = 0;
48 
49  /** The response status (success, error, etc.). */
50  Response response = Response::OK;
51 
52  uint8_t reserved[3] = {0};
53 };
54 
55 /**
56  * @brief Request transmission of a specified message type, (@ref
57  * MessageType::MESSAGE_REQUEST, version 1.0).
58  * @ingroup config_and_ctrl_messages
59  *
60  * On success, the device will output the requested message type.
61  *
62  * Not all message types may be requested explicitly. If a message type cannot
63  * be requested on demand or is not supported, the device will respond with a
64  * @ref Response::UNSUPPORTED_FEATURE message.
65  *
66  * @note
67  * The generated response may not immediately follow the request if other
68  * outbound messages are already enqueued to be sent.
69  *
70  * # Expected Response
71  * The requested message type, or @ref CommandResponseMessage on error.
72  */
74  static constexpr MessageType MESSAGE_TYPE = MessageType::MESSAGE_REQUEST;
75  static constexpr uint8_t MESSAGE_VERSION = 0;
76 
77  /** The desired message type. */
79 
80  uint8_t reserved[2] = {0};
81 };
82 
83 /**
84  * @brief Perform a software or hardware reset (@ref MessageType::RESET_REQUEST,
85  * version 1.0).
86  * @ingroup config_and_ctrl_messages
87  *
88  * This message contains a bitmask indicating the set of components to be reset.
89  * Helper bitmasks are provided for common reset operations.
90  *
91  * # Expected Response
92  * The device will respond with a @ref CommandResponseMessage indicating whether
93  * or not the request succeeded.
94  */
96  static constexpr MessageType MESSAGE_TYPE = MessageType::RESET_REQUEST;
97  static constexpr uint8_t MESSAGE_VERSION = 0;
98 
99  /**
100  * @name Runtime State Reset
101  * @{
102  */
103  /** Restart the navigation engine, but do not clear its position estimate. */
104  static constexpr uint32_t RESTART_NAVIGATION_ENGINE = 0x00000001;
105  /** Delete all GNSS corrections information. */
106  static constexpr uint32_t RESET_GNSS_CORRECTIONS = 0x00000002;
107  /** @} */
108 
109  /**
110  * @name Clear Short Lived Data
111  * @{
112  */
113  /**
114  * Reset the navigation engine's estimate of position, velocity, and
115  * orientation.
116  */
117  static constexpr uint32_t RESET_POSITION_DATA = 0x00000100;
118  /** Delete all saved satellite ephemeris. */
119  static constexpr uint32_t RESET_EPHEMERIS = 0x00000200;
120  /**
121  * Reset bias estimates, and other IMU corrections that are typically
122  * estimated quickly.
123  */
124  static constexpr uint32_t RESET_FAST_IMU_CORRECTIONS = 0x00000400;
125  /** @} */
126 
127  /**
128  * @name Clear Long Lived Data
129  * @{
130  */
131  /**
132  * Reset all stored navigation engine data, including position, velocity, and
133  * orientation state (same as @ref RESET_POSITION_DATA), plus all IMU
134  * corrections and other training data.
135  */
136  static constexpr uint32_t RESET_NAVIGATION_ENGINE_DATA = 0x00001000;
137  /**
138  * Reset the device calibration data.
139  *
140  * @note
141  * This does _not_ reset any existing navigation engine state. It is
142  * recommended that you set @ref RESET_NAVIGATION_ENGINE_DATA as well under
143  * normal circumstances.
144  */
145  static constexpr uint32_t RESET_CALIBRATION_DATA = 0x00002000;
146  /** @} */
147 
148  /**
149  * @name Clear Configuration Data
150  * @{
151  */
152  /** Clear all configuration data. */
153  static constexpr uint32_t RESET_CONFIG = 0x00100000;
154  /** @} */
155 
156  /**
157  * @name Software Reboot And Special Reset Modes
158  * @{
159  */
160  /**
161  * Reboot the GNSS measurement engine (GNSS receiver), in addition to
162  * performing any other requested resets (e.g., @ref RESET_EPHEMERIS). If no
163  * other resets are specified, the GNSS receiver will reboot and should
164  * perform a hot start.
165  */
166  static constexpr uint32_t REBOOT_GNSS_MEASUREMENT_ENGINE = 0x01000000;
167  /** Reboot the navigation processor. */
168  static constexpr uint32_t REBOOT_NAVIGATION_PROCESSOR = 0x02000000;
169  /**
170  * Perform a diagnostic log reset to guarantee deterministic performance for
171  * data post-processing and diagnostic support.
172  *
173  * Diagnostic log resets are useful when capturing data to be sent to Point
174  * One for analysis and support. Performing a diagnostic reset guarantees that
175  * the performance of the device seen in real time can be reproduced during
176  * post-processing.
177  *
178  * This reset performs the following:
179  * - Restart the navigation engine (@ref RESTART_NAVIGATION_ENGINE)
180  * - Clear any stored data in RAM that was received since startup such as
181  * ephemeris or GNSS corrections
182  * - This is _not_ the same as @ref RESET_EPHEMERIS; this action does not
183  * reset ephemeris data stored in persistent storage
184  * - Flush internal data buffers on the device
185  *
186  * Note that this does _not_ reset the navigation engine's position data,
187  * training parameters, or calibration. If the navigation engine has existing
188  * position information, it will be used.
189  *
190  * This reset may be combined with other resets as needed to clear additional
191  * information.
192  */
193  static constexpr uint32_t DIAGNOSTIC_LOG_RESET = 0x04000000;
194  /** @} */
195 
196  /**
197  * @name Device Reset Bitmasks
198  * @{
199  */
200  /**
201  * Perform a device hot start.
202  *
203  * This will reset the navigation engine into a known state, using previously
204  * stored position and time information. The device will begin navigating
205  * immediately if possible.
206  *
207  * To be reset:
208  * - The navigation engine (@ref RESTART_NAVIGATION_ENGINE)
209  *
210  * Not reset/performed:
211  * - All runtime data (GNSS corrections (@ref RESET_GNSS_CORRECTIONS), etc.)
212  * - Position, velocity, orientation (@ref RESET_POSITION_DATA)
213  * - GNSS ephemeris data (@ref RESET_EPHEMERIS)
214  * - Fast IMU corrections (@ref RESET_FAST_IMU_CORRECTIONS)
215  * - Training parameters (slowly estimated IMU corrections, temperature
216  * compensation, etc.; @ref RESET_NAVIGATION_ENGINE_DATA)
217  * - Calibration data (@ref RESET_CALIBRATION_DATA)
218  * - User configuration settings (@ref RESET_CONFIG)
219  * - Reboot GNSS measurement engine (@ref REBOOT_GNSS_MEASUREMENT_ENGINE)
220  * - Reboot navigation processor (@ref REBOOT_NAVIGATION_PROCESSOR)
221  */
222  static constexpr uint32_t HOT_START = 0x00000001;
223 
224  /**
225  * Perform a device warm start.
226  *
227  * During a warm start, the device retains its knowledge of approximate
228  * position and time, plus almanac data if available, but resets all ephemeris
229  * data. As a result, the device will need to download ephemeris data before
230  * continuing to navigate with GNSS.
231  *
232  * To be reset:
233  * - The navigation engine (i.e., perform a hot start, @ref
234  * RESTART_NAVIGATION_ENGINE)
235  * - GNSS ephemeris data (@ref RESET_EPHEMERIS)
236  *
237  * Not reset/performed:
238  * - All runtime data (GNSS corrections (@ref RESET_GNSS_CORRECTIONS), etc.)
239  * - Position, velocity, orientation (@ref RESET_POSITION_DATA)
240  * - Fast IMU corrections (@ref RESET_FAST_IMU_CORRECTIONS)
241  * - Training parameters (slowly estimated IMU corrections, temperature
242  * compensation, etc.; @ref RESET_NAVIGATION_ENGINE_DATA)
243  * - Calibration data (@ref RESET_CALIBRATION_DATA)
244  * - User configuration settings (@ref RESET_CONFIG)
245  * - Reboot GNSS measurement engine (@ref REBOOT_GNSS_MEASUREMENT_ENGINE)
246  * - Reboot navigation processor (@ref REBOOT_NAVIGATION_PROCESSOR)
247  */
248  static constexpr uint32_t WARM_START = 0x00000201;
249 
250  /**
251  * Perform a PVT reset: reset all position, velocity, orientation, and time
252  * information (i.e., the navigation engine's kinematic state).
253  *
254  * A PVT reset is typically used to reset the kinematic portion of the
255  * navigation engine's state if you are experiencing errors on startup or
256  * after a @ref HOT_START.
257  *
258  * To be reset:
259  * - The navigation engine (@ref RESTART_NAVIGATION_ENGINE)
260  * - All runtime data (GNSS corrections (@ref RESET_GNSS_CORRECTIONS), etc.)
261  * - Position, velocity, orientation (@ref RESET_POSITION_DATA)
262  *
263  * Not reset/performed:
264  * - GNSS ephemeris data (@ref RESET_EPHEMERIS)
265  * - Fast IMU corrections (@ref RESET_FAST_IMU_CORRECTIONS)
266  * - Training parameters (slowly estimated IMU corrections, temperature
267  * compensation, etc.; @ref RESET_NAVIGATION_ENGINE_DATA)
268  * - Calibration data (@ref RESET_CALIBRATION_DATA)
269  * - User configuration settings (@ref RESET_CONFIG)
270  * - Reboot GNSS measurement engine (@ref REBOOT_GNSS_MEASUREMENT_ENGINE)
271  * - Reboot navigation processor (@ref REBOOT_NAVIGATION_PROCESSOR)
272  */
273  static constexpr uint32_t PVT_RESET = 0x000001FF;
274 
275  /**
276  * Perform a device cold start.
277  *
278  * A cold start is typically used to reset the device's state estimate in the
279  * case of error that cannot be resolved by a @ref WARM_START.
280  *
281  * To be reset:
282  * - The navigation engine (@ref RESTART_NAVIGATION_ENGINE)
283  * - All runtime data (GNSS corrections (@ref RESET_GNSS_CORRECTIONS), etc.)
284  * - Position, velocity, orientation (@ref RESET_POSITION_DATA)
285  * - GNSS ephemeris data (@ref RESET_EPHEMERIS)
286  * - Fast IMU corrections (@ref RESET_FAST_IMU_CORRECTIONS)
287  *
288  * Not reset/performed:
289  * - Training parameters (slowly estimated IMU corrections, temperature
290  * compensation, etc.; @ref RESET_NAVIGATION_ENGINE_DATA)
291  * - Calibration data (@ref RESET_CALIBRATION_DATA)
292  * - User configuration settings (@ref RESET_CONFIG)
293  * - Reboot GNSS measurement engine (@ref REBOOT_GNSS_MEASUREMENT_ENGINE)
294  * - Reboot navigation processor (@ref REBOOT_NAVIGATION_PROCESSOR)
295  *
296  * @note
297  * To reset training or calibration data as well, set the @ref
298  * RESET_NAVIGATION_ENGINE_DATA and @ref RESET_CALIBRATION_DATA bits.
299  */
300  static constexpr uint32_t COLD_START = 0x00000FFF;
301 
302  /**
303  * Restart mask to set all persistent data, including calibration and user
304  * configuration, back to factory defaults.
305  */
306  static constexpr uint32_t FACTORY_RESET = 0xFFFFFFFF;
307  /** @} */
308 
309  /** Bit mask of functionality to reset. */
310  uint32_t reset_mask = 0;
311 };
312 
313 /**
314  * @brief Software version information, (@ref
315  * MessageType::VERSION_INFO, version 1.0).
316  * @ingroup config_and_ctrl_messages
317  *
318  * This message contains version strings for each of the following, where
319  * available:
320  * - Firmware - The current version of the platform software/firmware being used
321  * - Engine - The version of Point One FusionEngine being used
322  * - OS - The version of the operating system/kernel/bootloader being used
323  * - GNSS Receiver - The version of firmware being used by the device's GNSS
324  * receiver
325  *
326  * The message payload specifies the length of each string (in bytes). It is
327  * followed by each of the listed version strings consecutively. The strings are
328  * _not_ null terminated.
329  *
330  * ```
331  * {MessageHeader, VersionInfoMessage, "Firmware Version", "Engine Version",
332  * "OS Version", "Receiver Version"}
333  * ```
334  */
336  static constexpr MessageType MESSAGE_TYPE = MessageType::VERSION_INFO;
337  static constexpr uint8_t MESSAGE_VERSION = 0;
338 
339  /** The current system timestamp (in ns).*/
340  int64_t system_time_ns = 0;
341 
342  /** The length of the firmware version string (in bytes). */
343  uint8_t fw_version_length = 0;
344 
345  /** The length of the FusionEngine version string (in bytes). */
346  uint8_t engine_version_length = 0;
347 
348  /** The length of the OS version string (in bytes). */
349  uint8_t os_version_length = 0;
350 
351  /** The length of the GNSS receiver version string (in bytes). */
352  uint8_t rx_version_length = 0;
353 
354  uint8_t reserved[4] = {0};
355 
356  /**
357  * The beginning of the firmware version string.
358  *
359  * All other version strings follow immediately after this one in the data
360  * buffer. For example, the FusionEngine version string can be obtained as
361  * follows:
362  * ```cpp
363  * std::string engine_version_str(
364  * fw_version_str + message.fw_version_length,
365  * message.engine_version_length);
366  * ```
367  */
368  //char fw_version_str[0];
369 };
370 
371 /**
372  * @brief Identifies a FusionEngine device.
373  * @ingroup config_and_ctrl_messages
374  */
375 enum class DeviceType : uint8_t {
376  /** Unable to map device to a defined entry. */
377  UNKNOWN = 0,
378  /** Device is a Point One Atlas. */
379  ATLAS = 1,
380  /** Device is a Quectel LG69T-AM system. */
381  LG69T_AM = 2,
382  /** Device is a Quectel LG69T-AP system. */
383  LG69T_AP = 3,
384  /** Device is a Quectel LG69T-AH system. */
385  LG69T_AH = 4,
386 };
387 
388 /**
389  * @brief Get a human-friendly string name for the specified @ref DeviceType.
390  * @ingroup config_and_ctrl_messages
391  *
392  * @param val The enum to get the string name for.
393  *
394  * @return The corresponding string name.
395  */
397  switch (val) {
398  case DeviceType::UNKNOWN:
399  return "Unknown";
400  case DeviceType::ATLAS:
401  return "ATLAS";
403  return "LG69T_AM";
405  return "LG69T_AP";
407  return "LG69T_AH";
408  }
409  return "Unrecognized";
410 }
411 
412 /**
413  * @brief @ref DeviceType stream operator.
414  * @ingroup measurement_messages
415  */
417  stream << to_string(val) << " (" << (int)val << ")";
418  return stream;
419 }
420 
421 /**
422  * @brief Device identifier information (@ref MessageType::DEVICE_ID, version
423  * 1.0).
424  * @ingroup config_and_ctrl_messages
425  *
426  * This message contains ID data for each of the following, where available:
427  * - HW - A unique ROM identifier pulled from the device HW (for example, a CPU
428  * serial number)
429  * - User - A value set by the user to identify a device
430  * - Receiver - A unique ROM identifier pulled from the GNSS receiver
431  *
432  * The message payload specifies the length of each string (in bytes). It is
433  * followed by each of the listed IDs consecutively. The values are _not_ null
434  * terminated and the way each field is populated (strings or binary) depends on
435  * the type of device, indicated by @ref device_type.
436  *
437  * ```
438  * {MessageHeader, VersionInfoMessage, "HW ID", "User ID", "Receiver ID"}
439  * ```
440  */
442  static constexpr MessageType MESSAGE_TYPE = MessageType::DEVICE_ID;
443  static constexpr uint8_t MESSAGE_VERSION = 0;
444 
445  /** The current system timestamp (in ns).*/
446  int64_t system_time_ns = 0;
447 
448  /** The type of device this message originated from.*/
450 
451  /** The length of the HW ID (in bytes). */
452  uint8_t hw_id_length = 0;
453 
454  /** The length of the user specified ID (in bytes). */
455  uint8_t user_id_length = 0;
456 
457  /** The length of the GNSS receiver ID (in bytes). */
458  uint8_t receiver_id_length = 0;
459 
460  uint8_t reserved[4] = {0};
461 
462  /**
463  * The beginning of the hw ID data.
464  *
465  * All other ID strings follow immediately after this one in the data buffer.
466  * For example, the user ID can be obtained as follows:
467  * ```cpp
468  * std::vector<uint8_t> user_id_data(
469  * hw_id_data + message.hw_id_length,
470  * hw_id_data + message.hw_id_length + message.user_id_length);
471  * ```
472  */
473  //uint8_t hw_id_data[0];
474 };
475 
476 /**
477  * @brief Notification of a system event for logging purposes (@ref
478  * MessageType::EVENT_NOTIFICATION, version 1.0).
479  * @ingroup config_and_ctrl_messages
480  */
482  enum class EventType : uint8_t {
483  /**
484  * Event containing a logged message string from the device.
485  */
486  LOG = 0,
487  /**
488  * Event indicating a device reset occurred. The event flags will be set to
489  * the requested reset bitmask, if applicable (see @ref ResetRequest). The
490  * payload will contain a string describing the cause of the reset.
491  */
492  RESET = 1,
493  /**
494  * Notification that the user configuration has been changed. Intended for
495  * diagnostic purposes.
496  */
497  CONFIG_CHANGE = 2,
498  /**
499  * Notification that the user performed a command (e.g., configuration
500  * request, fault injection enable/disable).
501  */
502  COMMAND = 3,
503  /**
504  * Record containing the response to a user command. Response events are not
505  * output on the interface on which the command was received; that interface
506  * will receive the response itself.
507  */
508  COMMAND_RESPONSE = 4,
509  };
510 
511  static P1_CONSTEXPR_FUNC const char* to_string(EventType type) {
512  switch (type) {
513  case EventType::LOG:
514  return "Log";
515 
516  case EventType::RESET:
517  return "Reset";
518 
519  case EventType::CONFIG_CHANGE:
520  return "Config Change";
521 
522  case EventType::COMMAND:
523  return "Command";
524 
525  case EventType::COMMAND_RESPONSE:
526  return "Command Response";
527 
528  default:
529  return "Unknown";
530  }
531  }
532 
533  static constexpr MessageType MESSAGE_TYPE = MessageType::EVENT_NOTIFICATION;
534  static constexpr uint8_t MESSAGE_VERSION = 0;
535 
536  /** The type of event that occurred. */
538 
539  uint8_t reserved1[3] = {0};
540 
541  /** The current system timestamp (in ns).*/
542  int64_t system_time_ns = 0;
543 
544  /** A bitmask of flags associated with the event. */
545  uint64_t event_flags = 0;
546 
547  /** The number of bytes in the event description string. */
548  uint16_t event_description_len_bytes = 0;
549 
550  uint8_t reserved2[2] = {0};
551 
552  /**
553  * This is a dummy entry to provide a pointer to this offset.
554  *
555  * This is used for populating string describing the event, or other binary
556  * content where applicable.
557  */
558  //char* event_description[0];
559 };
560 
561 /**
562  * @brief Perform a device shutdown (@ref
563  * MessageType::SHUTDOWN_REQUEST, version 1.0).
564  * @ingroup config_and_ctrl_messages
565  *
566  * # Expected Response
567  * The device will respond with a @ref CommandResponseMessage indicating whether
568  * or not the request succeeded.
569  */
571  static constexpr MessageType MESSAGE_TYPE = MessageType::SHUTDOWN_REQUEST;
572  static constexpr uint8_t MESSAGE_VERSION = 0;
573  /** A bitmask of flags associated with the event. */
574  uint64_t shutdown_flags = 0;
575  uint8_t reserved1[8] = {0};
576 };
577 
578 /**
579  * @brief Start up a device (@ref
580  * MessageType::STARTUP_REQUEST, version 1.0).
581  * @ingroup config_and_ctrl_messages
582  *
583  * # Expected Response
584  * The device will respond with a @ref CommandResponseMessage indicating whether
585  * or not the request succeeded.
586  */
588  static constexpr MessageType MESSAGE_TYPE = MessageType::STARTUP_REQUEST;
589  static constexpr uint8_t MESSAGE_VERSION = 0;
590  /** A bitmask of flags associated with the event. */
591  uint64_t startup_flags = 0;
592  uint8_t reserved1[8] = {0};
593 };
594 
595 #pragma pack(pop)
596 
597 } // namespace messages
598 } // namespace fusion_engine
599 } // namespace point_one
MessageType
Identifiers for the defined output message types.
Definition: defs.h:34
Library portability helper definitions.
@ OK
Request transmission of a specified message type, (MessageType::MESSAGE_REQUEST, version 1....
Definition: control.h:73
Start up a device (MessageType::STARTUP_REQUEST, version 1.0).
Definition: control.h:587
@ COMMAND_RESPONSE
CommandResponseMessage
#define P1_ALIGNAS(N)
Definition: portability.h:57
@ DEVICE_ID
DeviceIDMessage
@ SHUTDOWN_REQUEST
ShutdownRequest
DeviceType
Identifies a FusionEngine device.
Definition: control.h:375
@ INVALID
Invalid message type.
Software version information, (MessageType::VERSION_INFO, version 1.0).
Definition: control.h:335
@ ATLAS
Device is a Point One Atlas.
Notification of a system event for logging purposes (MessageType::EVENT_NOTIFICATION,...
Definition: control.h:481
The base class for all message payloads.
Definition: defs.h:610
@ LG69T_AH
Device is a Quectel LG69T-AH system.
@ RESET_REQUEST
ResetRequest
static P1_CONSTEXPR_FUNC const char * to_string(EventType type)
Definition: control.h:511
@ VERSION_INFO
VersionInfoMessage
GNSS signal and frequency type definitions.
Definition: logging.h:38
P1_CONSTEXPR_FUNC const char * to_string(ConfigType type)
Get a human-friendly string name for the specified ConfigType.
Perform a software or hardware reset (MessageType::RESET_REQUEST, version 1.0).
Definition: control.h:95
@ UNKNOWN
Unable to map device to a defined entry.
std::ostream p1_ostream
Definition: portability.h:75
EventType
Definition: control.h:482
Response
Command response status indicators.
Definition: defs.h:335
p1_ostream & operator<<(p1_ostream &stream, ConfigType type)
ConfigType stream operator.
@ LG69T_AP
Device is a Quectel LG69T-AP system.
#define P1_CONSTEXPR_FUNC
Definition: portability.h:105
#define LOG(severity)
Definition: logging.h:77
Response to indicate if command was processed successfully (MessageType::COMMAND_RESPONSE,...
Definition: control.h:42
@ LG69T_AM
Device is a Quectel LG69T-AM system.
Perform a device shutdown (MessageType::SHUTDOWN_REQUEST, version 1.0).
Definition: control.h:570
Point One FusionEngine output message common definitions.
@ EVENT_NOTIFICATION
EventNotificationMessage
@ STARTUP_REQUEST
StartupRequest
Device identifier information (MessageType::DEVICE_ID, version 1.0).
Definition: control.h:441
@ MESSAGE_REQUEST
MessageRequest