[GYRO] Refactor gyro driver for dual-gyro support
[inav.git] / lib / main / MAVLink / common / mavlink_msg_statustext.h
blobe1ed320a3da33827a1e6f63bdfcacc294a104a28
1 #pragma once
2 // MESSAGE STATUSTEXT PACKING
4 #define MAVLINK_MSG_ID_STATUSTEXT 253
6 MAVPACKED(
7 typedef struct __mavlink_statustext_t {
8 uint8_t severity; /*< Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.*/
9 char text[50]; /*< Status text message, without null termination character*/
10 }) mavlink_statustext_t;
12 #define MAVLINK_MSG_ID_STATUSTEXT_LEN 51
13 #define MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN 51
14 #define MAVLINK_MSG_ID_253_LEN 51
15 #define MAVLINK_MSG_ID_253_MIN_LEN 51
17 #define MAVLINK_MSG_ID_STATUSTEXT_CRC 83
18 #define MAVLINK_MSG_ID_253_CRC 83
20 #define MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN 50
22 #if MAVLINK_COMMAND_24BIT
23 #define MAVLINK_MESSAGE_INFO_STATUSTEXT { \
24 253, \
25 "STATUSTEXT", \
26 2, \
27 { { "severity", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_statustext_t, severity) }, \
28 { "text", NULL, MAVLINK_TYPE_CHAR, 50, 1, offsetof(mavlink_statustext_t, text) }, \
29 } \
31 #else
32 #define MAVLINK_MESSAGE_INFO_STATUSTEXT { \
33 "STATUSTEXT", \
34 2, \
35 { { "severity", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_statustext_t, severity) }, \
36 { "text", NULL, MAVLINK_TYPE_CHAR, 50, 1, offsetof(mavlink_statustext_t, text) }, \
37 } \
39 #endif
41 /**
42 * @brief Pack a statustext message
43 * @param system_id ID of this system
44 * @param component_id ID of this component (e.g. 200 for IMU)
45 * @param msg The MAVLink message to compress the data into
47 * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
48 * @param text Status text message, without null termination character
49 * @return length of the message in bytes (excluding serial stream start sign)
51 static inline uint16_t mavlink_msg_statustext_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
52 uint8_t severity, const char *text)
54 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
55 char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN];
56 _mav_put_uint8_t(buf, 0, severity);
57 _mav_put_char_array(buf, 1, text, 50);
58 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUSTEXT_LEN);
59 #else
60 mavlink_statustext_t packet;
61 packet.severity = severity;
62 mav_array_memcpy(packet.text, text, sizeof(char)*50);
63 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUSTEXT_LEN);
64 #endif
66 msg->msgid = MAVLINK_MSG_ID_STATUSTEXT;
67 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC);
70 /**
71 * @brief Pack a statustext message on a channel
72 * @param system_id ID of this system
73 * @param component_id ID of this component (e.g. 200 for IMU)
74 * @param chan The MAVLink channel this message will be sent over
75 * @param msg The MAVLink message to compress the data into
76 * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
77 * @param text Status text message, without null termination character
78 * @return length of the message in bytes (excluding serial stream start sign)
80 static inline uint16_t mavlink_msg_statustext_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
81 mavlink_message_t* msg,
82 uint8_t severity,const char *text)
84 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
85 char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN];
86 _mav_put_uint8_t(buf, 0, severity);
87 _mav_put_char_array(buf, 1, text, 50);
88 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUSTEXT_LEN);
89 #else
90 mavlink_statustext_t packet;
91 packet.severity = severity;
92 mav_array_memcpy(packet.text, text, sizeof(char)*50);
93 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUSTEXT_LEN);
94 #endif
96 msg->msgid = MAVLINK_MSG_ID_STATUSTEXT;
97 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC);
101 * @brief Encode a statustext struct
103 * @param system_id ID of this system
104 * @param component_id ID of this component (e.g. 200 for IMU)
105 * @param msg The MAVLink message to compress the data into
106 * @param statustext C-struct to read the message contents from
108 static inline uint16_t mavlink_msg_statustext_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_statustext_t* statustext)
110 return mavlink_msg_statustext_pack(system_id, component_id, msg, statustext->severity, statustext->text);
114 * @brief Encode a statustext struct on a channel
116 * @param system_id ID of this system
117 * @param component_id ID of this component (e.g. 200 for IMU)
118 * @param chan The MAVLink channel this message will be sent over
119 * @param msg The MAVLink message to compress the data into
120 * @param statustext C-struct to read the message contents from
122 static inline uint16_t mavlink_msg_statustext_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_statustext_t* statustext)
124 return mavlink_msg_statustext_pack_chan(system_id, component_id, chan, msg, statustext->severity, statustext->text);
128 * @brief Send a statustext message
129 * @param chan MAVLink channel to send the message
131 * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
132 * @param text Status text message, without null termination character
134 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
136 static inline void mavlink_msg_statustext_send(mavlink_channel_t chan, uint8_t severity, const char *text)
138 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
139 char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN];
140 _mav_put_uint8_t(buf, 0, severity);
141 _mav_put_char_array(buf, 1, text, 50);
142 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, buf, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC);
143 #else
144 mavlink_statustext_t packet;
145 packet.severity = severity;
146 mav_array_memcpy(packet.text, text, sizeof(char)*50);
147 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, (const char *)&packet, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC);
148 #endif
152 * @brief Send a statustext message
153 * @param chan MAVLink channel to send the message
154 * @param struct The MAVLink struct to serialize
156 static inline void mavlink_msg_statustext_send_struct(mavlink_channel_t chan, const mavlink_statustext_t* statustext)
158 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
159 mavlink_msg_statustext_send(chan, statustext->severity, statustext->text);
160 #else
161 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, (const char *)statustext, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC);
162 #endif
165 #if MAVLINK_MSG_ID_STATUSTEXT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
167 This varient of _send() can be used to save stack space by re-using
168 memory from the receive buffer. The caller provides a
169 mavlink_message_t which is the size of a full mavlink message. This
170 is usually the receive buffer for the channel, and allows a reply to an
171 incoming message with minimum stack space usage.
173 static inline void mavlink_msg_statustext_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t severity, const char *text)
175 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
176 char *buf = (char *)msgbuf;
177 _mav_put_uint8_t(buf, 0, severity);
178 _mav_put_char_array(buf, 1, text, 50);
179 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, buf, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC);
180 #else
181 mavlink_statustext_t *packet = (mavlink_statustext_t *)msgbuf;
182 packet->severity = severity;
183 mav_array_memcpy(packet->text, text, sizeof(char)*50);
184 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, (const char *)packet, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC);
185 #endif
187 #endif
189 #endif
191 // MESSAGE STATUSTEXT UNPACKING
195 * @brief Get field severity from statustext message
197 * @return Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
199 static inline uint8_t mavlink_msg_statustext_get_severity(const mavlink_message_t* msg)
201 return _MAV_RETURN_uint8_t(msg, 0);
205 * @brief Get field text from statustext message
207 * @return Status text message, without null termination character
209 static inline uint16_t mavlink_msg_statustext_get_text(const mavlink_message_t* msg, char *text)
211 return _MAV_RETURN_char_array(msg, text, 50, 1);
215 * @brief Decode a statustext message into a struct
217 * @param msg The message to decode
218 * @param statustext C-struct to decode the message contents into
220 static inline void mavlink_msg_statustext_decode(const mavlink_message_t* msg, mavlink_statustext_t* statustext)
222 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
223 statustext->severity = mavlink_msg_statustext_get_severity(msg);
224 mavlink_msg_statustext_get_text(msg, statustext->text);
225 #else
226 uint8_t len = msg->len < MAVLINK_MSG_ID_STATUSTEXT_LEN? msg->len : MAVLINK_MSG_ID_STATUSTEXT_LEN;
227 memset(statustext, 0, MAVLINK_MSG_ID_STATUSTEXT_LEN);
228 memcpy(statustext, _MAV_PAYLOAD(msg), len);
229 #endif