Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_mission_count.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE MISSION_COUNT PACKING
3
4#define MAVLINK_MSG_ID_MISSION_COUNT 44
5
6MAVPACKED(
7typedef struct __mavlink_mission_count_t {
8 uint16_t count; /*< Number of mission items in the sequence*/
9 uint8_t target_system; /*< System ID*/
10 uint8_t target_component; /*< Component ID*/
11 uint8_t mission_type; /*< Mission type.*/
12 uint32_t opaque_id; /*< Id of current on-vehicle mission, fence, or rally point plan (on download from vehicle).
13 This field is used when downloading a plan from a vehicle to a GCS.
14 0 on upload to the vehicle from GCS.
15 0 if plan ids are not supported.
16 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.
17 The ids are recalculated by the vehicle when any part of the on-vehicle plan changes (when a new plan is uploaded, the vehicle returns the new id to the GCS in MISSION_ACK).
18 */
19}) mavlink_mission_count_t;
20
21#define MAVLINK_MSG_ID_MISSION_COUNT_LEN 9
22#define MAVLINK_MSG_ID_MISSION_COUNT_MIN_LEN 4
23#define MAVLINK_MSG_ID_44_LEN 9
24#define MAVLINK_MSG_ID_44_MIN_LEN 4
25
26#define MAVLINK_MSG_ID_MISSION_COUNT_CRC 221
27#define MAVLINK_MSG_ID_44_CRC 221
28
29
30
31#if MAVLINK_COMMAND_24BIT
32#define MAVLINK_MESSAGE_INFO_MISSION_COUNT {
33 44,
34 "MISSION_COUNT",
35 5,
36 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_mission_count_t, target_system) },
37 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_mission_count_t, target_component) },
38 { "count", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_mission_count_t, count) },
39 { "mission_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_mission_count_t, mission_type) },
40 { "opaque_id", NULL, MAVLINK_TYPE_UINT32_T, 0, 5, offsetof(mavlink_mission_count_t, opaque_id) },
41 } \
42}
43#else
44#define MAVLINK_MESSAGE_INFO_MISSION_COUNT {
45 "MISSION_COUNT",
46 5,
47 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_mission_count_t, target_system) },
48 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_mission_count_t, target_component) },
49 { "count", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_mission_count_t, count) },
50 { "mission_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_mission_count_t, mission_type) },
51 { "opaque_id", NULL, MAVLINK_TYPE_UINT32_T, 0, 5, offsetof(mavlink_mission_count_t, opaque_id) },
52 } \
53}
54#endif
55
56/**
57 * @brief Pack a mission_count 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 count Number of mission items in the sequence
65 * @param mission_type Mission type.
66 * @param opaque_id Id of current on-vehicle mission, fence, or rally point plan (on download from vehicle).
67 This field is used when downloading a plan from a vehicle to a GCS.
68 0 on upload to the vehicle from GCS.
69 0 if plan ids are not supported.
70 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.
71 The ids are recalculated by the vehicle when any part of the on-vehicle plan changes (when a new plan is uploaded, the vehicle returns the new id to the GCS in MISSION_ACK).
72
73 * @return length of the message in bytes (excluding serial stream start sign)
74 */
75static inline uint16_t mavlink_msg_mission_count_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
76 uint8_t target_system, uint8_t target_component, uint16_t count, uint8_t mission_type, uint32_t opaque_id)
77{
78#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
80 _mav_put_uint16_t(buf, 0, count);
81 _mav_put_uint8_t(buf, 2, target_system);
82 _mav_put_uint8_t(buf, 3, target_component);
83 _mav_put_uint8_t(buf, 4, mission_type);
84 _mav_put_uint32_t(buf, 5, opaque_id);
85
86 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_COUNT_LEN);
87#else
88 mavlink_mission_count_t packet;
89 packet.count = count;
90 packet.target_system = target_system;
91 packet.target_component = target_component;
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_COUNT_LEN);
96#endif
97
99 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_COUNT_MIN_LEN, MAVLINK_MSG_ID_MISSION_COUNT_LEN, MAVLINK_MSG_ID_MISSION_COUNT_CRC);
100}
101
102/**
103 * @brief Pack a mission_count 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 count Number of mission items in the sequence
112 * @param mission_type Mission type.
113 * @param opaque_id Id of current on-vehicle mission, fence, or rally point plan (on download from vehicle).
114 This field is used when downloading a plan from a vehicle to a GCS.
115 0 on upload to the vehicle from GCS.
116 0 if plan ids are not supported.
117 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.
118 The ids are recalculated by the vehicle when any part of the on-vehicle plan changes (when a new plan is uploaded, the vehicle returns the new id to the GCS in MISSION_ACK).
119
120 * @return length of the message in bytes (excluding serial stream start sign)
121 */
122static inline uint16_t mavlink_msg_mission_count_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, uint16_t count, uint8_t mission_type, uint32_t opaque_id)
124{
125#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
127 _mav_put_uint16_t(buf, 0, count);
128 _mav_put_uint8_t(buf, 2, target_system);
129 _mav_put_uint8_t(buf, 3, target_component);
130 _mav_put_uint8_t(buf, 4, mission_type);
131 _mav_put_uint32_t(buf, 5, opaque_id);
132
133 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_COUNT_LEN);
134#else
135 mavlink_mission_count_t packet;
136 packet.count = count;
137 packet.target_system = target_system;
138 packet.target_component = target_component;
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_COUNT_LEN);
143#endif
144
145 msg->msgid = MAVLINK_MSG_ID_MISSION_COUNT;
146#if MAVLINK_CRC_EXTRA
147 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_COUNT_MIN_LEN, MAVLINK_MSG_ID_MISSION_COUNT_LEN, MAVLINK_MSG_ID_MISSION_COUNT_CRC);
148#else
149 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_COUNT_MIN_LEN, MAVLINK_MSG_ID_MISSION_COUNT_LEN);
150#endif
151}
152
153/**
154 * @brief Pack a mission_count 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 count Number of mission items in the sequence
162 * @param mission_type Mission type.
163 * @param opaque_id Id of current on-vehicle mission, fence, or rally point plan (on download from vehicle).
164 This field is used when downloading a plan from a vehicle to a GCS.
165 0 on upload to the vehicle from GCS.
166 0 if plan ids are not supported.
167 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.
168 The ids are recalculated by the vehicle when any part of the on-vehicle plan changes (when a new plan is uploaded, the vehicle returns the new id to the GCS in MISSION_ACK).
169
170 * @return length of the message in bytes (excluding serial stream start sign)
171 */
172static inline uint16_t mavlink_msg_mission_count_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,uint16_t count,uint8_t mission_type,uint32_t opaque_id)
175{
176#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
178 _mav_put_uint16_t(buf, 0, count);
179 _mav_put_uint8_t(buf, 2, target_system);
180 _mav_put_uint8_t(buf, 3, target_component);
181 _mav_put_uint8_t(buf, 4, mission_type);
182 _mav_put_uint32_t(buf, 5, opaque_id);
183
184 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_COUNT_LEN);
185#else
186 mavlink_mission_count_t packet;
187 packet.count = count;
188 packet.target_system = target_system;
189 packet.target_component = target_component;
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_COUNT_LEN);
194#endif
195
196 msg->msgid = MAVLINK_MSG_ID_MISSION_COUNT;
197 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MISSION_COUNT_MIN_LEN, MAVLINK_MSG_ID_MISSION_COUNT_LEN, MAVLINK_MSG_ID_MISSION_COUNT_CRC);
198}
199
200/**
201 * @brief Encode a mission_count 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_count C-struct to read the message contents from
207 */
208static inline uint16_t mavlink_msg_mission_count_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mission_count_t* mission_count)
209{
210 return mavlink_msg_mission_count_pack(system_id, component_id, msg, mission_count->target_system, mission_count->target_component, mission_count->count, mission_count->mission_type, mission_count->opaque_id);
211}
212
213/**
214 * @brief Encode a mission_count 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_count C-struct to read the message contents from
221 */
222static inline uint16_t mavlink_msg_mission_count_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_mission_count_t* mission_count)
223{
224 return mavlink_msg_mission_count_pack_chan(system_id, component_id, chan, msg, mission_count->target_system, mission_count->target_component, mission_count->count, mission_count->mission_type, mission_count->opaque_id);
225}
226
227/**
228 * @brief Encode a mission_count 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_count C-struct to read the message contents from
235 */
236static inline uint16_t mavlink_msg_mission_count_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_count_t* mission_count)
237{
238 return mavlink_msg_mission_count_pack_status(system_id, component_id, _status, msg, mission_count->target_system, mission_count->target_component, mission_count->count, mission_count->mission_type, mission_count->opaque_id);
239}
240
241/**
242 * @brief Send a mission_count 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 count Number of mission items in the sequence
248 * @param mission_type Mission type.
249 * @param opaque_id Id of current on-vehicle mission, fence, or rally point plan (on download from vehicle).
250 This field is used when downloading a plan from a vehicle to a GCS.
251 0 on upload to the vehicle from GCS.
252 0 if plan ids are not supported.
253 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.
254 The ids are recalculated by the vehicle when any part of the on-vehicle plan changes (when a new plan is uploaded, the vehicle returns the new id to the GCS in MISSION_ACK).
255
256 */
257#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
258
259static inline void mavlink_msg_mission_count_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint16_t count, 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_COUNT_LEN];
263 _mav_put_uint16_t(buf, 0, count);
264 _mav_put_uint8_t(buf, 2, target_system);
265 _mav_put_uint8_t(buf, 3, target_component);
266 _mav_put_uint8_t(buf, 4, mission_type);
267 _mav_put_uint32_t(buf, 5, opaque_id);
268
269 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_COUNT, buf, MAVLINK_MSG_ID_MISSION_COUNT_MIN_LEN, MAVLINK_MSG_ID_MISSION_COUNT_LEN, MAVLINK_MSG_ID_MISSION_COUNT_CRC);
270#else
271 mavlink_mission_count_t packet;
272 packet.count = count;
273 packet.target_system = target_system;
274 packet.target_component = target_component;
275 packet.mission_type = mission_type;
276 packet.opaque_id = opaque_id;
277
278 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_COUNT, (const char *)&packet, MAVLINK_MSG_ID_MISSION_COUNT_MIN_LEN, MAVLINK_MSG_ID_MISSION_COUNT_LEN, MAVLINK_MSG_ID_MISSION_COUNT_CRC);
279#endif
280}
281
282/**
283 * @brief Send a mission_count 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_count_send_struct(mavlink_channel_t chan, const mavlink_mission_count_t* mission_count)
288{
289#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
290 mavlink_msg_mission_count_send(chan, mission_count->target_system, mission_count->target_component, mission_count->count, mission_count->mission_type, mission_count->opaque_id);
291#else
292 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_COUNT, (const char *)mission_count, MAVLINK_MSG_ID_MISSION_COUNT_MIN_LEN, MAVLINK_MSG_ID_MISSION_COUNT_LEN, MAVLINK_MSG_ID_MISSION_COUNT_CRC);
293#endif
294}
295
296#if MAVLINK_MSG_ID_MISSION_COUNT_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_count_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint16_t count, 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_uint16_t(buf, 0, count);
309 _mav_put_uint8_t(buf, 2, target_system);
310 _mav_put_uint8_t(buf, 3, target_component);
311 _mav_put_uint8_t(buf, 4, mission_type);
312 _mav_put_uint32_t(buf, 5, opaque_id);
313
314 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_COUNT, buf, MAVLINK_MSG_ID_MISSION_COUNT_MIN_LEN, MAVLINK_MSG_ID_MISSION_COUNT_LEN, MAVLINK_MSG_ID_MISSION_COUNT_CRC);
315#else
316 mavlink_mission_count_t *packet = (mavlink_mission_count_t *)msgbuf;
317 packet->count = count;
318 packet->target_system = target_system;
319 packet->target_component = target_component;
320 packet->mission_type = mission_type;
321 packet->opaque_id = opaque_id;
322
323 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_COUNT, (const char *)packet, MAVLINK_MSG_ID_MISSION_COUNT_MIN_LEN, MAVLINK_MSG_ID_MISSION_COUNT_LEN, MAVLINK_MSG_ID_MISSION_COUNT_CRC);
324#endif
325}
326#endif
327
328#endif
329
330// MESSAGE MISSION_COUNT UNPACKING
331
332
333/**
334 * @brief Get field target_system from mission_count message
335 *
336 * @return System ID
337 */
338static inline uint8_t mavlink_msg_mission_count_get_target_system(const mavlink_message_t* msg)
339{
340 return _MAV_RETURN_uint8_t(msg, 2);
341}
342
343/**
344 * @brief Get field target_component from mission_count message
345 *
346 * @return Component ID
347 */
348static inline uint8_t mavlink_msg_mission_count_get_target_component(const mavlink_message_t* msg)
349{
350 return _MAV_RETURN_uint8_t(msg, 3);
351}
352
353/**
354 * @brief Get field count from mission_count message
355 *
356 * @return Number of mission items in the sequence
357 */
358static inline uint16_t mavlink_msg_mission_count_get_count(const mavlink_message_t* msg)
359{
360 return _MAV_RETURN_uint16_t(msg, 0);
361}
362
363/**
364 * @brief Get field mission_type from mission_count message
365 *
366 * @return Mission type.
367 */
368static inline uint8_t mavlink_msg_mission_count_get_mission_type(const mavlink_message_t* msg)
369{
370 return _MAV_RETURN_uint8_t(msg, 4);
371}
372
373/**
374 * @brief Get field opaque_id from mission_count message
375 *
376 * @return Id of current on-vehicle mission, fence, or rally point plan (on download from vehicle).
377 This field is used when downloading a plan from a vehicle to a GCS.
378 0 on upload to the vehicle from GCS.
379 0 if plan ids are not supported.
380 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.
381 The ids are recalculated by the vehicle when any part of the on-vehicle plan changes (when a new plan is uploaded, the vehicle returns the new id to the GCS in MISSION_ACK).
382
383 */
384static inline uint32_t mavlink_msg_mission_count_get_opaque_id(const mavlink_message_t* msg)
385{
386 return _MAV_RETURN_uint32_t(msg, 5);
387}
388
389/**
390 * @brief Decode a mission_count message into a struct
391 *
392 * @param msg The message to decode
393 * @param mission_count C-struct to decode the message contents into
394 */
395static inline void mavlink_msg_mission_count_decode(const mavlink_message_t* msg, mavlink_mission_count_t* mission_count)
396{
397#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
398 mission_count->count = mavlink_msg_mission_count_get_count(msg);
399 mission_count->target_system = mavlink_msg_mission_count_get_target_system(msg);
400 mission_count->target_component = mavlink_msg_mission_count_get_target_component(msg);
401 mission_count->mission_type = mavlink_msg_mission_count_get_mission_type(msg);
402 mission_count->opaque_id = mavlink_msg_mission_count_get_opaque_id(msg);
403#else
404 uint8_t len = msg->len < MAVLINK_MSG_ID_MISSION_COUNT_LEN? msg->len : MAVLINK_MSG_ID_MISSION_COUNT_LEN;
405 memset(mission_count, 0, MAVLINK_MSG_ID_MISSION_COUNT_LEN);
406 memcpy(mission_count, _MAV_PAYLOAD(msg), len);
407#endif
408}