Move telemetry displayport init and cms device registering
[betaflight.git] / lib / main / MAVLink / common / mavlink_msg_statustext.h
blobc8c2547b319fb32b686112e98f45dcb3b6315d68
1 // MESSAGE STATUSTEXT PACKING
3 #define MAVLINK_MSG_ID_STATUSTEXT 253
5 typedef struct __mavlink_statustext_t
7 uint8_t severity; ///< Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
8 char text[50]; ///< Status text message, without null termination character
9 } mavlink_statustext_t;
11 #define MAVLINK_MSG_ID_STATUSTEXT_LEN 51
12 #define MAVLINK_MSG_ID_253_LEN 51
14 #define MAVLINK_MSG_ID_STATUSTEXT_CRC 83
15 #define MAVLINK_MSG_ID_253_CRC 83
17 #define MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN 50
19 #define MAVLINK_MESSAGE_INFO_STATUSTEXT { \
20 "STATUSTEXT", \
21 2, \
22 { { "severity", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_statustext_t, severity) }, \
23 { "text", NULL, MAVLINK_TYPE_CHAR, 50, 1, offsetof(mavlink_statustext_t, text) }, \
24 } \
28 /**
29 * @brief Pack a statustext message
30 * @param system_id ID of this system
31 * @param component_id ID of this component (e.g. 200 for IMU)
32 * @param msg The MAVLink message to compress the data into
34 * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
35 * @param text Status text message, without null termination character
36 * @return length of the message in bytes (excluding serial stream start sign)
38 static inline uint16_t mavlink_msg_statustext_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
39 uint8_t severity, const char *text)
41 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
42 char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN];
43 _mav_put_uint8_t(buf, 0, severity);
44 _mav_put_char_array(buf, 1, text, 50);
45 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUSTEXT_LEN);
46 #else
47 mavlink_statustext_t packet;
48 packet.severity = severity;
49 mav_array_memcpy(packet.text, text, sizeof(char)*50);
50 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUSTEXT_LEN);
51 #endif
53 msg->msgid = MAVLINK_MSG_ID_STATUSTEXT;
54 #if MAVLINK_CRC_EXTRA
55 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC);
56 #else
57 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STATUSTEXT_LEN);
58 #endif
61 /**
62 * @brief Pack a statustext message on a channel
63 * @param system_id ID of this system
64 * @param component_id ID of this component (e.g. 200 for IMU)
65 * @param chan The MAVLink channel this message will be sent over
66 * @param msg The MAVLink message to compress the data into
67 * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
68 * @param text Status text message, without null termination character
69 * @return length of the message in bytes (excluding serial stream start sign)
71 static inline uint16_t mavlink_msg_statustext_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
72 mavlink_message_t* msg,
73 uint8_t severity,const char *text)
75 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
76 char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN];
77 _mav_put_uint8_t(buf, 0, severity);
78 _mav_put_char_array(buf, 1, text, 50);
79 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUSTEXT_LEN);
80 #else
81 mavlink_statustext_t packet;
82 packet.severity = severity;
83 mav_array_memcpy(packet.text, text, sizeof(char)*50);
84 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUSTEXT_LEN);
85 #endif
87 msg->msgid = MAVLINK_MSG_ID_STATUSTEXT;
88 #if MAVLINK_CRC_EXTRA
89 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC);
90 #else
91 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_STATUSTEXT_LEN);
92 #endif
95 /**
96 * @brief Encode a statustext struct
98 * @param system_id ID of this system
99 * @param component_id ID of this component (e.g. 200 for IMU)
100 * @param msg The MAVLink message to compress the data into
101 * @param statustext C-struct to read the message contents from
103 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)
105 return mavlink_msg_statustext_pack(system_id, component_id, msg, statustext->severity, statustext->text);
109 * @brief Encode a statustext struct on a channel
111 * @param system_id ID of this system
112 * @param component_id ID of this component (e.g. 200 for IMU)
113 * @param chan The MAVLink channel this message will be sent over
114 * @param msg The MAVLink message to compress the data into
115 * @param statustext C-struct to read the message contents from
117 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)
119 return mavlink_msg_statustext_pack_chan(system_id, component_id, chan, msg, statustext->severity, statustext->text);
123 * @brief Send a statustext message
124 * @param chan MAVLink channel to send the message
126 * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
127 * @param text Status text message, without null termination character
129 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
131 static inline void mavlink_msg_statustext_send(mavlink_channel_t chan, uint8_t severity, const char *text)
133 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
134 char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN];
135 _mav_put_uint8_t(buf, 0, severity);
136 _mav_put_char_array(buf, 1, text, 50);
137 #if MAVLINK_CRC_EXTRA
138 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, buf, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC);
139 #else
140 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, buf, MAVLINK_MSG_ID_STATUSTEXT_LEN);
141 #endif
142 #else
143 mavlink_statustext_t packet;
144 packet.severity = severity;
145 mav_array_memcpy(packet.text, text, sizeof(char)*50);
146 #if MAVLINK_CRC_EXTRA
147 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, (const char *)&packet, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC);
148 #else
149 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, (const char *)&packet, MAVLINK_MSG_ID_STATUSTEXT_LEN);
150 #endif
151 #endif
154 #if MAVLINK_MSG_ID_STATUSTEXT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
156 This varient of _send() can be used to save stack space by re-using
157 memory from the receive buffer. The caller provides a
158 mavlink_message_t which is the size of a full mavlink message. This
159 is usually the receive buffer for the channel, and allows a reply to an
160 incoming message with minimum stack space usage.
162 static inline void mavlink_msg_statustext_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t severity, const char *text)
164 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
165 char *buf = (char *)msgbuf;
166 _mav_put_uint8_t(buf, 0, severity);
167 _mav_put_char_array(buf, 1, text, 50);
168 #if MAVLINK_CRC_EXTRA
169 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, buf, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC);
170 #else
171 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, buf, MAVLINK_MSG_ID_STATUSTEXT_LEN);
172 #endif
173 #else
174 mavlink_statustext_t *packet = (mavlink_statustext_t *)msgbuf;
175 packet->severity = severity;
176 mav_array_memcpy(packet->text, text, sizeof(char)*50);
177 #if MAVLINK_CRC_EXTRA
178 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, (const char *)packet, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC);
179 #else
180 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, (const char *)packet, MAVLINK_MSG_ID_STATUSTEXT_LEN);
181 #endif
182 #endif
184 #endif
186 #endif
188 // MESSAGE STATUSTEXT UNPACKING
192 * @brief Get field severity from statustext message
194 * @return Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
196 static inline uint8_t mavlink_msg_statustext_get_severity(const mavlink_message_t* msg)
198 return _MAV_RETURN_uint8_t(msg, 0);
202 * @brief Get field text from statustext message
204 * @return Status text message, without null termination character
206 static inline uint16_t mavlink_msg_statustext_get_text(const mavlink_message_t* msg, char *text)
208 return _MAV_RETURN_char_array(msg, text, 50, 1);
212 * @brief Decode a statustext message into a struct
214 * @param msg The message to decode
215 * @param statustext C-struct to decode the message contents into
217 static inline void mavlink_msg_statustext_decode(const mavlink_message_t* msg, mavlink_statustext_t* statustext)
219 #if MAVLINK_NEED_BYTE_SWAP
220 statustext->severity = mavlink_msg_statustext_get_severity(msg);
221 mavlink_msg_statustext_get_text(msg, statustext->text);
222 #else
223 memcpy(statustext, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_STATUSTEXT_LEN);
224 #endif