RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_statustext.h
1#pragma once
2// MESSAGE STATUSTEXT PACKING
3
4#define MAVLINK_MSG_ID_STATUSTEXT 253
5
6MAVPACKED(
7typedef 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;
11
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
16
17#define MAVLINK_MSG_ID_STATUSTEXT_CRC 83
18#define MAVLINK_MSG_ID_253_CRC 83
19
20#define MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN 50
21
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 } \
30}
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 } \
38}
39#endif
40
51static 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)
53{
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
65
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);
68}
69
80static 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)
83{
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
95
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);
98}
99
108static inline uint16_t mavlink_msg_statustext_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_statustext_t* statustext)
109{
110 return mavlink_msg_statustext_pack(system_id, component_id, msg, statustext->severity, statustext->text);
111}
112
122static 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)
123{
124 return mavlink_msg_statustext_pack_chan(system_id, component_id, chan, msg, statustext->severity, statustext->text);
125}
126
134#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
135
136static inline void mavlink_msg_statustext_send(mavlink_channel_t chan, uint8_t severity, const char *text)
137{
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
149}
150
156static inline void mavlink_msg_statustext_send_struct(mavlink_channel_t chan, const mavlink_statustext_t* statustext)
157{
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
163}
164
165#if MAVLINK_MSG_ID_STATUSTEXT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
166/*
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.
172 */
173static inline void mavlink_msg_statustext_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t severity, const char *text)
174{
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
186}
187#endif
188
189#endif
190
191// MESSAGE STATUSTEXT UNPACKING
192
193
199static inline uint8_t mavlink_msg_statustext_get_severity(const mavlink_message_t* msg)
200{
201 return _MAV_RETURN_uint8_t(msg, 0);
202}
203
209static inline uint16_t mavlink_msg_statustext_get_text(const mavlink_message_t* msg, char *text)
210{
211 return _MAV_RETURN_char_array(msg, text, 50, 1);
212}
213
220static inline void mavlink_msg_statustext_decode(const mavlink_message_t* msg, mavlink_statustext_t* statustext)
221{
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
230}