fault_control.h
Go to the documentation of this file.
1 /**************************************************************************/ /**
2  * @brief System fault 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.
19 #pragma pack(push, 1)
20 
21 /**
22  * @defgroup fault_control_messages System Fault Control
23  * @brief Messages/types for controlling or simulating system faults.
24  * @ingroup config_and_ctrl_messages
25  */
26 
27 /**
28  * @brief Available fault types/control inputs.
29  * @ingroup fault_control_messages
30  *
31  * See @ref FaultControlMessage.
32  */
33 enum class FaultType : uint8_t {
34  /**
35  * Clear existing faults.
36  *
37  * @note
38  * This cannot be used to clear a @ref FaultType::CRASH or @ref
39  * FaultType::FATAL_ERROR.
40  *
41  * Payload format: none
42  */
43  CLEAR_ALL = 0,
44  /**
45  * Force the device to crash (intended for factory test purposes only).
46  *
47  * On crash, the device no longer produce any output on any interfaces, and
48  * will stop responding to commands. If the watchdog is enabled, the device
49  * will restart automatically after the watchdog timer elapses.
50  *
51  * @warning
52  * The device will crash immediately after receiving this request. It will not
53  * send a @ref CommandResponseMessage back to the user.
54  *
55  * Payload format: none
56  */
57  CRASH = 1,
58  /**
59  * Force the device to exhibit a fatal error (intended for factory test
60  * purposes only).
61  *
62  * After a fatal error, the device will stop navigating and will no longer
63  * produce solution messages on any interfaces. Instead, it will output an
64  * @ref EventNotificationMessage indicating the fault status. If the watchdog
65  * is enabled, the device will restart automatically after the watchdog timer
66  * elapses.
67  *
68  * Unlike @ref FaultType::CRASH, a fatal error will send an error notification
69  * to the user, but will still not send a @ref CommandResponseMessage.
70  *
71  * Payload format: none
72  */
73  FATAL_ERROR = 2,
74  /**
75  * Simulate a COCOM limit (intended for factory test purposes only).
76  *
77  * When a COCOM limit is exceeded, the device will stop navigating and will
78  * produce @ref SolutionType::Invalid solution messages. COCOM limits may be
79  * cleared via @ref ResetRequest, or by sending a @ref CoComType::NONE fault
80  * control.
81  *
82  * Payload format: @ref CoComType
83  */
84  COCOM = 3,
85  /**
86  * Enable/disable use of GNSS measurements (intended for dead reckoning
87  * performance testing).
88  *
89  * Payload format: `uint8_t` (0=disable, 1=enable)
90  */
91  ENABLE_GNSS = 4,
92  /**
93  * Simulate a region blackout (intended for factory test purposes only).
94  *
95  * Payload format: `uint8_t` (0=disable, 1=enable)
96  */
97  REGION_BLACKOUT = 5,
98  /**
99  * Enable/disable Quectel test features (intended for factory test purposes
100  * only).
101  *
102  * Payload format: `uint8_t` (0=disable, 1=enable)
103  */
104  QUECTEL_TEST = 6,
105  /**
106  * Simulate a specified integrity status failure (intended for factory test
107  * purposes only).
108  *
109  * Payload format: `uint8_t`
110  */
111  INTEGRITY_STATUS = 7,
112 };
113 
114 /**
115  * @brief Get a human-friendly string name for the specified @ref FaultType.
116  * @ingroup fault_control_messages
117  *
118  * @param type The desired fault type.
119  *
120  * @return The corresponding string name.
121  */
123  switch (type) {
125  return "Clear Faults";
126 
127  case FaultType::CRASH:
128  return "Crash";
129 
131  return "Fatal Error";
132 
133  case FaultType::COCOM:
134  return "COCOM";
135 
137  return "Enable GNSS";
138 
140  return "Region Blackout";
141 
143  return "Quectel Test";
144 
146  return "Integrity Status";
147  }
148  return "Unrecognized";
149 }
150 
151 /**
152  * @brief @ref ConfigurationSource stream operator.
153  * @ingroup fault_control_messages
154  */
155 inline p1_ostream& operator<<(p1_ostream& stream, FaultType type) {
156  stream << to_string(type) << " (" << (int)type << ")";
157  return stream;
158 }
159 
160 /**
161  * @brief The type of COCOM limit to be applied.
162  * @ingroup fault_control_messages
163  */
164 enum class CoComType : uint8_t {
165  /** Clear the current COCOM limit. */
166  NONE = 0,
167  /** Simulate a maximum acceleration limit. */
168  ACCELERATION = 1,
169  /** Simulate a maximum speed limit. */
170  SPEED = 2,
171  /** Simulate a maximum altitude limit. */
172  ALTITUDE = 3,
173 };
174 
175 /**
176  * @brief Get a human-friendly string name for the specified @ref CoComType.
177  * @ingroup fault_control_messages
178  *
179  * @param type The desired type.
180  *
181  * @return The corresponding string name.
182  */
184  switch (type) {
185  case CoComType::NONE:
186  return "No Limit";
188  return "Acceleration";
189  case CoComType::SPEED:
190  return "Speed";
191  case CoComType::ALTITUDE:
192  return "Altitude";
193  }
194  return "Unrecognized";
195 }
196 
197 /**
198  * @brief @ref CoComType stream operator.
199  * @ingroup fault_control_messages
200  */
201 inline p1_ostream& operator<<(p1_ostream& stream, CoComType type) {
202  stream << to_string(type) << " (" << (int)type << ")";
203  return stream;
204 }
205 
206 /**
207  * @brief Enable/disable a specified system fault (@ref
208  * MessageType::FAULT_CONTROL, version 1.0).
209  * @ingroup fault_control_messages
210  *
211  * This message is followed by an `N`-byte payload. The size and format of the
212  * payload are specified by the @ref fault_type. See @ref FaultType for details.
213  * For example, a message with a `uint8_t` payload will be serialized as
214  * follows:
215  *
216  * ```
217  * {MessageHeader, FaultControlMessage, uint8_t}
218  * ```
219  *
220  * # Expected Response
221  * The device will respond with a @ref CommandResponseMessage indicating whether
222  * or not the request succeeded.
223  */
225  static constexpr MessageType MESSAGE_TYPE = MessageType::FAULT_CONTROL;
226  static constexpr uint8_t MESSAGE_VERSION = 0;
227 
228  /** The type of fault/control to be performed. */
230 
231  uint8_t reserved[15] = {0};
232 
233  /** The size of the payload (in bytes). */
234  uint32_t payload_length_bytes = 0;
235 
236  // uint8_t payload[N];
237 };
238 
239 #pragma pack(pop)
240 
241 } // namespace messages
242 } // namespace fusion_engine
243 } // namespace point_one
MessageType
Identifiers for the defined output message types.
Definition: defs.h:34
Library portability helper definitions.
@ CRASH
Force the device to crash (intended for factory test purposes only).
P1_CONSTEXPR_FUNC const char * to_string(ConfigType type)
Get a human-friendly string name for the specified ConfigType.
@ ALTITUDE
Simulate a maximum altitude limit.
#define P1_ALIGNAS(N)
Definition: portability.h:57
@ FATAL_ERROR
Force the device to exhibit a fatal error (intended for factory test purposes only).
@ SPEED
Simulate a maximum speed limit.
@ NONE
Clear the current COCOM limit.
@ ENABLE_GNSS
Enable/disable use of GNSS measurements (intended for dead reckoning performance testing).
Enable/disable a specified system fault (MessageType::FAULT_CONTROL, version 1.0).
The base class for all message payloads.
Definition: defs.h:685
@ INTEGRITY_STATUS
Simulate a specified integrity status failure (intended for factory test purposes only).
@ REGION_BLACKOUT
Simulate a region blackout (intended for factory test purposes only).
GNSS signal and frequency type definitions.
Definition: logging.h:38
@ QUECTEL_TEST
Enable/disable Quectel test features (intended for factory test purposes only).
std::ostream p1_ostream
Definition: portability.h:75
p1_ostream & operator<<(p1_ostream &stream, ConfigType type)
ConfigType stream operator.
@ ACCELERATION
Simulate a maximum acceleration limit.
#define P1_CONSTEXPR_FUNC
Definition: portability.h:105
@ CLEAR_ALL
Clear existing faults.
@ COCOM
Simulate a COCOM limit (intended for factory test purposes only).
Point One FusionEngine output message common definitions.
FaultType
Available fault types/control inputs.
Definition: fault_control.h:33
CoComType
The type of COCOM limit to be applied.
@ FAULT_CONTROL
FaultControlMessage