RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_diagnostic.h
1#pragma once
2// MESSAGE DIAGNOSTIC PACKING
3
4#define MAVLINK_MSG_ID_DIAGNOSTIC 173
5
6MAVPACKED(
7typedef struct __mavlink_diagnostic_t {
8 float diagFl1; /*< Diagnostic float 1*/
9 float diagFl2; /*< Diagnostic float 2*/
10 float diagFl3; /*< Diagnostic float 3*/
11 int16_t diagSh1; /*< Diagnostic short 1*/
12 int16_t diagSh2; /*< Diagnostic short 2*/
13 int16_t diagSh3; /*< Diagnostic short 3*/
14}) mavlink_diagnostic_t;
15
16#define MAVLINK_MSG_ID_DIAGNOSTIC_LEN 18
17#define MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN 18
18#define MAVLINK_MSG_ID_173_LEN 18
19#define MAVLINK_MSG_ID_173_MIN_LEN 18
20
21#define MAVLINK_MSG_ID_DIAGNOSTIC_CRC 2
22#define MAVLINK_MSG_ID_173_CRC 2
23
24
25
26#if MAVLINK_COMMAND_24BIT
27#define MAVLINK_MESSAGE_INFO_DIAGNOSTIC { \
28 173, \
29 "DIAGNOSTIC", \
30 6, \
31 { { "diagFl1", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_diagnostic_t, diagFl1) }, \
32 { "diagFl2", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_diagnostic_t, diagFl2) }, \
33 { "diagFl3", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_diagnostic_t, diagFl3) }, \
34 { "diagSh1", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_diagnostic_t, diagSh1) }, \
35 { "diagSh2", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_diagnostic_t, diagSh2) }, \
36 { "diagSh3", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_diagnostic_t, diagSh3) }, \
37 } \
38}
39#else
40#define MAVLINK_MESSAGE_INFO_DIAGNOSTIC { \
41 "DIAGNOSTIC", \
42 6, \
43 { { "diagFl1", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_diagnostic_t, diagFl1) }, \
44 { "diagFl2", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_diagnostic_t, diagFl2) }, \
45 { "diagFl3", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_diagnostic_t, diagFl3) }, \
46 { "diagSh1", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_diagnostic_t, diagSh1) }, \
47 { "diagSh2", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_diagnostic_t, diagSh2) }, \
48 { "diagSh3", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_diagnostic_t, diagSh3) }, \
49 } \
50}
51#endif
52
53/**
54 * @brief Pack a diagnostic message
55 * @param system_id ID of this system
56 * @param component_id ID of this component (e.g. 200 for IMU)
57 * @param msg The MAVLink message to compress the data into
58 *
59 * @param diagFl1 Diagnostic float 1
60 * @param diagFl2 Diagnostic float 2
61 * @param diagFl3 Diagnostic float 3
62 * @param diagSh1 Diagnostic short 1
63 * @param diagSh2 Diagnostic short 2
64 * @param diagSh3 Diagnostic short 3
65 * @return length of the message in bytes (excluding serial stream start sign)
66 */
67static inline uint16_t mavlink_msg_diagnostic_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
68 float diagFl1, float diagFl2, float diagFl3, int16_t diagSh1, int16_t diagSh2, int16_t diagSh3)
69{
70#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 char buf[MAVLINK_MSG_ID_DIAGNOSTIC_LEN];
72 _mav_put_float(buf, 0, diagFl1);
73 _mav_put_float(buf, 4, diagFl2);
74 _mav_put_float(buf, 8, diagFl3);
75 _mav_put_int16_t(buf, 12, diagSh1);
76 _mav_put_int16_t(buf, 14, diagSh2);
77 _mav_put_int16_t(buf, 16, diagSh3);
78
79 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
80#else
81 mavlink_diagnostic_t packet;
82 packet.diagFl1 = diagFl1;
83 packet.diagFl2 = diagFl2;
84 packet.diagFl3 = diagFl3;
85 packet.diagSh1 = diagSh1;
86 packet.diagSh2 = diagSh2;
87 packet.diagSh3 = diagSh3;
88
89 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
90#endif
91
92 msg->msgid = MAVLINK_MSG_ID_DIAGNOSTIC;
93 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
94}
95
96/**
97 * @brief Pack a diagnostic message on a channel
98 * @param system_id ID of this system
99 * @param component_id ID of this component (e.g. 200 for IMU)
100 * @param chan The MAVLink channel this message will be sent over
101 * @param msg The MAVLink message to compress the data into
102 * @param diagFl1 Diagnostic float 1
103 * @param diagFl2 Diagnostic float 2
104 * @param diagFl3 Diagnostic float 3
105 * @param diagSh1 Diagnostic short 1
106 * @param diagSh2 Diagnostic short 2
107 * @param diagSh3 Diagnostic short 3
108 * @return length of the message in bytes (excluding serial stream start sign)
109 */
110static inline uint16_t mavlink_msg_diagnostic_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
111 mavlink_message_t* msg,
112 float diagFl1,float diagFl2,float diagFl3,int16_t diagSh1,int16_t diagSh2,int16_t diagSh3)
113{
114#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
115 char buf[MAVLINK_MSG_ID_DIAGNOSTIC_LEN];
116 _mav_put_float(buf, 0, diagFl1);
117 _mav_put_float(buf, 4, diagFl2);
118 _mav_put_float(buf, 8, diagFl3);
119 _mav_put_int16_t(buf, 12, diagSh1);
120 _mav_put_int16_t(buf, 14, diagSh2);
121 _mav_put_int16_t(buf, 16, diagSh3);
122
123 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
124#else
125 mavlink_diagnostic_t packet;
126 packet.diagFl1 = diagFl1;
127 packet.diagFl2 = diagFl2;
128 packet.diagFl3 = diagFl3;
129 packet.diagSh1 = diagSh1;
130 packet.diagSh2 = diagSh2;
131 packet.diagSh3 = diagSh3;
132
133 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
134#endif
135
136 msg->msgid = MAVLINK_MSG_ID_DIAGNOSTIC;
137 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
138}
139
140/**
141 * @brief Encode a diagnostic struct
142 *
143 * @param system_id ID of this system
144 * @param component_id ID of this component (e.g. 200 for IMU)
145 * @param msg The MAVLink message to compress the data into
146 * @param diagnostic C-struct to read the message contents from
147 */
148static inline uint16_t mavlink_msg_diagnostic_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_diagnostic_t* diagnostic)
149{
150 return mavlink_msg_diagnostic_pack(system_id, component_id, msg, diagnostic->diagFl1, diagnostic->diagFl2, diagnostic->diagFl3, diagnostic->diagSh1, diagnostic->diagSh2, diagnostic->diagSh3);
151}
152
153/**
154 * @brief Encode a diagnostic struct on a channel
155 *
156 * @param system_id ID of this system
157 * @param component_id ID of this component (e.g. 200 for IMU)
158 * @param chan The MAVLink channel this message will be sent over
159 * @param msg The MAVLink message to compress the data into
160 * @param diagnostic C-struct to read the message contents from
161 */
162static inline uint16_t mavlink_msg_diagnostic_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_diagnostic_t* diagnostic)
163{
164 return mavlink_msg_diagnostic_pack_chan(system_id, component_id, chan, msg, diagnostic->diagFl1, diagnostic->diagFl2, diagnostic->diagFl3, diagnostic->diagSh1, diagnostic->diagSh2, diagnostic->diagSh3);
165}
166
167/**
168 * @brief Send a diagnostic message
169 * @param chan MAVLink channel to send the message
170 *
171 * @param diagFl1 Diagnostic float 1
172 * @param diagFl2 Diagnostic float 2
173 * @param diagFl3 Diagnostic float 3
174 * @param diagSh1 Diagnostic short 1
175 * @param diagSh2 Diagnostic short 2
176 * @param diagSh3 Diagnostic short 3
177 */
178#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
179
180static inline void mavlink_msg_diagnostic_send(mavlink_channel_t chan, float diagFl1, float diagFl2, float diagFl3, int16_t diagSh1, int16_t diagSh2, int16_t diagSh3)
181{
182#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
183 char buf[MAVLINK_MSG_ID_DIAGNOSTIC_LEN];
184 _mav_put_float(buf, 0, diagFl1);
185 _mav_put_float(buf, 4, diagFl2);
186 _mav_put_float(buf, 8, diagFl3);
187 _mav_put_int16_t(buf, 12, diagSh1);
188 _mav_put_int16_t(buf, 14, diagSh2);
189 _mav_put_int16_t(buf, 16, diagSh3);
190
191 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, buf, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
192#else
193 mavlink_diagnostic_t packet;
194 packet.diagFl1 = diagFl1;
195 packet.diagFl2 = diagFl2;
196 packet.diagFl3 = diagFl3;
197 packet.diagSh1 = diagSh1;
198 packet.diagSh2 = diagSh2;
199 packet.diagSh3 = diagSh3;
200
201 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, (const char *)&packet, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
202#endif
203}
204
205/**
206 * @brief Send a diagnostic message
207 * @param chan MAVLink channel to send the message
208 * @param struct The MAVLink struct to serialize
209 */
210static inline void mavlink_msg_diagnostic_send_struct(mavlink_channel_t chan, const mavlink_diagnostic_t* diagnostic)
211{
212#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
213 mavlink_msg_diagnostic_send(chan, diagnostic->diagFl1, diagnostic->diagFl2, diagnostic->diagFl3, diagnostic->diagSh1, diagnostic->diagSh2, diagnostic->diagSh3);
214#else
215 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, (const char *)diagnostic, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
216#endif
217}
218
219#if MAVLINK_MSG_ID_DIAGNOSTIC_LEN <= MAVLINK_MAX_PAYLOAD_LEN
220/*
221 This varient of _send() can be used to save stack space by re-using
222 memory from the receive buffer. The caller provides a
223 mavlink_message_t which is the size of a full mavlink message. This
224 is usually the receive buffer for the channel, and allows a reply to an
225 incoming message with minimum stack space usage.
226 */
227static inline void mavlink_msg_diagnostic_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float diagFl1, float diagFl2, float diagFl3, int16_t diagSh1, int16_t diagSh2, int16_t diagSh3)
228{
229#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
230 char *buf = (char *)msgbuf;
231 _mav_put_float(buf, 0, diagFl1);
232 _mav_put_float(buf, 4, diagFl2);
233 _mav_put_float(buf, 8, diagFl3);
234 _mav_put_int16_t(buf, 12, diagSh1);
235 _mav_put_int16_t(buf, 14, diagSh2);
236 _mav_put_int16_t(buf, 16, diagSh3);
237
238 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, buf, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
239#else
240 mavlink_diagnostic_t *packet = (mavlink_diagnostic_t *)msgbuf;
241 packet->diagFl1 = diagFl1;
242 packet->diagFl2 = diagFl2;
243 packet->diagFl3 = diagFl3;
244 packet->diagSh1 = diagSh1;
245 packet->diagSh2 = diagSh2;
246 packet->diagSh3 = diagSh3;
247
248 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, (const char *)packet, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
249#endif
250}
251#endif
252
253#endif
254
255// MESSAGE DIAGNOSTIC UNPACKING
256
257
258/**
259 * @brief Get field diagFl1 from diagnostic message
260 *
261 * @return Diagnostic float 1
262 */
263static inline float mavlink_msg_diagnostic_get_diagFl1(const mavlink_message_t* msg)
264{
265 return _MAV_RETURN_float(msg, 0);
266}
267
268/**
269 * @brief Get field diagFl2 from diagnostic message
270 *
271 * @return Diagnostic float 2
272 */
273static inline float mavlink_msg_diagnostic_get_diagFl2(const mavlink_message_t* msg)
274{
275 return _MAV_RETURN_float(msg, 4);
276}
277
278/**
279 * @brief Get field diagFl3 from diagnostic message
280 *
281 * @return Diagnostic float 3
282 */
283static inline float mavlink_msg_diagnostic_get_diagFl3(const mavlink_message_t* msg)
284{
285 return _MAV_RETURN_float(msg, 8);
286}
287
288/**
289 * @brief Get field diagSh1 from diagnostic message
290 *
291 * @return Diagnostic short 1
292 */
293static inline int16_t mavlink_msg_diagnostic_get_diagSh1(const mavlink_message_t* msg)
294{
295 return _MAV_RETURN_int16_t(msg, 12);
296}
297
298/**
299 * @brief Get field diagSh2 from diagnostic message
300 *
301 * @return Diagnostic short 2
302 */
303static inline int16_t mavlink_msg_diagnostic_get_diagSh2(const mavlink_message_t* msg)
304{
305 return _MAV_RETURN_int16_t(msg, 14);
306}
307
308/**
309 * @brief Get field diagSh3 from diagnostic message
310 *
311 * @return Diagnostic short 3
312 */
313static inline int16_t mavlink_msg_diagnostic_get_diagSh3(const mavlink_message_t* msg)
314{
315 return _MAV_RETURN_int16_t(msg, 16);
316}
317
318/**
319 * @brief Decode a diagnostic message into a struct
320 *
321 * @param msg The message to decode
322 * @param diagnostic C-struct to decode the message contents into
323 */
324static inline void mavlink_msg_diagnostic_decode(const mavlink_message_t* msg, mavlink_diagnostic_t* diagnostic)
325{
326#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
327 diagnostic->diagFl1 = mavlink_msg_diagnostic_get_diagFl1(msg);
328 diagnostic->diagFl2 = mavlink_msg_diagnostic_get_diagFl2(msg);
329 diagnostic->diagFl3 = mavlink_msg_diagnostic_get_diagFl3(msg);
330 diagnostic->diagSh1 = mavlink_msg_diagnostic_get_diagSh1(msg);
331 diagnostic->diagSh2 = mavlink_msg_diagnostic_get_diagSh2(msg);
332 diagnostic->diagSh3 = mavlink_msg_diagnostic_get_diagSh3(msg);
333#else
334 uint8_t len = msg->len < MAVLINK_MSG_ID_DIAGNOSTIC_LEN? msg->len : MAVLINK_MSG_ID_DIAGNOSTIC_LEN;
335 memset(diagnostic, 0, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
336 memcpy(diagnostic, _MAV_PAYLOAD(msg), len);
337#endif
338}