[GYRO] Refactor gyro driver for dual-gyro support
[inav.git] / lib / main / MAVLink / common / mavlink_msg_command_ack.h
blob7ace685119f9f5ecdc95fea6d4b677eff2971508
1 #pragma once
2 // MESSAGE COMMAND_ACK PACKING
4 #define MAVLINK_MSG_ID_COMMAND_ACK 77
6 MAVPACKED(
7 typedef struct __mavlink_command_ack_t {
8 uint16_t command; /*< Command ID, as defined by MAV_CMD enum.*/
9 uint8_t result; /*< See MAV_RESULT enum*/
10 }) mavlink_command_ack_t;
12 #define MAVLINK_MSG_ID_COMMAND_ACK_LEN 3
13 #define MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN 3
14 #define MAVLINK_MSG_ID_77_LEN 3
15 #define MAVLINK_MSG_ID_77_MIN_LEN 3
17 #define MAVLINK_MSG_ID_COMMAND_ACK_CRC 143
18 #define MAVLINK_MSG_ID_77_CRC 143
22 #if MAVLINK_COMMAND_24BIT
23 #define MAVLINK_MESSAGE_INFO_COMMAND_ACK { \
24 77, \
25 "COMMAND_ACK", \
26 2, \
27 { { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_command_ack_t, command) }, \
28 { "result", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_command_ack_t, result) }, \
29 } \
31 #else
32 #define MAVLINK_MESSAGE_INFO_COMMAND_ACK { \
33 "COMMAND_ACK", \
34 2, \
35 { { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_command_ack_t, command) }, \
36 { "result", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_command_ack_t, result) }, \
37 } \
39 #endif
41 /**
42 * @brief Pack a command_ack message
43 * @param system_id ID of this system
44 * @param component_id ID of this component (e.g. 200 for IMU)
45 * @param msg The MAVLink message to compress the data into
47 * @param command Command ID, as defined by MAV_CMD enum.
48 * @param result See MAV_RESULT enum
49 * @return length of the message in bytes (excluding serial stream start sign)
51 static inline uint16_t mavlink_msg_command_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
52 uint16_t command, uint8_t result)
54 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
55 char buf[MAVLINK_MSG_ID_COMMAND_ACK_LEN];
56 _mav_put_uint16_t(buf, 0, command);
57 _mav_put_uint8_t(buf, 2, result);
59 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_ACK_LEN);
60 #else
61 mavlink_command_ack_t packet;
62 packet.command = command;
63 packet.result = result;
65 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_ACK_LEN);
66 #endif
68 msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
69 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
72 /**
73 * @brief Pack a command_ack message on a channel
74 * @param system_id ID of this system
75 * @param component_id ID of this component (e.g. 200 for IMU)
76 * @param chan The MAVLink channel this message will be sent over
77 * @param msg The MAVLink message to compress the data into
78 * @param command Command ID, as defined by MAV_CMD enum.
79 * @param result See MAV_RESULT enum
80 * @return length of the message in bytes (excluding serial stream start sign)
82 static inline uint16_t mavlink_msg_command_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
83 mavlink_message_t* msg,
84 uint16_t command,uint8_t result)
86 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
87 char buf[MAVLINK_MSG_ID_COMMAND_ACK_LEN];
88 _mav_put_uint16_t(buf, 0, command);
89 _mav_put_uint8_t(buf, 2, result);
91 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_ACK_LEN);
92 #else
93 mavlink_command_ack_t packet;
94 packet.command = command;
95 packet.result = result;
97 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_ACK_LEN);
98 #endif
100 msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
101 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
105 * @brief Encode a command_ack struct
107 * @param system_id ID of this system
108 * @param component_id ID of this component (e.g. 200 for IMU)
109 * @param msg The MAVLink message to compress the data into
110 * @param command_ack C-struct to read the message contents from
112 static inline uint16_t mavlink_msg_command_ack_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_command_ack_t* command_ack)
114 return mavlink_msg_command_ack_pack(system_id, component_id, msg, command_ack->command, command_ack->result);
118 * @brief Encode a command_ack struct 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 command_ack C-struct to read the message contents from
126 static inline uint16_t mavlink_msg_command_ack_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_command_ack_t* command_ack)
128 return mavlink_msg_command_ack_pack_chan(system_id, component_id, chan, msg, command_ack->command, command_ack->result);
132 * @brief Send a command_ack message
133 * @param chan MAVLink channel to send the message
135 * @param command Command ID, as defined by MAV_CMD enum.
136 * @param result See MAV_RESULT enum
138 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
140 static inline void mavlink_msg_command_ack_send(mavlink_channel_t chan, uint16_t command, uint8_t result)
142 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
143 char buf[MAVLINK_MSG_ID_COMMAND_ACK_LEN];
144 _mav_put_uint16_t(buf, 0, command);
145 _mav_put_uint8_t(buf, 2, result);
147 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, buf, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
148 #else
149 mavlink_command_ack_t packet;
150 packet.command = command;
151 packet.result = result;
153 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, (const char *)&packet, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
154 #endif
158 * @brief Send a command_ack message
159 * @param chan MAVLink channel to send the message
160 * @param struct The MAVLink struct to serialize
162 static inline void mavlink_msg_command_ack_send_struct(mavlink_channel_t chan, const mavlink_command_ack_t* command_ack)
164 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
165 mavlink_msg_command_ack_send(chan, command_ack->command, command_ack->result);
166 #else
167 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, (const char *)command_ack, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
168 #endif
171 #if MAVLINK_MSG_ID_COMMAND_ACK_LEN <= MAVLINK_MAX_PAYLOAD_LEN
173 This varient of _send() can be used to save stack space by re-using
174 memory from the receive buffer. The caller provides a
175 mavlink_message_t which is the size of a full mavlink message. This
176 is usually the receive buffer for the channel, and allows a reply to an
177 incoming message with minimum stack space usage.
179 static inline void mavlink_msg_command_ack_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t command, uint8_t result)
181 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
182 char *buf = (char *)msgbuf;
183 _mav_put_uint16_t(buf, 0, command);
184 _mav_put_uint8_t(buf, 2, result);
186 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, buf, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
187 #else
188 mavlink_command_ack_t *packet = (mavlink_command_ack_t *)msgbuf;
189 packet->command = command;
190 packet->result = result;
192 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, (const char *)packet, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
193 #endif
195 #endif
197 #endif
199 // MESSAGE COMMAND_ACK UNPACKING
203 * @brief Get field command from command_ack message
205 * @return Command ID, as defined by MAV_CMD enum.
207 static inline uint16_t mavlink_msg_command_ack_get_command(const mavlink_message_t* msg)
209 return _MAV_RETURN_uint16_t(msg, 0);
213 * @brief Get field result from command_ack message
215 * @return See MAV_RESULT enum
217 static inline uint8_t mavlink_msg_command_ack_get_result(const mavlink_message_t* msg)
219 return _MAV_RETURN_uint8_t(msg, 2);
223 * @brief Decode a command_ack message into a struct
225 * @param msg The message to decode
226 * @param command_ack C-struct to decode the message contents into
228 static inline void mavlink_msg_command_ack_decode(const mavlink_message_t* msg, mavlink_command_ack_t* command_ack)
230 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
231 command_ack->command = mavlink_msg_command_ack_get_command(msg);
232 command_ack->result = mavlink_msg_command_ack_get_result(msg);
233 #else
234 uint8_t len = msg->len < MAVLINK_MSG_ID_COMMAND_ACK_LEN? msg->len : MAVLINK_MSG_ID_COMMAND_ACK_LEN;
235 memset(command_ack, 0, MAVLINK_MSG_ID_COMMAND_ACK_LEN);
236 memcpy(command_ack, _MAV_PAYLOAD(msg), len);
237 #endif