Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_mission_ack.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE MISSION_ACK PACKING
3
4#define MAVLINK_MSG_ID_MISSION_ACK 47
5
6
7typedef struct __mavlink_mission_ack_t {
8 uint8_t target_system; /*< System ID*/
9 uint8_t target_component; /*< Component ID*/
10 uint8_t type; /*< Mission result.*/
11 uint8_t mission_type; /*< Mission type.*/
12 uint32_t opaque_id; /*< Id of new on-vehicle mission, fence, or rally point plan (on upload to vehicle).
13 The id is calculated and returned by a vehicle when a new plan is uploaded by a GCS.
14 The only requirement on the id is that it must change when there is any change to the on-vehicle plan type (there is no requirement that the id be globally unique).
15 0 on download from the vehicle to the GCS (on download the ID is set in MISSION_COUNT).
16 0 if plan ids are not supported.
17 The current on-vehicle plan ids are streamed in `MISSION_CURRENT`, allowing a GCS to determine if any part of the plan has changed and needs to be re-uploaded.
18 */
19} mavlink_mission_ack_t;
20
21#define MAVLINK_MSG_ID_MISSION_ACK_LEN 8
22#define MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN 3
23#define MAVLINK_MSG_ID_47_LEN 8
24#define MAVLINK_MSG_ID_47_MIN_LEN 3
25
26#define MAVLINK_MSG_ID_MISSION_ACK_CRC 153
27#define MAVLINK_MSG_ID_47_CRC 153
28
29
30
31#if MAVLINK_COMMAND_24BIT
32#define MAVLINK_MESSAGE_INFO_MISSION_ACK {
33 47,
34 "MISSION_ACK",
35 5,
36 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_mission_ack_t, target_system) },
37 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_mission_ack_t, target_component) },
38 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_mission_ack_t, type) },
39 { "mission_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_mission_ack_t, mission_type) },
40 { "opaque_id", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_mission_ack_t, opaque_id) },
41 } \
42}
43#else
44#define MAVLINK_MESSAGE_INFO_MISSION_ACK {
45 "MISSION_ACK",
46 5,
47 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_mission_ack_t, target_system) },
48 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_mission_ack_t, target_component) },
49 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_mission_ack_t, type) },
50 { "mission_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_mission_ack_t, mission_type) },
51 { "opaque_id", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_mission_ack_t, opaque_id) },
52 } \
53}
54#endif
55
56/**
57 * @brief Pack a mission_ack message
58 * @param system_id ID of this system
59 * @param component_id ID of this component (e.g. 200 for IMU)
60 * @param msg The MAVLink message to compress the data into
61 *
62 * @param target_system System ID
63 * @param target_component Component ID
64 * @param type Mission result.
65 * @param mission_type Mission type.
66 * @param opaque_id Id of new on-vehicle mission, fence, or rally point plan (on upload to vehicle).
67 The id is calculated and returned by a vehicle when a new plan is uploaded by a GCS.
68 The only requirement on the id is that it must change when there is any change to the on-vehicle plan type (there is no requirement that the id be globally unique).
69 0 on download from the vehicle to the GCS (on download the ID is set in MISSION_COUNT).
70 0 if plan ids are not supported.
71 The current on-vehicle plan ids are streamed in `MISSION_CURRENT`, allowing a GCS to determine if any part of the plan has changed and needs to be re-uploaded.
72
73 * @return length of the message in bytes (excluding serial stream start sign)
74 */
75static inline uint16_t mavlink_msg_mission_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
76 uint8_t target_system, uint8_t target_component, uint8_t type, uint8_t mission_type, uint32_t opaque_id)
77{
78#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
80 _mav_put_uint8_t(buf, 0, target_system);
81 _mav_put_uint8_t(buf, 1, target_component);
82 _mav_put_uint8_t(buf, 2, type);
83 _mav_put_uint8_t(buf, 3, mission_type);
84 _mav_put_uint32_t(buf, 4, opaque_id);
85
86 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ACK_LEN);
87#else
88 mavlink_mission_ack_t packet;
89 packet.target_system = target_system;
90 packet.target_component = target_component;
91 packet.type = type;
92 packet.mission_type = mission_type;
93 packet.opaque_id = opaque_id;
94
95 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ACK_LEN);
96#endif
97
98 msg->msgid = MAVLINK_MSG_ID_MISSION_ACK;
99 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
100}
101
102/**
103 * @brief Pack a mission_ack message
104 * @param system_id ID of this system
105 * @param component_id ID of this component (e.g. 200 for IMU)
106 * @param status MAVLink status structure
107 * @param msg The MAVLink message to compress the data into
108 *
109 * @param target_system System ID
110 * @param target_component Component ID
111 * @param type Mission result.
112 * @param mission_type Mission type.
113 * @param opaque_id Id of new on-vehicle mission, fence, or rally point plan (on upload to vehicle).
114 The id is calculated and returned by a vehicle when a new plan is uploaded by a GCS.
115 The only requirement on the id is that it must change when there is any change to the on-vehicle plan type (there is no requirement that the id be globally unique).
116 0 on download from the vehicle to the GCS (on download the ID is set in MISSION_COUNT).
117 0 if plan ids are not supported.
118 The current on-vehicle plan ids are streamed in `MISSION_CURRENT`, allowing a GCS to determine if any part of the plan has changed and needs to be re-uploaded.
119
120 * @return length of the message in bytes (excluding serial stream start sign)
121 */
122static inline uint16_t mavlink_msg_mission_ack_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
123 uint8_t target_system, uint8_t target_component, uint8_t type, uint8_t mission_type, uint32_t opaque_id)
124{
125#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
127 _mav_put_uint8_t(buf, 0, target_system);
128 _mav_put_uint8_t(buf, 1, target_component);
129 _mav_put_uint8_t(buf, 2, type);
130 _mav_put_uint8_t(buf, 3, mission_type);
131 _mav_put_uint32_t(buf, 4, opaque_id);
132
133 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ACK_LEN);
134#else
135 mavlink_mission_ack_t packet;
136 packet.target_system = target_system;
137 packet.target_component = target_component;
138 packet.type = type;
139 packet.mission_type = mission_type;
140 packet.opaque_id = opaque_id;
141
142 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ACK_LEN);
143#endif
144
145 msg->msgid = MAVLINK_MSG_ID_MISSION_ACK;
146#if MAVLINK_CRC_EXTRA
147 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
148#else
149 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN);
150#endif
151}
152
153/**
154 * @brief Pack a mission_ack message on a channel
155 * @param system_id ID of this system
156 * @param component_id ID of this component (e.g. 200 for IMU)
157 * @param chan The MAVLink channel this message will be sent over
158 * @param msg The MAVLink message to compress the data into
159 * @param target_system System ID
160 * @param target_component Component ID
161 * @param type Mission result.
162 * @param mission_type Mission type.
163 * @param opaque_id Id of new on-vehicle mission, fence, or rally point plan (on upload to vehicle).
164 The id is calculated and returned by a vehicle when a new plan is uploaded by a GCS.
165 The only requirement on the id is that it must change when there is any change to the on-vehicle plan type (there is no requirement that the id be globally unique).
166 0 on download from the vehicle to the GCS (on download the ID is set in MISSION_COUNT).
167 0 if plan ids are not supported.
168 The current on-vehicle plan ids are streamed in `MISSION_CURRENT`, allowing a GCS to determine if any part of the plan has changed and needs to be re-uploaded.
169
170 * @return length of the message in bytes (excluding serial stream start sign)
171 */
172static inline uint16_t mavlink_msg_mission_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
173 mavlink_message_t* msg,
174 uint8_t target_system,uint8_t target_component,uint8_t type,uint8_t mission_type,uint32_t opaque_id)
175{
176#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
178 _mav_put_uint8_t(buf, 0, target_system);
179 _mav_put_uint8_t(buf, 1, target_component);
180 _mav_put_uint8_t(buf, 2, type);
181 _mav_put_uint8_t(buf, 3, mission_type);
182 _mav_put_uint32_t(buf, 4, opaque_id);
183
184 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ACK_LEN);
185#else
186 mavlink_mission_ack_t packet;
187 packet.target_system = target_system;
188 packet.target_component = target_component;
189 packet.type = type;
190 packet.mission_type = mission_type;
191 packet.opaque_id = opaque_id;
192
193 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ACK_LEN);
194#endif
195
196 msg->msgid = MAVLINK_MSG_ID_MISSION_ACK;
197 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
198}
199
200/**
201 * @brief Encode a mission_ack struct
202 *
203 * @param system_id ID of this system
204 * @param component_id ID of this component (e.g. 200 for IMU)
205 * @param msg The MAVLink message to compress the data into
206 * @param mission_ack C-struct to read the message contents from
207 */
208static inline uint16_t mavlink_msg_mission_ack_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mission_ack_t* mission_ack)
209{
210 return mavlink_msg_mission_ack_pack(system_id, component_id, msg, mission_ack->target_system, mission_ack->target_component, mission_ack->type, mission_ack->mission_type, mission_ack->opaque_id);
211}
212
213/**
214 * @brief Encode a mission_ack struct on a channel
215 *
216 * @param system_id ID of this system
217 * @param component_id ID of this component (e.g. 200 for IMU)
218 * @param chan The MAVLink channel this message will be sent over
219 * @param msg The MAVLink message to compress the data into
220 * @param mission_ack C-struct to read the message contents from
221 */
222static inline uint16_t mavlink_msg_mission_ack_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_mission_ack_t* mission_ack)
223{
224 return mavlink_msg_mission_ack_pack_chan(system_id, component_id, chan, msg, mission_ack->target_system, mission_ack->target_component, mission_ack->type, mission_ack->mission_type, mission_ack->opaque_id);
225}
226
227/**
228 * @brief Encode a mission_ack struct with provided status structure
229 *
230 * @param system_id ID of this system
231 * @param component_id ID of this component (e.g. 200 for IMU)
232 * @param status MAVLink status structure
233 * @param msg The MAVLink message to compress the data into
234 * @param mission_ack C-struct to read the message contents from
235 */
236static inline uint16_t mavlink_msg_mission_ack_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_ack_t* mission_ack)
237{
238 return mavlink_msg_mission_ack_pack_status(system_id, component_id, _status, msg, mission_ack->target_system, mission_ack->target_component, mission_ack->type, mission_ack->mission_type, mission_ack->opaque_id);
239}
240
241/**
242 * @brief Send a mission_ack message
243 * @param chan MAVLink channel to send the message
244 *
245 * @param target_system System ID
246 * @param target_component Component ID
247 * @param type Mission result.
248 * @param mission_type Mission type.
249 * @param opaque_id Id of new on-vehicle mission, fence, or rally point plan (on upload to vehicle).
250 The id is calculated and returned by a vehicle when a new plan is uploaded by a GCS.
251 The only requirement on the id is that it must change when there is any change to the on-vehicle plan type (there is no requirement that the id be globally unique).
252 0 on download from the vehicle to the GCS (on download the ID is set in MISSION_COUNT).
253 0 if plan ids are not supported.
254 The current on-vehicle plan ids are streamed in `MISSION_CURRENT`, allowing a GCS to determine if any part of the plan has changed and needs to be re-uploaded.
255
256 */
257#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
258
259static inline void mavlink_msg_mission_ack_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t type, uint8_t mission_type, uint32_t opaque_id)
260{
261#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
262 char buf[MAVLINK_MSG_ID_MISSION_ACK_LEN];
263 _mav_put_uint8_t(buf, 0, target_system);
264 _mav_put_uint8_t(buf, 1, target_component);
265 _mav_put_uint8_t(buf, 2, type);
266 _mav_put_uint8_t(buf, 3, mission_type);
267 _mav_put_uint32_t(buf, 4, opaque_id);
268
269 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, buf, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
270#else
271 mavlink_mission_ack_t packet;
272 packet.target_system = target_system;
273 packet.target_component = target_component;
274 packet.type = type;
275 packet.mission_type = mission_type;
276 packet.opaque_id = opaque_id;
277
278 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, (const char *)&packet, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
279#endif
280}
281
282/**
283 * @brief Send a mission_ack message
284 * @param chan MAVLink channel to send the message
285 * @param struct The MAVLink struct to serialize
286 */
287static inline void mavlink_msg_mission_ack_send_struct(mavlink_channel_t chan, const mavlink_mission_ack_t* mission_ack)
288{
289#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
290 mavlink_msg_mission_ack_send(chan, mission_ack->target_system, mission_ack->target_component, mission_ack->type, mission_ack->mission_type, mission_ack->opaque_id);
291#else
292 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, (const char *)mission_ack, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
293#endif
294}
295
296#if MAVLINK_MSG_ID_MISSION_ACK_LEN <= MAVLINK_MAX_PAYLOAD_LEN
297/*
298 This variant of _send() can be used to save stack space by reusing
299 memory from the receive buffer. The caller provides a
300 mavlink_message_t which is the size of a full mavlink message. This
301 is usually the receive buffer for the channel, and allows a reply to an
302 incoming message with minimum stack space usage.
303 */
304static inline void mavlink_msg_mission_ack_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t type, uint8_t mission_type, uint32_t opaque_id)
305{
306#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
307 char *buf = (char *)msgbuf;
308 _mav_put_uint8_t(buf, 0, target_system);
309 _mav_put_uint8_t(buf, 1, target_component);
310 _mav_put_uint8_t(buf, 2, type);
311 _mav_put_uint8_t(buf, 3, mission_type);
312 _mav_put_uint32_t(buf, 4, opaque_id);
313
314 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, buf, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
315#else
316 mavlink_mission_ack_t *packet = (mavlink_mission_ack_t *)msgbuf;
317 packet->target_system = target_system;
318 packet->target_component = target_component;
319 packet->type = type;
320 packet->mission_type = mission_type;
321 packet->opaque_id = opaque_id;
322
323 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, (const char *)packet, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
324#endif
325}
326#endif
327
328#endif
329
330// MESSAGE MISSION_ACK UNPACKING
331
332
333/**
334 * @brief Get field target_system from mission_ack message
335 *
336 * @return System ID
337 */
338static inline uint8_t mavlink_msg_mission_ack_get_target_system(const mavlink_message_t* msg)
339{
340 return _MAV_RETURN_uint8_t(msg, 0);
341}
342
343/**
344 * @brief Get field target_component from mission_ack message
345 *
346 * @return Component ID
347 */
348static inline uint8_t mavlink_msg_mission_ack_get_target_component(const mavlink_message_t* msg)
349{
350 return _MAV_RETURN_uint8_t(msg, 1);
351}
352
353/**
354 * @brief Get field type from mission_ack message
355 *
356 * @return Mission result.
357 */
358static inline uint8_t mavlink_msg_mission_ack_get_type(const mavlink_message_t* msg)
359{
360 return _MAV_RETURN_uint8_t(msg, 2);
361}
362
363/**
364 * @brief Get field mission_type from mission_ack message
365 *
366 * @return Mission type.
367 */
368static inline uint8_t mavlink_msg_mission_ack_get_mission_type(const mavlink_message_t* msg)
369{
370 return _MAV_RETURN_uint8_t(msg, 3);
371}
372
373/**
374 * @brief Get field opaque_id from mission_ack message
375 *
376 * @return Id of new on-vehicle mission, fence, or rally point plan (on upload to vehicle).
377 The id is calculated and returned by a vehicle when a new plan is uploaded by a GCS.
378 The only requirement on the id is that it must change when there is any change to the on-vehicle plan type (there is no requirement that the id be globally unique).
379 0 on download from the vehicle to the GCS (on download the ID is set in MISSION_COUNT).
380 0 if plan ids are not supported.
381 The current on-vehicle plan ids are streamed in `MISSION_CURRENT`, allowing a GCS to determine if any part of the plan has changed and needs to be re-uploaded.
382
383 */
384static inline uint32_t mavlink_msg_mission_ack_get_opaque_id(const mavlink_message_t* msg)
385{
386 return _MAV_RETURN_uint32_t(msg, 4);
387}
388
389/**
390 * @brief Decode a mission_ack message into a struct
391 *
392 * @param msg The message to decode
393 * @param mission_ack C-struct to decode the message contents into
394 */
395static inline void mavlink_msg_mission_ack_decode(const mavlink_message_t* msg, mavlink_mission_ack_t* mission_ack)
396{
397#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
398 mission_ack->target_system = mavlink_msg_mission_ack_get_target_system(msg);
399 mission_ack->target_component = mavlink_msg_mission_ack_get_target_component(msg);
400 mission_ack->type = mavlink_msg_mission_ack_get_type(msg);
401 mission_ack->mission_type = mavlink_msg_mission_ack_get_mission_type(msg);
402 mission_ack->opaque_id = mavlink_msg_mission_ack_get_opaque_id(msg);
403#else
404 uint8_t len = msg->len < MAVLINK_MSG_ID_MISSION_ACK_LEN? msg->len : MAVLINK_MSG_ID_MISSION_ACK_LEN;
405 memset(mission_ack, 0, MAVLINK_MSG_ID_MISSION_ACK_LEN);
406 memcpy(mission_ack, _MAV_PAYLOAD(msg), len);
407#endif
408}