source: flair-src/branches/mavlink/tools/Controller/Mavlink/src/include/common/mavlink_msg_statustext.h@ 75

Last change on this file since 75 was 75, checked in by Thomas Fuhrmann, 8 years ago

Change the version of mavlink generated messages and rename it to include

File size: 9.1 KB
Line 
1// MESSAGE STATUSTEXT PACKING
2
3#define MAVLINK_MSG_ID_STATUSTEXT 253
4
5typedef struct MAVLINK_PACKED __mavlink_statustext_t
6{
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;
10
11#define MAVLINK_MSG_ID_STATUSTEXT_LEN 51
12#define MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN 51
13#define MAVLINK_MSG_ID_253_LEN 51
14#define MAVLINK_MSG_ID_253_MIN_LEN 51
15
16#define MAVLINK_MSG_ID_STATUSTEXT_CRC 83
17#define MAVLINK_MSG_ID_253_CRC 83
18
19#define MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN 50
20
21#if MAVLINK_COMMAND_24BIT
22#define MAVLINK_MESSAGE_INFO_STATUSTEXT { \
23 253, \
24 "STATUSTEXT", \
25 2, \
26 { { "severity", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_statustext_t, severity) }, \
27 { "text", NULL, MAVLINK_TYPE_CHAR, 50, 1, offsetof(mavlink_statustext_t, text) }, \
28 } \
29}
30#else
31#define MAVLINK_MESSAGE_INFO_STATUSTEXT { \
32 "STATUSTEXT", \
33 2, \
34 { { "severity", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_statustext_t, severity) }, \
35 { "text", NULL, MAVLINK_TYPE_CHAR, 50, 1, offsetof(mavlink_statustext_t, text) }, \
36 } \
37}
38#endif
39
40/**
41 * @brief Pack a statustext message
42 * @param system_id ID of this system
43 * @param component_id ID of this component (e.g. 200 for IMU)
44 * @param msg The MAVLink message to compress the data into
45 *
46 * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
47 * @param text Status text message, without null termination character
48 * @return length of the message in bytes (excluding serial stream start sign)
49 */
50static inline uint16_t mavlink_msg_statustext_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
51 uint8_t severity, const char *text)
52{
53#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
54 char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN];
55 _mav_put_uint8_t(buf, 0, severity);
56 _mav_put_char_array(buf, 1, text, 50);
57 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUSTEXT_LEN);
58#else
59 mavlink_statustext_t packet;
60 packet.severity = severity;
61 mav_array_memcpy(packet.text, text, sizeof(char)*50);
62 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUSTEXT_LEN);
63#endif
64
65 msg->msgid = MAVLINK_MSG_ID_STATUSTEXT;
66 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);
67}
68
69/**
70 * @brief Pack a statustext message on a channel
71 * @param system_id ID of this system
72 * @param component_id ID of this component (e.g. 200 for IMU)
73 * @param chan The MAVLink channel this message will be sent over
74 * @param msg The MAVLink message to compress the data into
75 * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
76 * @param text Status text message, without null termination character
77 * @return length of the message in bytes (excluding serial stream start sign)
78 */
79static inline uint16_t mavlink_msg_statustext_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
80 mavlink_message_t* msg,
81 uint8_t severity,const char *text)
82{
83#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
84 char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN];
85 _mav_put_uint8_t(buf, 0, severity);
86 _mav_put_char_array(buf, 1, text, 50);
87 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUSTEXT_LEN);
88#else
89 mavlink_statustext_t packet;
90 packet.severity = severity;
91 mav_array_memcpy(packet.text, text, sizeof(char)*50);
92 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUSTEXT_LEN);
93#endif
94
95 msg->msgid = MAVLINK_MSG_ID_STATUSTEXT;
96 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);
97}
98
99/**
100 * @brief Encode a statustext struct
101 *
102 * @param system_id ID of this system
103 * @param component_id ID of this component (e.g. 200 for IMU)
104 * @param msg The MAVLink message to compress the data into
105 * @param statustext C-struct to read the message contents from
106 */
107static inline uint16_t mavlink_msg_statustext_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_statustext_t* statustext)
108{
109 return mavlink_msg_statustext_pack(system_id, component_id, msg, statustext->severity, statustext->text);
110}
111
112/**
113 * @brief Encode a statustext struct on a channel
114 *
115 * @param system_id ID of this system
116 * @param component_id ID of this component (e.g. 200 for IMU)
117 * @param chan The MAVLink channel this message will be sent over
118 * @param msg The MAVLink message to compress the data into
119 * @param statustext C-struct to read the message contents from
120 */
121static 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)
122{
123 return mavlink_msg_statustext_pack_chan(system_id, component_id, chan, msg, statustext->severity, statustext->text);
124}
125
126/**
127 * @brief Send a statustext message
128 * @param chan MAVLink channel to send the message
129 *
130 * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
131 * @param text Status text message, without null termination character
132 */
133#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
134
135static inline void mavlink_msg_statustext_send(mavlink_channel_t chan, uint8_t severity, const char *text)
136{
137#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
138 char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN];
139 _mav_put_uint8_t(buf, 0, severity);
140 _mav_put_char_array(buf, 1, text, 50);
141 _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);
142#else
143 mavlink_statustext_t packet;
144 packet.severity = severity;
145 mav_array_memcpy(packet.text, text, sizeof(char)*50);
146 _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);
147#endif
148}
149
150/**
151 * @brief Send a statustext message
152 * @param chan MAVLink channel to send the message
153 * @param struct The MAVLink struct to serialize
154 */
155static inline void mavlink_msg_statustext_send_struct(mavlink_channel_t chan, const mavlink_statustext_t* statustext)
156{
157#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
158 mavlink_msg_statustext_send(chan, statustext->severity, statustext->text);
159#else
160 _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);
161#endif
162}
163
164#if MAVLINK_MSG_ID_STATUSTEXT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
165/*
166 This varient of _send() can be used to save stack space by re-using
167 memory from the receive buffer. The caller provides a
168 mavlink_message_t which is the size of a full mavlink message. This
169 is usually the receive buffer for the channel, and allows a reply to an
170 incoming message with minimum stack space usage.
171 */
172static inline void mavlink_msg_statustext_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t severity, const char *text)
173{
174#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
175 char *buf = (char *)msgbuf;
176 _mav_put_uint8_t(buf, 0, severity);
177 _mav_put_char_array(buf, 1, text, 50);
178 _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);
179#else
180 mavlink_statustext_t *packet = (mavlink_statustext_t *)msgbuf;
181 packet->severity = severity;
182 mav_array_memcpy(packet->text, text, sizeof(char)*50);
183 _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);
184#endif
185}
186#endif
187
188#endif
189
190// MESSAGE STATUSTEXT UNPACKING
191
192
193/**
194 * @brief Get field severity from statustext message
195 *
196 * @return Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
197 */
198static inline uint8_t mavlink_msg_statustext_get_severity(const mavlink_message_t* msg)
199{
200 return _MAV_RETURN_uint8_t(msg, 0);
201}
202
203/**
204 * @brief Get field text from statustext message
205 *
206 * @return Status text message, without null termination character
207 */
208static inline uint16_t mavlink_msg_statustext_get_text(const mavlink_message_t* msg, char *text)
209{
210 return _MAV_RETURN_char_array(msg, text, 50, 1);
211}
212
213/**
214 * @brief Decode a statustext message into a struct
215 *
216 * @param msg The message to decode
217 * @param statustext C-struct to decode the message contents into
218 */
219static inline void mavlink_msg_statustext_decode(const mavlink_message_t* msg, mavlink_statustext_t* statustext)
220{
221#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
222 statustext->severity = mavlink_msg_statustext_get_severity(msg);
223 mavlink_msg_statustext_get_text(msg, statustext->text);
224#else
225 uint8_t len = msg->len < MAVLINK_MSG_ID_STATUSTEXT_LEN? msg->len : MAVLINK_MSG_ID_STATUSTEXT_LEN;
226 memset(statustext, 0, MAVLINK_MSG_ID_STATUSTEXT_LEN);
227 memcpy(statustext, _MAV_PAYLOAD(msg), len);
228#endif
229}
Note: See TracBrowser for help on using the repository browser.