RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_ap_adc.h
1#pragma once
2// MESSAGE AP_ADC PACKING
3
4#define MAVLINK_MSG_ID_AP_ADC 153
5
6MAVPACKED(
7typedef struct __mavlink_ap_adc_t {
8 uint16_t adc1; /*< ADC output 1*/
9 uint16_t adc2; /*< ADC output 2*/
10 uint16_t adc3; /*< ADC output 3*/
11 uint16_t adc4; /*< ADC output 4*/
12 uint16_t adc5; /*< ADC output 5*/
13 uint16_t adc6; /*< ADC output 6*/
14}) mavlink_ap_adc_t;
15
16#define MAVLINK_MSG_ID_AP_ADC_LEN 12
17#define MAVLINK_MSG_ID_AP_ADC_MIN_LEN 12
18#define MAVLINK_MSG_ID_153_LEN 12
19#define MAVLINK_MSG_ID_153_MIN_LEN 12
20
21#define MAVLINK_MSG_ID_AP_ADC_CRC 188
22#define MAVLINK_MSG_ID_153_CRC 188
23
24
25
26#if MAVLINK_COMMAND_24BIT
27#define MAVLINK_MESSAGE_INFO_AP_ADC { \
28 153, \
29 "AP_ADC", \
30 6, \
31 { { "adc1", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_ap_adc_t, adc1) }, \
32 { "adc2", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_ap_adc_t, adc2) }, \
33 { "adc3", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_ap_adc_t, adc3) }, \
34 { "adc4", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_ap_adc_t, adc4) }, \
35 { "adc5", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_ap_adc_t, adc5) }, \
36 { "adc6", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_ap_adc_t, adc6) }, \
37 } \
38}
39#else
40#define MAVLINK_MESSAGE_INFO_AP_ADC { \
41 "AP_ADC", \
42 6, \
43 { { "adc1", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_ap_adc_t, adc1) }, \
44 { "adc2", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_ap_adc_t, adc2) }, \
45 { "adc3", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_ap_adc_t, adc3) }, \
46 { "adc4", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_ap_adc_t, adc4) }, \
47 { "adc5", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_ap_adc_t, adc5) }, \
48 { "adc6", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_ap_adc_t, adc6) }, \
49 } \
50}
51#endif
52
53/**
54 * @brief Pack a ap_adc 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 adc1 ADC output 1
60 * @param adc2 ADC output 2
61 * @param adc3 ADC output 3
62 * @param adc4 ADC output 4
63 * @param adc5 ADC output 5
64 * @param adc6 ADC output 6
65 * @return length of the message in bytes (excluding serial stream start sign)
66 */
67static inline uint16_t mavlink_msg_ap_adc_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
68 uint16_t adc1, uint16_t adc2, uint16_t adc3, uint16_t adc4, uint16_t adc5, uint16_t adc6)
69{
70#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 char buf[MAVLINK_MSG_ID_AP_ADC_LEN];
72 _mav_put_uint16_t(buf, 0, adc1);
73 _mav_put_uint16_t(buf, 2, adc2);
74 _mav_put_uint16_t(buf, 4, adc3);
75 _mav_put_uint16_t(buf, 6, adc4);
76 _mav_put_uint16_t(buf, 8, adc5);
77 _mav_put_uint16_t(buf, 10, adc6);
78
79 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AP_ADC_LEN);
80#else
81 mavlink_ap_adc_t packet;
82 packet.adc1 = adc1;
83 packet.adc2 = adc2;
84 packet.adc3 = adc3;
85 packet.adc4 = adc4;
86 packet.adc5 = adc5;
87 packet.adc6 = adc6;
88
89 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AP_ADC_LEN);
90#endif
91
92 msg->msgid = MAVLINK_MSG_ID_AP_ADC;
93 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AP_ADC_MIN_LEN, MAVLINK_MSG_ID_AP_ADC_LEN, MAVLINK_MSG_ID_AP_ADC_CRC);
94}
95
96/**
97 * @brief Pack a ap_adc 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 adc1 ADC output 1
103 * @param adc2 ADC output 2
104 * @param adc3 ADC output 3
105 * @param adc4 ADC output 4
106 * @param adc5 ADC output 5
107 * @param adc6 ADC output 6
108 * @return length of the message in bytes (excluding serial stream start sign)
109 */
110static inline uint16_t mavlink_msg_ap_adc_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
111 mavlink_message_t* msg,
112 uint16_t adc1,uint16_t adc2,uint16_t adc3,uint16_t adc4,uint16_t adc5,uint16_t adc6)
113{
114#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
115 char buf[MAVLINK_MSG_ID_AP_ADC_LEN];
116 _mav_put_uint16_t(buf, 0, adc1);
117 _mav_put_uint16_t(buf, 2, adc2);
118 _mav_put_uint16_t(buf, 4, adc3);
119 _mav_put_uint16_t(buf, 6, adc4);
120 _mav_put_uint16_t(buf, 8, adc5);
121 _mav_put_uint16_t(buf, 10, adc6);
122
123 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AP_ADC_LEN);
124#else
125 mavlink_ap_adc_t packet;
126 packet.adc1 = adc1;
127 packet.adc2 = adc2;
128 packet.adc3 = adc3;
129 packet.adc4 = adc4;
130 packet.adc5 = adc5;
131 packet.adc6 = adc6;
132
133 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AP_ADC_LEN);
134#endif
135
136 msg->msgid = MAVLINK_MSG_ID_AP_ADC;
137 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_AP_ADC_MIN_LEN, MAVLINK_MSG_ID_AP_ADC_LEN, MAVLINK_MSG_ID_AP_ADC_CRC);
138}
139
140/**
141 * @brief Encode a ap_adc 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 ap_adc C-struct to read the message contents from
147 */
148static inline uint16_t mavlink_msg_ap_adc_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_ap_adc_t* ap_adc)
149{
150 return mavlink_msg_ap_adc_pack(system_id, component_id, msg, ap_adc->adc1, ap_adc->adc2, ap_adc->adc3, ap_adc->adc4, ap_adc->adc5, ap_adc->adc6);
151}
152
153/**
154 * @brief Encode a ap_adc 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 ap_adc C-struct to read the message contents from
161 */
162static inline uint16_t mavlink_msg_ap_adc_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_ap_adc_t* ap_adc)
163{
164 return mavlink_msg_ap_adc_pack_chan(system_id, component_id, chan, msg, ap_adc->adc1, ap_adc->adc2, ap_adc->adc3, ap_adc->adc4, ap_adc->adc5, ap_adc->adc6);
165}
166
167/**
168 * @brief Send a ap_adc message
169 * @param chan MAVLink channel to send the message
170 *
171 * @param adc1 ADC output 1
172 * @param adc2 ADC output 2
173 * @param adc3 ADC output 3
174 * @param adc4 ADC output 4
175 * @param adc5 ADC output 5
176 * @param adc6 ADC output 6
177 */
178#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
179
180static inline void mavlink_msg_ap_adc_send(mavlink_channel_t chan, uint16_t adc1, uint16_t adc2, uint16_t adc3, uint16_t adc4, uint16_t adc5, uint16_t adc6)
181{
182#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
183 char buf[MAVLINK_MSG_ID_AP_ADC_LEN];
184 _mav_put_uint16_t(buf, 0, adc1);
185 _mav_put_uint16_t(buf, 2, adc2);
186 _mav_put_uint16_t(buf, 4, adc3);
187 _mav_put_uint16_t(buf, 6, adc4);
188 _mav_put_uint16_t(buf, 8, adc5);
189 _mav_put_uint16_t(buf, 10, adc6);
190
191 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AP_ADC, buf, MAVLINK_MSG_ID_AP_ADC_MIN_LEN, MAVLINK_MSG_ID_AP_ADC_LEN, MAVLINK_MSG_ID_AP_ADC_CRC);
192#else
193 mavlink_ap_adc_t packet;
194 packet.adc1 = adc1;
195 packet.adc2 = adc2;
196 packet.adc3 = adc3;
197 packet.adc4 = adc4;
198 packet.adc5 = adc5;
199 packet.adc6 = adc6;
200
201 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AP_ADC, (const char *)&packet, MAVLINK_MSG_ID_AP_ADC_MIN_LEN, MAVLINK_MSG_ID_AP_ADC_LEN, MAVLINK_MSG_ID_AP_ADC_CRC);
202#endif
203}
204
205/**
206 * @brief Send a ap_adc message
207 * @param chan MAVLink channel to send the message
208 * @param struct The MAVLink struct to serialize
209 */
210static inline void mavlink_msg_ap_adc_send_struct(mavlink_channel_t chan, const mavlink_ap_adc_t* ap_adc)
211{
212#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
213 mavlink_msg_ap_adc_send(chan, ap_adc->adc1, ap_adc->adc2, ap_adc->adc3, ap_adc->adc4, ap_adc->adc5, ap_adc->adc6);
214#else
215 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AP_ADC, (const char *)ap_adc, MAVLINK_MSG_ID_AP_ADC_MIN_LEN, MAVLINK_MSG_ID_AP_ADC_LEN, MAVLINK_MSG_ID_AP_ADC_CRC);
216#endif
217}
218
219#if MAVLINK_MSG_ID_AP_ADC_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_ap_adc_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t adc1, uint16_t adc2, uint16_t adc3, uint16_t adc4, uint16_t adc5, uint16_t adc6)
228{
229#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
230 char *buf = (char *)msgbuf;
231 _mav_put_uint16_t(buf, 0, adc1);
232 _mav_put_uint16_t(buf, 2, adc2);
233 _mav_put_uint16_t(buf, 4, adc3);
234 _mav_put_uint16_t(buf, 6, adc4);
235 _mav_put_uint16_t(buf, 8, adc5);
236 _mav_put_uint16_t(buf, 10, adc6);
237
238 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AP_ADC, buf, MAVLINK_MSG_ID_AP_ADC_MIN_LEN, MAVLINK_MSG_ID_AP_ADC_LEN, MAVLINK_MSG_ID_AP_ADC_CRC);
239#else
240 mavlink_ap_adc_t *packet = (mavlink_ap_adc_t *)msgbuf;
241 packet->adc1 = adc1;
242 packet->adc2 = adc2;
243 packet->adc3 = adc3;
244 packet->adc4 = adc4;
245 packet->adc5 = adc5;
246 packet->adc6 = adc6;
247
248 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AP_ADC, (const char *)packet, MAVLINK_MSG_ID_AP_ADC_MIN_LEN, MAVLINK_MSG_ID_AP_ADC_LEN, MAVLINK_MSG_ID_AP_ADC_CRC);
249#endif
250}
251#endif
252
253#endif
254
255// MESSAGE AP_ADC UNPACKING
256
257
258/**
259 * @brief Get field adc1 from ap_adc message
260 *
261 * @return ADC output 1
262 */
263static inline uint16_t mavlink_msg_ap_adc_get_adc1(const mavlink_message_t* msg)
264{
265 return _MAV_RETURN_uint16_t(msg, 0);
266}
267
268/**
269 * @brief Get field adc2 from ap_adc message
270 *
271 * @return ADC output 2
272 */
273static inline uint16_t mavlink_msg_ap_adc_get_adc2(const mavlink_message_t* msg)
274{
275 return _MAV_RETURN_uint16_t(msg, 2);
276}
277
278/**
279 * @brief Get field adc3 from ap_adc message
280 *
281 * @return ADC output 3
282 */
283static inline uint16_t mavlink_msg_ap_adc_get_adc3(const mavlink_message_t* msg)
284{
285 return _MAV_RETURN_uint16_t(msg, 4);
286}
287
288/**
289 * @brief Get field adc4 from ap_adc message
290 *
291 * @return ADC output 4
292 */
293static inline uint16_t mavlink_msg_ap_adc_get_adc4(const mavlink_message_t* msg)
294{
295 return _MAV_RETURN_uint16_t(msg, 6);
296}
297
298/**
299 * @brief Get field adc5 from ap_adc message
300 *
301 * @return ADC output 5
302 */
303static inline uint16_t mavlink_msg_ap_adc_get_adc5(const mavlink_message_t* msg)
304{
305 return _MAV_RETURN_uint16_t(msg, 8);
306}
307
308/**
309 * @brief Get field adc6 from ap_adc message
310 *
311 * @return ADC output 6
312 */
313static inline uint16_t mavlink_msg_ap_adc_get_adc6(const mavlink_message_t* msg)
314{
315 return _MAV_RETURN_uint16_t(msg, 10);
316}
317
318/**
319 * @brief Decode a ap_adc message into a struct
320 *
321 * @param msg The message to decode
322 * @param ap_adc C-struct to decode the message contents into
323 */
324static inline void mavlink_msg_ap_adc_decode(const mavlink_message_t* msg, mavlink_ap_adc_t* ap_adc)
325{
326#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
327 ap_adc->adc1 = mavlink_msg_ap_adc_get_adc1(msg);
328 ap_adc->adc2 = mavlink_msg_ap_adc_get_adc2(msg);
329 ap_adc->adc3 = mavlink_msg_ap_adc_get_adc3(msg);
330 ap_adc->adc4 = mavlink_msg_ap_adc_get_adc4(msg);
331 ap_adc->adc5 = mavlink_msg_ap_adc_get_adc5(msg);
332 ap_adc->adc6 = mavlink_msg_ap_adc_get_adc6(msg);
333#else
334 uint8_t len = msg->len < MAVLINK_MSG_ID_AP_ADC_LEN? msg->len : MAVLINK_MSG_ID_AP_ADC_LEN;
335 memset(ap_adc, 0, MAVLINK_MSG_ID_AP_ADC_LEN);
336 memcpy(ap_adc, _MAV_PAYLOAD(msg), len);
337#endif
338}