NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mavlink_msg_raw_aux.h
Go to the documentation of this file.
1 // MESSAGE RAW_AUX PACKING
2 
3 #define MAVLINK_MSG_ID_RAW_AUX 172
4 
5 typedef struct __mavlink_raw_aux_t
6 {
7  int32_t baro;
8  uint16_t adc1;
9  uint16_t adc2;
10  uint16_t adc3;
11  uint16_t adc4;
12  uint16_t vbat;
13  int16_t temp;
15 
16 #define MAVLINK_MSG_ID_RAW_AUX_LEN 16
17 #define MAVLINK_MSG_ID_172_LEN 16
18 
19 #define MAVLINK_MSG_ID_RAW_AUX_CRC 182
20 #define MAVLINK_MSG_ID_172_CRC 182
21 
22 
23 
24 #define MAVLINK_MESSAGE_INFO_RAW_AUX { \
25  "RAW_AUX", \
26  7, \
27  { { "baro", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_raw_aux_t, baro) }, \
28  { "adc1", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_raw_aux_t, adc1) }, \
29  { "adc2", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_raw_aux_t, adc2) }, \
30  { "adc3", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_raw_aux_t, adc3) }, \
31  { "adc4", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_raw_aux_t, adc4) }, \
32  { "vbat", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_raw_aux_t, vbat) }, \
33  { "temp", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_raw_aux_t, temp) }, \
34  } \
35 }
36 
37 
53 static inline uint16_t mavlink_msg_raw_aux_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
54  uint16_t adc1, uint16_t adc2, uint16_t adc3, uint16_t adc4, uint16_t vbat, int16_t temp, int32_t baro)
55 {
56 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
58  _mav_put_int32_t(buf, 0, baro);
59  _mav_put_uint16_t(buf, 4, adc1);
60  _mav_put_uint16_t(buf, 6, adc2);
61  _mav_put_uint16_t(buf, 8, adc3);
62  _mav_put_uint16_t(buf, 10, adc4);
63  _mav_put_uint16_t(buf, 12, vbat);
64  _mav_put_int16_t(buf, 14, temp);
65 
67 #else
68  mavlink_raw_aux_t packet;
69  packet.baro = baro;
70  packet.adc1 = adc1;
71  packet.adc2 = adc2;
72  packet.adc3 = adc3;
73  packet.adc4 = adc4;
74  packet.vbat = vbat;
75  packet.temp = temp;
76 
78 #endif
79 
80  msg->msgid = MAVLINK_MSG_ID_RAW_AUX;
81 #if MAVLINK_CRC_EXTRA
83 #else
84  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RAW_AUX_LEN);
85 #endif
86 }
87 
103 static inline uint16_t mavlink_msg_raw_aux_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
104  mavlink_message_t* msg,
105  uint16_t adc1,uint16_t adc2,uint16_t adc3,uint16_t adc4,uint16_t vbat,int16_t temp,int32_t baro)
106 {
107 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
108  char buf[MAVLINK_MSG_ID_RAW_AUX_LEN];
109  _mav_put_int32_t(buf, 0, baro);
110  _mav_put_uint16_t(buf, 4, adc1);
111  _mav_put_uint16_t(buf, 6, adc2);
112  _mav_put_uint16_t(buf, 8, adc3);
113  _mav_put_uint16_t(buf, 10, adc4);
114  _mav_put_uint16_t(buf, 12, vbat);
115  _mav_put_int16_t(buf, 14, temp);
116 
118 #else
119  mavlink_raw_aux_t packet;
120  packet.baro = baro;
121  packet.adc1 = adc1;
122  packet.adc2 = adc2;
123  packet.adc3 = adc3;
124  packet.adc4 = adc4;
125  packet.vbat = vbat;
126  packet.temp = temp;
127 
128  memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_AUX_LEN);
129 #endif
130 
131  msg->msgid = MAVLINK_MSG_ID_RAW_AUX;
132 #if MAVLINK_CRC_EXTRA
133  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_RAW_AUX_LEN, MAVLINK_MSG_ID_RAW_AUX_CRC);
134 #else
135  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_RAW_AUX_LEN);
136 #endif
137 }
138 
147 static inline uint16_t mavlink_msg_raw_aux_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_raw_aux_t* raw_aux)
148 {
149  return mavlink_msg_raw_aux_pack(system_id, component_id, msg, raw_aux->adc1, raw_aux->adc2, raw_aux->adc3, raw_aux->adc4, raw_aux->vbat, raw_aux->temp, raw_aux->baro);
150 }
151 
161 static inline uint16_t mavlink_msg_raw_aux_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_raw_aux_t* raw_aux)
162 {
163  return mavlink_msg_raw_aux_pack_chan(system_id, component_id, chan, msg, raw_aux->adc1, raw_aux->adc2, raw_aux->adc3, raw_aux->adc4, raw_aux->vbat, raw_aux->temp, raw_aux->baro);
164 }
165 
178 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
179 
180 static inline void mavlink_msg_raw_aux_send(mavlink_channel_t chan, uint16_t adc1, uint16_t adc2, uint16_t adc3, uint16_t adc4, uint16_t vbat, int16_t temp, int32_t baro)
181 {
182 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
183  char buf[MAVLINK_MSG_ID_RAW_AUX_LEN];
184  _mav_put_int32_t(buf, 0, baro);
185  _mav_put_uint16_t(buf, 4, adc1);
186  _mav_put_uint16_t(buf, 6, adc2);
187  _mav_put_uint16_t(buf, 8, adc3);
188  _mav_put_uint16_t(buf, 10, adc4);
189  _mav_put_uint16_t(buf, 12, vbat);
190  _mav_put_int16_t(buf, 14, temp);
191 
192 #if MAVLINK_CRC_EXTRA
193  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_AUX, buf, MAVLINK_MSG_ID_RAW_AUX_LEN, MAVLINK_MSG_ID_RAW_AUX_CRC);
194 #else
195  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_AUX, buf, MAVLINK_MSG_ID_RAW_AUX_LEN);
196 #endif
197 #else
198  mavlink_raw_aux_t packet;
199  packet.baro = baro;
200  packet.adc1 = adc1;
201  packet.adc2 = adc2;
202  packet.adc3 = adc3;
203  packet.adc4 = adc4;
204  packet.vbat = vbat;
205  packet.temp = temp;
206 
207 #if MAVLINK_CRC_EXTRA
208  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_AUX, (const char *)&packet, MAVLINK_MSG_ID_RAW_AUX_LEN, MAVLINK_MSG_ID_RAW_AUX_CRC);
209 #else
210  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_AUX, (const char *)&packet, MAVLINK_MSG_ID_RAW_AUX_LEN);
211 #endif
212 #endif
213 }
214 
215 #if MAVLINK_MSG_ID_RAW_AUX_LEN <= MAVLINK_MAX_PAYLOAD_LEN
216 /*
217  This varient of _send() can be used to save stack space by re-using
218  memory from the receive buffer. The caller provides a
219  mavlink_message_t which is the size of a full mavlink message. This
220  is usually the receive buffer for the channel, and allows a reply to an
221  incoming message with minimum stack space usage.
222  */
223 static inline void mavlink_msg_raw_aux_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t adc1, uint16_t adc2, uint16_t adc3, uint16_t adc4, uint16_t vbat, int16_t temp, int32_t baro)
224 {
225 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
226  char *buf = (char *)msgbuf;
227  _mav_put_int32_t(buf, 0, baro);
228  _mav_put_uint16_t(buf, 4, adc1);
229  _mav_put_uint16_t(buf, 6, adc2);
230  _mav_put_uint16_t(buf, 8, adc3);
231  _mav_put_uint16_t(buf, 10, adc4);
232  _mav_put_uint16_t(buf, 12, vbat);
233  _mav_put_int16_t(buf, 14, temp);
234 
235 #if MAVLINK_CRC_EXTRA
236  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_AUX, buf, MAVLINK_MSG_ID_RAW_AUX_LEN, MAVLINK_MSG_ID_RAW_AUX_CRC);
237 #else
238  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_AUX, buf, MAVLINK_MSG_ID_RAW_AUX_LEN);
239 #endif
240 #else
241  mavlink_raw_aux_t *packet = (mavlink_raw_aux_t *)msgbuf;
242  packet->baro = baro;
243  packet->adc1 = adc1;
244  packet->adc2 = adc2;
245  packet->adc3 = adc3;
246  packet->adc4 = adc4;
247  packet->vbat = vbat;
248  packet->temp = temp;
249 
250 #if MAVLINK_CRC_EXTRA
251  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_AUX, (const char *)packet, MAVLINK_MSG_ID_RAW_AUX_LEN, MAVLINK_MSG_ID_RAW_AUX_CRC);
252 #else
253  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_AUX, (const char *)packet, MAVLINK_MSG_ID_RAW_AUX_LEN);
254 #endif
255 #endif
256 }
257 #endif
258 
259 #endif
260 
261 // MESSAGE RAW_AUX UNPACKING
262 
263 
269 static inline uint16_t mavlink_msg_raw_aux_get_adc1(const mavlink_message_t* msg)
270 {
271  return _MAV_RETURN_uint16_t(msg, 4);
272 }
273 
279 static inline uint16_t mavlink_msg_raw_aux_get_adc2(const mavlink_message_t* msg)
280 {
281  return _MAV_RETURN_uint16_t(msg, 6);
282 }
283 
289 static inline uint16_t mavlink_msg_raw_aux_get_adc3(const mavlink_message_t* msg)
290 {
291  return _MAV_RETURN_uint16_t(msg, 8);
292 }
293 
299 static inline uint16_t mavlink_msg_raw_aux_get_adc4(const mavlink_message_t* msg)
300 {
301  return _MAV_RETURN_uint16_t(msg, 10);
302 }
303 
309 static inline uint16_t mavlink_msg_raw_aux_get_vbat(const mavlink_message_t* msg)
310 {
311  return _MAV_RETURN_uint16_t(msg, 12);
312 }
313 
319 static inline int16_t mavlink_msg_raw_aux_get_temp(const mavlink_message_t* msg)
320 {
321  return _MAV_RETURN_int16_t(msg, 14);
322 }
323 
329 static inline int32_t mavlink_msg_raw_aux_get_baro(const mavlink_message_t* msg)
330 {
331  return _MAV_RETURN_int32_t(msg, 0);
332 }
333 
340 static inline void mavlink_msg_raw_aux_decode(const mavlink_message_t* msg, mavlink_raw_aux_t* raw_aux)
341 {
342 #if MAVLINK_NEED_BYTE_SWAP
343  raw_aux->baro = mavlink_msg_raw_aux_get_baro(msg);
344  raw_aux->adc1 = mavlink_msg_raw_aux_get_adc1(msg);
345  raw_aux->adc2 = mavlink_msg_raw_aux_get_adc2(msg);
346  raw_aux->adc3 = mavlink_msg_raw_aux_get_adc3(msg);
347  raw_aux->adc4 = mavlink_msg_raw_aux_get_adc4(msg);
348  raw_aux->vbat = mavlink_msg_raw_aux_get_vbat(msg);
349  raw_aux->temp = mavlink_msg_raw_aux_get_temp(msg);
350 #else
351  memcpy(raw_aux, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_RAW_AUX_LEN);
352 #endif
353 }
#define _mav_put_int32_t(buf, wire_offset, b)
Definition: protocol.h:142
struct barometer_config baro
Definition: config.h:95
#define _mav_put_uint16_t(buf, wire_offset, b)
Definition: protocol.h:139
#define _mav_put_int16_t(buf, wire_offset, b)
Definition: protocol.h:140
Definition: barometer.h:33