NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mavlink_msg_diagnostic.h
Go to the documentation of this file.
1 // MESSAGE DIAGNOSTIC PACKING
2 
3 #define MAVLINK_MSG_ID_DIAGNOSTIC 173
4 
5 typedef struct __mavlink_diagnostic_t
6 {
7  float diagFl1;
8  float diagFl2;
9  float diagFl3;
10  int16_t diagSh1;
11  int16_t diagSh2;
12  int16_t diagSh3;
14 
15 #define MAVLINK_MSG_ID_DIAGNOSTIC_LEN 18
16 #define MAVLINK_MSG_ID_173_LEN 18
17 
18 #define MAVLINK_MSG_ID_DIAGNOSTIC_CRC 2
19 #define MAVLINK_MSG_ID_173_CRC 2
20 
21 
22 
23 #define MAVLINK_MESSAGE_INFO_DIAGNOSTIC { \
24  "DIAGNOSTIC", \
25  6, \
26  { { "diagFl1", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_diagnostic_t, diagFl1) }, \
27  { "diagFl2", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_diagnostic_t, diagFl2) }, \
28  { "diagFl3", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_diagnostic_t, diagFl3) }, \
29  { "diagSh1", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_diagnostic_t, diagSh1) }, \
30  { "diagSh2", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_diagnostic_t, diagSh2) }, \
31  { "diagSh3", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_diagnostic_t, diagSh3) }, \
32  } \
33 }
34 
35 
50 static inline uint16_t mavlink_msg_diagnostic_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
51  float diagFl1, float diagFl2, float diagFl3, int16_t diagSh1, int16_t diagSh2, int16_t diagSh3)
52 {
53 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
55  _mav_put_float(buf, 0, diagFl1);
56  _mav_put_float(buf, 4, diagFl2);
57  _mav_put_float(buf, 8, diagFl3);
58  _mav_put_int16_t(buf, 12, diagSh1);
59  _mav_put_int16_t(buf, 14, diagSh2);
60  _mav_put_int16_t(buf, 16, diagSh3);
61 
63 #else
64  mavlink_diagnostic_t packet;
65  packet.diagFl1 = diagFl1;
66  packet.diagFl2 = diagFl2;
67  packet.diagFl3 = diagFl3;
68  packet.diagSh1 = diagSh1;
69  packet.diagSh2 = diagSh2;
70  packet.diagSh3 = diagSh3;
71 
73 #endif
74 
75  msg->msgid = MAVLINK_MSG_ID_DIAGNOSTIC;
76 #if MAVLINK_CRC_EXTRA
78 #else
79  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
80 #endif
81 }
82 
97 static inline uint16_t mavlink_msg_diagnostic_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
98  mavlink_message_t* msg,
99  float diagFl1,float diagFl2,float diagFl3,int16_t diagSh1,int16_t diagSh2,int16_t diagSh3)
100 {
101 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
103  _mav_put_float(buf, 0, diagFl1);
104  _mav_put_float(buf, 4, diagFl2);
105  _mav_put_float(buf, 8, diagFl3);
106  _mav_put_int16_t(buf, 12, diagSh1);
107  _mav_put_int16_t(buf, 14, diagSh2);
108  _mav_put_int16_t(buf, 16, diagSh3);
109 
111 #else
112  mavlink_diagnostic_t packet;
113  packet.diagFl1 = diagFl1;
114  packet.diagFl2 = diagFl2;
115  packet.diagFl3 = diagFl3;
116  packet.diagSh1 = diagSh1;
117  packet.diagSh2 = diagSh2;
118  packet.diagSh3 = diagSh3;
119 
121 #endif
122 
123  msg->msgid = MAVLINK_MSG_ID_DIAGNOSTIC;
124 #if MAVLINK_CRC_EXTRA
126 #else
127  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
128 #endif
129 }
130 
139 static inline uint16_t mavlink_msg_diagnostic_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_diagnostic_t* diagnostic)
140 {
141  return mavlink_msg_diagnostic_pack(system_id, component_id, msg, diagnostic->diagFl1, diagnostic->diagFl2, diagnostic->diagFl3, diagnostic->diagSh1, diagnostic->diagSh2, diagnostic->diagSh3);
142 }
143 
153 static 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)
154 {
155  return mavlink_msg_diagnostic_pack_chan(system_id, component_id, chan, msg, diagnostic->diagFl1, diagnostic->diagFl2, diagnostic->diagFl3, diagnostic->diagSh1, diagnostic->diagSh2, diagnostic->diagSh3);
156 }
157 
169 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
170 
171 static 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)
172 {
173 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
175  _mav_put_float(buf, 0, diagFl1);
176  _mav_put_float(buf, 4, diagFl2);
177  _mav_put_float(buf, 8, diagFl3);
178  _mav_put_int16_t(buf, 12, diagSh1);
179  _mav_put_int16_t(buf, 14, diagSh2);
180  _mav_put_int16_t(buf, 16, diagSh3);
181 
182 #if MAVLINK_CRC_EXTRA
183  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, buf, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
184 #else
185  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, buf, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
186 #endif
187 #else
188  mavlink_diagnostic_t packet;
189  packet.diagFl1 = diagFl1;
190  packet.diagFl2 = diagFl2;
191  packet.diagFl3 = diagFl3;
192  packet.diagSh1 = diagSh1;
193  packet.diagSh2 = diagSh2;
194  packet.diagSh3 = diagSh3;
195 
196 #if MAVLINK_CRC_EXTRA
197  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, (const char *)&packet, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
198 #else
199  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, (const char *)&packet, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
200 #endif
201 #endif
202 }
203 
204 #if MAVLINK_MSG_ID_DIAGNOSTIC_LEN <= MAVLINK_MAX_PAYLOAD_LEN
205 /*
206  This varient of _send() can be used to save stack space by re-using
207  memory from the receive buffer. The caller provides a
208  mavlink_message_t which is the size of a full mavlink message. This
209  is usually the receive buffer for the channel, and allows a reply to an
210  incoming message with minimum stack space usage.
211  */
212 static 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)
213 {
214 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
215  char *buf = (char *)msgbuf;
216  _mav_put_float(buf, 0, diagFl1);
217  _mav_put_float(buf, 4, diagFl2);
218  _mav_put_float(buf, 8, diagFl3);
219  _mav_put_int16_t(buf, 12, diagSh1);
220  _mav_put_int16_t(buf, 14, diagSh2);
221  _mav_put_int16_t(buf, 16, diagSh3);
222 
223 #if MAVLINK_CRC_EXTRA
224  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, buf, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
225 #else
226  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, buf, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
227 #endif
228 #else
229  mavlink_diagnostic_t *packet = (mavlink_diagnostic_t *)msgbuf;
230  packet->diagFl1 = diagFl1;
231  packet->diagFl2 = diagFl2;
232  packet->diagFl3 = diagFl3;
233  packet->diagSh1 = diagSh1;
234  packet->diagSh2 = diagSh2;
235  packet->diagSh3 = diagSh3;
236 
237 #if MAVLINK_CRC_EXTRA
238  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, (const char *)packet, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
239 #else
240  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, (const char *)packet, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
241 #endif
242 #endif
243 }
244 #endif
245 
246 #endif
247 
248 // MESSAGE DIAGNOSTIC UNPACKING
249 
250 
256 static inline float mavlink_msg_diagnostic_get_diagFl1(const mavlink_message_t* msg)
257 {
258  return _MAV_RETURN_float(msg, 0);
259 }
260 
266 static inline float mavlink_msg_diagnostic_get_diagFl2(const mavlink_message_t* msg)
267 {
268  return _MAV_RETURN_float(msg, 4);
269 }
270 
276 static inline float mavlink_msg_diagnostic_get_diagFl3(const mavlink_message_t* msg)
277 {
278  return _MAV_RETURN_float(msg, 8);
279 }
280 
286 static inline int16_t mavlink_msg_diagnostic_get_diagSh1(const mavlink_message_t* msg)
287 {
288  return _MAV_RETURN_int16_t(msg, 12);
289 }
290 
296 static inline int16_t mavlink_msg_diagnostic_get_diagSh2(const mavlink_message_t* msg)
297 {
298  return _MAV_RETURN_int16_t(msg, 14);
299 }
300 
306 static inline int16_t mavlink_msg_diagnostic_get_diagSh3(const mavlink_message_t* msg)
307 {
308  return _MAV_RETURN_int16_t(msg, 16);
309 }
310 
317 static inline void mavlink_msg_diagnostic_decode(const mavlink_message_t* msg, mavlink_diagnostic_t* diagnostic)
318 {
319 #if MAVLINK_NEED_BYTE_SWAP
320  diagnostic->diagFl1 = mavlink_msg_diagnostic_get_diagFl1(msg);
321  diagnostic->diagFl2 = mavlink_msg_diagnostic_get_diagFl2(msg);
322  diagnostic->diagFl3 = mavlink_msg_diagnostic_get_diagFl3(msg);
323  diagnostic->diagSh1 = mavlink_msg_diagnostic_get_diagSh1(msg);
324  diagnostic->diagSh2 = mavlink_msg_diagnostic_get_diagSh2(msg);
325  diagnostic->diagSh3 = mavlink_msg_diagnostic_get_diagSh3(msg);
326 #else
327  memcpy(diagnostic, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
328 #endif
329 }
#define _mav_put_float(buf, wire_offset, b)
Definition: protocol.h:145
#define _mav_put_int16_t(buf, wire_offset, b)
Definition: protocol.h:140