Merge pull request #10476 from radiolinkW/RADIOLINKF722
[inav.git] / lib / main / MAVLink / common / mavlink_msg_statustext.h
blob28e0c0b0fd8568c59f4100e466f452217180083c
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.*/
9 char text[50]; /*< Status text message, without null termination character*/
10 uint16_t id; /*< Unique (opaque) identifier for this statustext message. May be used to reassemble a logical long-statustext message from a sequence of chunks. A value of zero indicates this is the only chunk in the sequence and the message can be emitted immediately.*/
11 uint8_t chunk_seq; /*< This chunk's sequence number; indexing is from zero. Any null character in the text field is taken to mean this was the last chunk.*/
12 }) mavlink_statustext_t;
14 #define MAVLINK_MSG_ID_STATUSTEXT_LEN 54
15 #define MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN 51
16 #define MAVLINK_MSG_ID_253_LEN 54
17 #define MAVLINK_MSG_ID_253_MIN_LEN 51
19 #define MAVLINK_MSG_ID_STATUSTEXT_CRC 83
20 #define MAVLINK_MSG_ID_253_CRC 83
22 #define MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN 50
24 #if MAVLINK_COMMAND_24BIT
25 #define MAVLINK_MESSAGE_INFO_STATUSTEXT { \
26 253, \
27 "STATUSTEXT", \
28 4, \
29 { { "severity", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_statustext_t, severity) }, \
30 { "text", NULL, MAVLINK_TYPE_CHAR, 50, 1, offsetof(mavlink_statustext_t, text) }, \
31 { "id", NULL, MAVLINK_TYPE_UINT16_T, 0, 51, offsetof(mavlink_statustext_t, id) }, \
32 { "chunk_seq", NULL, MAVLINK_TYPE_UINT8_T, 0, 53, offsetof(mavlink_statustext_t, chunk_seq) }, \
33 } \
35 #else
36 #define MAVLINK_MESSAGE_INFO_STATUSTEXT { \
37 "STATUSTEXT", \
38 4, \
39 { { "severity", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_statustext_t, severity) }, \
40 { "text", NULL, MAVLINK_TYPE_CHAR, 50, 1, offsetof(mavlink_statustext_t, text) }, \
41 { "id", NULL, MAVLINK_TYPE_UINT16_T, 0, 51, offsetof(mavlink_statustext_t, id) }, \
42 { "chunk_seq", NULL, MAVLINK_TYPE_UINT8_T, 0, 53, offsetof(mavlink_statustext_t, chunk_seq) }, \
43 } \
45 #endif
47 /**
48 * @brief Pack a statustext message
49 * @param system_id ID of this system
50 * @param component_id ID of this component (e.g. 200 for IMU)
51 * @param msg The MAVLink message to compress the data into
53 * @param severity Severity of status. Relies on the definitions within RFC-5424.
54 * @param text Status text message, without null termination character
55 * @param id Unique (opaque) identifier for this statustext message. May be used to reassemble a logical long-statustext message from a sequence of chunks. A value of zero indicates this is the only chunk in the sequence and the message can be emitted immediately.
56 * @param chunk_seq This chunk's sequence number; indexing is from zero. Any null character in the text field is taken to mean this was the last chunk.
57 * @return length of the message in bytes (excluding serial stream start sign)
59 static inline uint16_t mavlink_msg_statustext_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
60 uint8_t severity, const char *text, uint16_t id, uint8_t chunk_seq)
62 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
63 char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN];
64 _mav_put_uint8_t(buf, 0, severity);
65 _mav_put_uint16_t(buf, 51, id);
66 _mav_put_uint8_t(buf, 53, chunk_seq);
67 _mav_put_char_array(buf, 1, text, 50);
68 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUSTEXT_LEN);
69 #else
70 mavlink_statustext_t packet;
71 packet.severity = severity;
72 packet.id = id;
73 packet.chunk_seq = chunk_seq;
74 mav_array_memcpy(packet.text, text, sizeof(char)*50);
75 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUSTEXT_LEN);
76 #endif
78 msg->msgid = MAVLINK_MSG_ID_STATUSTEXT;
79 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);
82 /**
83 * @brief Pack a statustext message on a channel
84 * @param system_id ID of this system
85 * @param component_id ID of this component (e.g. 200 for IMU)
86 * @param chan The MAVLink channel this message will be sent over
87 * @param msg The MAVLink message to compress the data into
88 * @param severity Severity of status. Relies on the definitions within RFC-5424.
89 * @param text Status text message, without null termination character
90 * @param id Unique (opaque) identifier for this statustext message. May be used to reassemble a logical long-statustext message from a sequence of chunks. A value of zero indicates this is the only chunk in the sequence and the message can be emitted immediately.
91 * @param chunk_seq This chunk's sequence number; indexing is from zero. Any null character in the text field is taken to mean this was the last chunk.
92 * @return length of the message in bytes (excluding serial stream start sign)
94 static inline uint16_t mavlink_msg_statustext_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
95 mavlink_message_t* msg,
96 uint8_t severity,const char *text,uint16_t id,uint8_t chunk_seq)
98 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
99 char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN];
100 _mav_put_uint8_t(buf, 0, severity);
101 _mav_put_uint16_t(buf, 51, id);
102 _mav_put_uint8_t(buf, 53, chunk_seq);
103 _mav_put_char_array(buf, 1, text, 50);
104 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUSTEXT_LEN);
105 #else
106 mavlink_statustext_t packet;
107 packet.severity = severity;
108 packet.id = id;
109 packet.chunk_seq = chunk_seq;
110 mav_array_memcpy(packet.text, text, sizeof(char)*50);
111 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUSTEXT_LEN);
112 #endif
114 msg->msgid = MAVLINK_MSG_ID_STATUSTEXT;
115 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);
119 * @brief Encode a statustext struct
121 * @param system_id ID of this system
122 * @param component_id ID of this component (e.g. 200 for IMU)
123 * @param msg The MAVLink message to compress the data into
124 * @param statustext C-struct to read the message contents from
126 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)
128 return mavlink_msg_statustext_pack(system_id, component_id, msg, statustext->severity, statustext->text, statustext->id, statustext->chunk_seq);
132 * @brief Encode a statustext struct on a channel
134 * @param system_id ID of this system
135 * @param component_id ID of this component (e.g. 200 for IMU)
136 * @param chan The MAVLink channel this message will be sent over
137 * @param msg The MAVLink message to compress the data into
138 * @param statustext C-struct to read the message contents from
140 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)
142 return mavlink_msg_statustext_pack_chan(system_id, component_id, chan, msg, statustext->severity, statustext->text, statustext->id, statustext->chunk_seq);
146 * @brief Send a statustext message
147 * @param chan MAVLink channel to send the message
149 * @param severity Severity of status. Relies on the definitions within RFC-5424.
150 * @param text Status text message, without null termination character
151 * @param id Unique (opaque) identifier for this statustext message. May be used to reassemble a logical long-statustext message from a sequence of chunks. A value of zero indicates this is the only chunk in the sequence and the message can be emitted immediately.
152 * @param chunk_seq This chunk's sequence number; indexing is from zero. Any null character in the text field is taken to mean this was the last chunk.
154 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
156 static inline void mavlink_msg_statustext_send(mavlink_channel_t chan, uint8_t severity, const char *text, uint16_t id, uint8_t chunk_seq)
158 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
159 char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN];
160 _mav_put_uint8_t(buf, 0, severity);
161 _mav_put_uint16_t(buf, 51, id);
162 _mav_put_uint8_t(buf, 53, chunk_seq);
163 _mav_put_char_array(buf, 1, text, 50);
164 _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);
165 #else
166 mavlink_statustext_t packet;
167 packet.severity = severity;
168 packet.id = id;
169 packet.chunk_seq = chunk_seq;
170 mav_array_memcpy(packet.text, text, sizeof(char)*50);
171 _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);
172 #endif
176 * @brief Send a statustext message
177 * @param chan MAVLink channel to send the message
178 * @param struct The MAVLink struct to serialize
180 static inline void mavlink_msg_statustext_send_struct(mavlink_channel_t chan, const mavlink_statustext_t* statustext)
182 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
183 mavlink_msg_statustext_send(chan, statustext->severity, statustext->text, statustext->id, statustext->chunk_seq);
184 #else
185 _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);
186 #endif
189 #if MAVLINK_MSG_ID_STATUSTEXT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
191 This varient of _send() can be used to save stack space by re-using
192 memory from the receive buffer. The caller provides a
193 mavlink_message_t which is the size of a full mavlink message. This
194 is usually the receive buffer for the channel, and allows a reply to an
195 incoming message with minimum stack space usage.
197 static inline void mavlink_msg_statustext_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t severity, const char *text, uint16_t id, uint8_t chunk_seq)
199 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
200 char *buf = (char *)msgbuf;
201 _mav_put_uint8_t(buf, 0, severity);
202 _mav_put_uint16_t(buf, 51, id);
203 _mav_put_uint8_t(buf, 53, chunk_seq);
204 _mav_put_char_array(buf, 1, text, 50);
205 _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);
206 #else
207 mavlink_statustext_t *packet = (mavlink_statustext_t *)msgbuf;
208 packet->severity = severity;
209 packet->id = id;
210 packet->chunk_seq = chunk_seq;
211 mav_array_memcpy(packet->text, text, sizeof(char)*50);
212 _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);
213 #endif
215 #endif
217 #endif
219 // MESSAGE STATUSTEXT UNPACKING
223 * @brief Get field severity from statustext message
225 * @return Severity of status. Relies on the definitions within RFC-5424.
227 static inline uint8_t mavlink_msg_statustext_get_severity(const mavlink_message_t* msg)
229 return _MAV_RETURN_uint8_t(msg, 0);
233 * @brief Get field text from statustext message
235 * @return Status text message, without null termination character
237 static inline uint16_t mavlink_msg_statustext_get_text(const mavlink_message_t* msg, char *text)
239 return _MAV_RETURN_char_array(msg, text, 50, 1);
243 * @brief Get field id from statustext message
245 * @return Unique (opaque) identifier for this statustext message. May be used to reassemble a logical long-statustext message from a sequence of chunks. A value of zero indicates this is the only chunk in the sequence and the message can be emitted immediately.
247 static inline uint16_t mavlink_msg_statustext_get_id(const mavlink_message_t* msg)
249 return _MAV_RETURN_uint16_t(msg, 51);
253 * @brief Get field chunk_seq from statustext message
255 * @return This chunk's sequence number; indexing is from zero. Any null character in the text field is taken to mean this was the last chunk.
257 static inline uint8_t mavlink_msg_statustext_get_chunk_seq(const mavlink_message_t* msg)
259 return _MAV_RETURN_uint8_t(msg, 53);
263 * @brief Decode a statustext message into a struct
265 * @param msg The message to decode
266 * @param statustext C-struct to decode the message contents into
268 static inline void mavlink_msg_statustext_decode(const mavlink_message_t* msg, mavlink_statustext_t* statustext)
270 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
271 statustext->severity = mavlink_msg_statustext_get_severity(msg);
272 mavlink_msg_statustext_get_text(msg, statustext->text);
273 statustext->id = mavlink_msg_statustext_get_id(msg);
274 statustext->chunk_seq = mavlink_msg_statustext_get_chunk_seq(msg);
275 #else
276 uint8_t len = msg->len < MAVLINK_MSG_ID_STATUSTEXT_LEN? msg->len : MAVLINK_MSG_ID_STATUSTEXT_LEN;
277 memset(statustext, 0, MAVLINK_MSG_ID_STATUSTEXT_LEN);
278 memcpy(statustext, _MAV_PAYLOAD(msg), len);
279 #endif