Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_command_cancel.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE COMMAND_CANCEL PACKING
3
4#define MAVLINK_MSG_ID_COMMAND_CANCEL 80
5
6
8 uint16_t command; /*< Command ID (of command to cancel).*/
9 uint8_t target_system; /*< System executing long running command. Should not be broadcast (0).*/
10 uint8_t target_component; /*< Component executing long running command.*/
11} mavlink_command_cancel_t;
12
13#define MAVLINK_MSG_ID_COMMAND_CANCEL_LEN 4
14#define MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN 4
15#define MAVLINK_MSG_ID_80_LEN 4
16#define MAVLINK_MSG_ID_80_MIN_LEN 4
17
18#define MAVLINK_MSG_ID_COMMAND_CANCEL_CRC 14
19#define MAVLINK_MSG_ID_80_CRC 14
20
21
22
23#if MAVLINK_COMMAND_24BIT
24#define MAVLINK_MESSAGE_INFO_COMMAND_CANCEL {
25 80,
26 "COMMAND_CANCEL",
27 3,
28 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_command_cancel_t, target_system) },
29 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_command_cancel_t, target_component) },
30 { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_command_cancel_t, command) },
31 } \
32}
33#else
34#define MAVLINK_MESSAGE_INFO_COMMAND_CANCEL {
35 "COMMAND_CANCEL",
36 3,
37 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_command_cancel_t, target_system) },
38 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_command_cancel_t, target_component) },
39 { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_command_cancel_t, command) },
40 } \
41}
42#endif
43
44/**
45 * @brief Pack a command_cancel message
46 * @param system_id ID of this system
47 * @param component_id ID of this component (e.g. 200 for IMU)
48 * @param msg The MAVLink message to compress the data into
49 *
50 * @param target_system System executing long running command. Should not be broadcast (0).
51 * @param target_component Component executing long running command.
52 * @param command Command ID (of command to cancel).
53 * @return length of the message in bytes (excluding serial stream start sign)
54 */
55MAVLINK_WIP
56static inline uint16_t mavlink_msg_command_cancel_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
57 uint8_t target_system, uint8_t target_component, uint16_t command)
58{
59#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
61 _mav_put_uint16_t(buf, 0, command);
62 _mav_put_uint8_t(buf, 2, target_system);
63 _mav_put_uint8_t(buf, 3, target_component);
64
65 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
66#else
67 mavlink_command_cancel_t packet;
68 packet.command = command;
69 packet.target_system = target_system;
70 packet.target_component = target_component;
71
72 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
73#endif
74
76 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
77}
78
79/**
80 * @brief Pack a command_cancel message
81 * @param system_id ID of this system
82 * @param component_id ID of this component (e.g. 200 for IMU)
83 * @param status MAVLink status structure
84 * @param msg The MAVLink message to compress the data into
85 *
86 * @param target_system System executing long running command. Should not be broadcast (0).
87 * @param target_component Component executing long running command.
88 * @param command Command ID (of command to cancel).
89 * @return length of the message in bytes (excluding serial stream start sign)
90 */
91static inline uint16_t mavlink_msg_command_cancel_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
92 uint8_t target_system, uint8_t target_component, uint16_t command)
93{
94#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
96 _mav_put_uint16_t(buf, 0, command);
97 _mav_put_uint8_t(buf, 2, target_system);
98 _mav_put_uint8_t(buf, 3, target_component);
99
100 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
101#else
102 mavlink_command_cancel_t packet;
103 packet.command = command;
104 packet.target_system = target_system;
105 packet.target_component = target_component;
106
107 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
108#endif
109
111#if MAVLINK_CRC_EXTRA
112 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
113#else
114 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
115#endif
116}
117
118/**
119 * @brief Pack a command_cancel message on a channel
120 * @param system_id ID of this system
121 * @param component_id ID of this component (e.g. 200 for IMU)
122 * @param chan The MAVLink channel this message will be sent over
123 * @param msg The MAVLink message to compress the data into
124 * @param target_system System executing long running command. Should not be broadcast (0).
125 * @param target_component Component executing long running command.
126 * @param command Command ID (of command to cancel).
127 * @return length of the message in bytes (excluding serial stream start sign)
128 */
129MAVLINK_WIP
130static inline uint16_t mavlink_msg_command_cancel_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
131 mavlink_message_t* msg,
132 uint8_t target_system,uint8_t target_component,uint16_t command)
133{
134#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
136 _mav_put_uint16_t(buf, 0, command);
137 _mav_put_uint8_t(buf, 2, target_system);
138 _mav_put_uint8_t(buf, 3, target_component);
139
140 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
141#else
142 mavlink_command_cancel_t packet;
143 packet.command = command;
144 packet.target_system = target_system;
145 packet.target_component = target_component;
146
147 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
148#endif
149
151 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
152}
153
154/**
155 * @brief Encode a command_cancel struct
156 *
157 * @param system_id ID of this system
158 * @param component_id ID of this component (e.g. 200 for IMU)
159 * @param msg The MAVLink message to compress the data into
160 * @param command_cancel C-struct to read the message contents from
161 */
162MAVLINK_WIP
163static inline uint16_t mavlink_msg_command_cancel_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_command_cancel_t* command_cancel)
164{
165 return mavlink_msg_command_cancel_pack(system_id, component_id, msg, command_cancel->target_system, command_cancel->target_component, command_cancel->command);
166}
167
168/**
169 * @brief Encode a command_cancel struct on a channel
170 *
171 * @param system_id ID of this system
172 * @param component_id ID of this component (e.g. 200 for IMU)
173 * @param chan The MAVLink channel this message will be sent over
174 * @param msg The MAVLink message to compress the data into
175 * @param command_cancel C-struct to read the message contents from
176 */
177MAVLINK_WIP
178static inline uint16_t mavlink_msg_command_cancel_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_command_cancel_t* command_cancel)
179{
180 return mavlink_msg_command_cancel_pack_chan(system_id, component_id, chan, msg, command_cancel->target_system, command_cancel->target_component, command_cancel->command);
181}
182
183/**
184 * @brief Encode a command_cancel struct with provided status structure
185 *
186 * @param system_id ID of this system
187 * @param component_id ID of this component (e.g. 200 for IMU)
188 * @param status MAVLink status structure
189 * @param msg The MAVLink message to compress the data into
190 * @param command_cancel C-struct to read the message contents from
191 */
192static inline uint16_t mavlink_msg_command_cancel_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_command_cancel_t* command_cancel)
193{
194 return mavlink_msg_command_cancel_pack_status(system_id, component_id, _status, msg, command_cancel->target_system, command_cancel->target_component, command_cancel->command);
195}
196
197/**
198 * @brief Send a command_cancel message
199 * @param chan MAVLink channel to send the message
200 *
201 * @param target_system System executing long running command. Should not be broadcast (0).
202 * @param target_component Component executing long running command.
203 * @param command Command ID (of command to cancel).
204 */
205#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
206
207MAVLINK_WIP
208static inline void mavlink_msg_command_cancel_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint16_t command)
209{
210#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
211 char buf[MAVLINK_MSG_ID_COMMAND_CANCEL_LEN];
212 _mav_put_uint16_t(buf, 0, command);
213 _mav_put_uint8_t(buf, 2, target_system);
214 _mav_put_uint8_t(buf, 3, target_component);
215
216 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_CANCEL, buf, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
217#else
218 mavlink_command_cancel_t packet;
219 packet.command = command;
220 packet.target_system = target_system;
221 packet.target_component = target_component;
222
223 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_CANCEL, (const char *)&packet, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
224#endif
225}
226
227/**
228 * @brief Send a command_cancel message
229 * @param chan MAVLink channel to send the message
230 * @param struct The MAVLink struct to serialize
231 */
232MAVLINK_WIP
233static inline void mavlink_msg_command_cancel_send_struct(mavlink_channel_t chan, const mavlink_command_cancel_t* command_cancel)
234{
235#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
236 mavlink_msg_command_cancel_send(chan, command_cancel->target_system, command_cancel->target_component, command_cancel->command);
237#else
238 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_CANCEL, (const char *)command_cancel, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
239#endif
240}
241
242#if MAVLINK_MSG_ID_COMMAND_CANCEL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
243/*
244 This variant of _send() can be used to save stack space by reusing
245 memory from the receive buffer. The caller provides a
246 mavlink_message_t which is the size of a full mavlink message. This
247 is usually the receive buffer for the channel, and allows a reply to an
248 incoming message with minimum stack space usage.
249 */
250MAVLINK_WIP
251static inline void mavlink_msg_command_cancel_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint16_t command)
252{
253#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
254 char *buf = (char *)msgbuf;
255 _mav_put_uint16_t(buf, 0, command);
256 _mav_put_uint8_t(buf, 2, target_system);
257 _mav_put_uint8_t(buf, 3, target_component);
258
259 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_CANCEL, buf, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
260#else
261 mavlink_command_cancel_t *packet = (mavlink_command_cancel_t *)msgbuf;
262 packet->command = command;
263 packet->target_system = target_system;
264 packet->target_component = target_component;
265
266 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_CANCEL, (const char *)packet, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
267#endif
268}
269#endif
270
271#endif
272
273// MESSAGE COMMAND_CANCEL UNPACKING
274
275
276/**
277 * @brief Get field target_system from command_cancel message
278 *
279 * @return System executing long running command. Should not be broadcast (0).
280 */
281MAVLINK_WIP
282static inline uint8_t mavlink_msg_command_cancel_get_target_system(const mavlink_message_t* msg)
283{
284 return _MAV_RETURN_uint8_t(msg, 2);
285}
286
287/**
288 * @brief Get field target_component from command_cancel message
289 *
290 * @return Component executing long running command.
291 */
292MAVLINK_WIP
293static inline uint8_t mavlink_msg_command_cancel_get_target_component(const mavlink_message_t* msg)
294{
295 return _MAV_RETURN_uint8_t(msg, 3);
296}
297
298/**
299 * @brief Get field command from command_cancel message
300 *
301 * @return Command ID (of command to cancel).
302 */
303MAVLINK_WIP
304static inline uint16_t mavlink_msg_command_cancel_get_command(const mavlink_message_t* msg)
305{
306 return _MAV_RETURN_uint16_t(msg, 0);
307}
308
309/**
310 * @brief Decode a command_cancel message into a struct
311 *
312 * @param msg The message to decode
313 * @param command_cancel C-struct to decode the message contents into
314 */
315MAVLINK_WIP
316static inline void mavlink_msg_command_cancel_decode(const mavlink_message_t* msg, mavlink_command_cancel_t* command_cancel)
317{
318#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
319 command_cancel->command = mavlink_msg_command_cancel_get_command(msg);
320 command_cancel->target_system = mavlink_msg_command_cancel_get_target_system(msg);
321 command_cancel->target_component = mavlink_msg_command_cancel_get_target_component(msg);
322#else
323 uint8_t len = msg->len < MAVLINK_MSG_ID_COMMAND_CANCEL_LEN? msg->len : MAVLINK_MSG_ID_COMMAND_CANCEL_LEN;
324 memset(command_cancel, 0, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
325 memcpy(command_cancel, _MAV_PAYLOAD(msg), len);
326#endif
327}