device.h
Go to the documentation of this file.
1 /**************************************************************************/ /**
2  * @brief Device status 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 device_status Device Status/Information Messages
23  * @brief Messages for indicating high-level device status (notifications,
24  * software version, etc.).
25  * @ingroup messages
26  * @ingroup config_and_ctrl_messages
27  *
28  * See also @ref messages and @ref config_and_ctrl_messages.
29  ******************************************************************************/
30 
31 /**
32  * @brief Software version information, (@ref
33  * MessageType::VERSION_INFO, version 1.0).
34  * @ingroup device_status
35  *
36  * This message contains version strings for each of the following, where
37  * available:
38  * - Firmware - The current version of the platform software/firmware being used
39  * - Engine - The version of Point One FusionEngine being used
40  * - OS - The version of the operating system/kernel/bootloader being used
41  * - GNSS Receiver - The version of firmware being used by the device's GNSS
42  * receiver
43  *
44  * The message payload specifies the length of each string (in bytes). It is
45  * followed by each of the listed version strings consecutively. The strings are
46  * _not_ null-terminated.
47  *
48  * ```
49  * {MessageHeader, VersionInfoMessage, "Firmware Version", "Engine Version",
50  * "OS Version", "Receiver Version"}
51  * ```
52  *
53  * The following is an example of extracting the firmware and engine version
54  * strings from a byte array containing the entire message:
55  * ```cpp
56  * auto message = *reinterpret_cast<const VersionInfoMessage*>(buffer);
57  * buffer += sizeof(VersionInfoMessage);
58  * std::string fw_version(buffer, message.fw_version_length);
59  * buffer += message.fw_version_length;
60  * std::string engine_version(buffer, message.engine_version_length);
61  * ```
62  */
64  static constexpr MessageType MESSAGE_TYPE = MessageType::VERSION_INFO;
65  static constexpr uint8_t MESSAGE_VERSION = 0;
66 
67  /** The current system timestamp (in ns).*/
68  int64_t system_time_ns = 0;
69 
70  /** The length of the firmware version string (in bytes). */
71  uint8_t fw_version_length = 0;
72 
73  /** The length of the FusionEngine version string (in bytes). */
74  uint8_t engine_version_length = 0;
75 
76  /** The length of the OS version string (in bytes). */
77  uint8_t os_version_length = 0;
78 
79  /** The length of the GNSS receiver version string (in bytes). */
80  uint8_t rx_version_length = 0;
81 
82  uint8_t reserved[4] = {0};
83 };
84 
85 /**
86  * @brief Identifies a FusionEngine device.
87  * @ingroup device_status
88  */
89 enum class DeviceType : uint8_t {
90  /** Unable to map device to a defined entry. */
91  UNKNOWN = 0,
92  /** Point One Atlas. */
93  ATLAS = 1,
94  /** Quectel LG69T-AM system. */
95  LG69T_AM = 2,
96  /** Quectel LG69T-AP system. */
97  LG69T_AP = 3,
98  /** Quectel LG69T-AH system. */
99  LG69T_AH = 4,
100  /** Nexar Beam2K system. */
101  NEXAR_BEAM2K = 5,
102  /** Point One SSR client running on an LG69T platform. */
103  SSR_LG69T = 6,
104  /** Point One SSR client running on a desktop platform. */
105  SSR_DESKTOP = 7,
106 };
107 
108 /**
109  * @brief Get a human-friendly string name for the specified @ref DeviceType.
110  * @ingroup device_status
111  *
112  * @param val The enum to get the string name for.
113  *
114  * @return The corresponding string name.
115  */
117  switch (val) {
118  case DeviceType::UNKNOWN:
119  return "Unknown";
120  case DeviceType::ATLAS:
121  return "ATLAS";
123  return "LG69T_AM";
125  return "LG69T_AP";
127  return "LG69T_AH";
129  return "NEXAR_BEAM2K";
131  return "SSR_LG69T";
133  return "SSR_DESKTOP";
134  }
135  return "Unrecognized";
136 }
137 
138 /**
139  * @brief @ref DeviceType stream operator.
140  * @ingroup measurement_messages
141  */
143  stream << to_string(val) << " (" << (int)val << ")";
144  return stream;
145 }
146 
147 /**
148  * @brief Device identifier information (@ref MessageType::DEVICE_ID, version
149  * 1.0).
150  * @ingroup device_status
151  *
152  * This message contains ID fields for each of the following, where applicable.
153  * - Hardware - A unique ROM identifier pulled from the device hardware (for
154  * example, a CPU serial number)
155  * - User - A value set by the user to identify a device
156  * - Receiver - A unique ROM identifier pulled from the GNSS receiver
157  *
158  * The message payload specifies the length of each field (in bytes), and is
159  * followed by each of the ID values. ID values may be strings or binary,
160  * depending on the type of device (@ref device_type). Strings are _not_
161  * null-terminated.
162  *
163  * ```
164  * {MessageHeader, DeviceIDMessage, "HW ID", "User ID", "Receiver ID"}
165  * ```
166  *
167  * The following is an example of extracting the hardware and user IDs from a
168  * byte array containing the entire message (assuming both are strings for this
169  * example device):
170  * ```cpp
171  * auto message = *reinterpret_cast<const DeviceIDMessage*>(buffer);
172  * buffer += sizeof(DeviceIDMessage);
173  * std::string hw_id(buffer, message.hw_id_length);
174  * buffer += message.hw_id_length;
175  * std::string user_id(buffer, message.user_id_length);
176  * ```
177  */
179  static constexpr MessageType MESSAGE_TYPE = MessageType::DEVICE_ID;
180  static constexpr uint8_t MESSAGE_VERSION = 0;
181 
182  /** The current system timestamp (in ns).*/
183  int64_t system_time_ns = 0;
184 
185  /** The type of device this message originated from.*/
187 
188  /** The length of the harware ID (in bytes). */
189  uint8_t hw_id_length = 0;
190 
191  /** The length of the user specified ID (in bytes). */
192  uint8_t user_id_length = 0;
193 
194  /** The length of the GNSS receiver ID (in bytes). */
195  uint8_t receiver_id_length = 0;
196 
197  uint8_t reserved[4] = {0};
198 };
199 
200 /**
201  * @brief Notification of a system event for logging purposes (@ref
202  * MessageType::EVENT_NOTIFICATION, version 1.0).
203  * @ingroup device_status
204  *
205  * This message is followed by a string describing the event or additional
206  * binary content, depending on the type of event. The length of the description
207  * is @ref event_description_len_bytes. Strings are _not_ null-terminated.
208  *
209  * ```
210  * {MessageHeader, EventNotificationMessage, "Description"}
211  * ```
212  */
214  enum class EventType : uint8_t {
215  /**
216  * Event containing a logged message string from the device.
217  */
218  LOG = 0,
219  /**
220  * Event indicating a device reset occurred. The event flags will be set to
221  * the requested reset bitmask, if applicable (see @ref ResetRequest). The
222  * payload will contain a string describing the cause of the reset.
223  */
224  RESET = 1,
225  /**
226  * Notification that the user configuration has been changed. Intended for
227  * diagnostic purposes.
228  */
229  CONFIG_CHANGE = 2,
230  /**
231  * Notification that the user performed a command (e.g., configuration
232  * request, fault injection enable/disable).
233  */
234  COMMAND = 3,
235  /**
236  * Record containing the response to a user command. Response events are not
237  * output on the interface on which the command was received; that interface
238  * will receive the response itself.
239  */
240  COMMAND_RESPONSE = 4,
241  };
242 
243  static P1_CONSTEXPR_FUNC const char* to_string(EventType type) {
244  switch (type) {
245  case EventType::LOG:
246  return "Log";
247 
248  case EventType::RESET:
249  return "Reset";
250 
251  case EventType::CONFIG_CHANGE:
252  return "Config Change";
253 
254  case EventType::COMMAND:
255  return "Command";
256 
257  case EventType::COMMAND_RESPONSE:
258  return "Command Response";
259 
260  default:
261  return "Unknown";
262  }
263  }
264 
265  static constexpr MessageType MESSAGE_TYPE = MessageType::EVENT_NOTIFICATION;
266  static constexpr uint8_t MESSAGE_VERSION = 0;
267 
268  /** The type of event that occurred. */
270 
271  uint8_t reserved1[3] = {0};
272 
273  /** The system time when the event occurred (in ns).*/
274  int64_t system_time_ns = 0;
275 
276  /** A bitmask of flags associated with the event. */
277  uint64_t event_flags = 0;
278 
279  /** The number of bytes in the event description string. */
280  uint16_t event_description_len_bytes = 0;
281 
282  uint8_t reserved2[2] = {0};
283 };
284 
285 /**
286  * @brief System status information (@ref
287  * MessageType::SYSTEM_STATUS, version 1.0).
288  * @ingroup device_status
289  */
290 
292  static constexpr MessageType MESSAGE_TYPE = MessageType::SYSTEM_STATUS;
293  static constexpr uint8_t MESSAGE_VERSION = 0;
294 
295  static constexpr int16_t INVALID_TEMPERATURE = INT16_MAX;
296 
297  /** The time of the message, in P1 time (beginning at power-on). */
299 
300  /**
301  * The temperature of the GNSS receiver (in deg Celcius * 2^-7). Set to
302  * 0x7FFF if invalid.
303  */
304  int16_t gnss_temperature = INVALID_TEMPERATURE;
305 
306  uint8_t reserved[118] = {0};
307 };
308 
309 #pragma pack(pop)
310 
311 } // namespace messages
312 } // namespace fusion_engine
313 } // namespace point_one
Timestamp p1_time
The time of the message, in P1 time (beginning at power-on).
Definition: device.h:298
MessageType
Identifiers for the defined output message types.
Definition: defs.h:34
Library portability helper definitions.
P1_CONSTEXPR_FUNC const char * to_string(ConfigType type)
Get a human-friendly string name for the specified ConfigType.
@ COMMAND_RESPONSE
CommandResponseMessage
#define P1_ALIGNAS(N)
Definition: portability.h:57
@ DEVICE_ID
DeviceIDMessage
@ SYSTEM_STATUS
SystemStatusMessage
Software version information, (MessageType::VERSION_INFO, version 1.0).
Definition: device.h:63
Notification of a system event for logging purposes (MessageType::EVENT_NOTIFICATION,...
Definition: device.h:213
@ NEXAR_BEAM2K
Nexar Beam2K system.
The base class for all message payloads.
Definition: defs.h:687
@ SSR_DESKTOP
Point One SSR client running on a desktop platform.
@ SSR_LG69T
Point One SSR client running on an LG69T platform.
static P1_CONSTEXPR_FUNC const char * to_string(EventType type)
Definition: device.h:243
@ VERSION_INFO
VersionInfoMessage
@ LG69T_AP
Quectel LG69T-AP system.
GNSS signal and frequency type definitions.
Definition: logging.h:38
System status information (MessageType::SYSTEM_STATUS, version 1.0).
Definition: device.h:291
@ ATLAS
Point One Atlas.
std::ostream p1_ostream
Definition: portability.h:75
EventType
Definition: device.h:214
p1_ostream & operator<<(p1_ostream &stream, ConfigType type)
ConfigType stream operator.
#define P1_CONSTEXPR_FUNC
Definition: portability.h:105
#define LOG(severity)
Definition: logging.h:77
@ LG69T_AM
Quectel LG69T-AM system.
@ UNKNOWN
Unable to map device to a defined entry.
Point One FusionEngine output message common definitions.
@ EVENT_NOTIFICATION
EventNotificationMessage
Generic timestamp representation.
Definition: defs.h:588
@ LG69T_AH
Quectel LG69T-AH system.
Device identifier information (MessageType::DEVICE_ID, version 1.0).
Definition: device.h:178
DeviceType
Identifies a FusionEngine device.
Definition: device.h:89