Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / libraries / mavlink / v1.0 / common / mavlink_msg_command_ack.h
blob2550ec30ffc84747646db70058cc8e576f389c62
1 // MESSAGE COMMAND_ACK PACKING
3 #define MAVLINK_MSG_ID_COMMAND_ACK 77
5 typedef struct __mavlink_command_ack_t {
6 uint16_t command; ///< Command ID, as defined by MAV_CMD enum.
7 uint8_t result; ///< See MAV_RESULT enum
8 } mavlink_command_ack_t;
10 #define MAVLINK_MSG_ID_COMMAND_ACK_LEN 3
11 #define MAVLINK_MSG_ID_77_LEN 3
14 #define MAVLINK_MESSAGE_INFO_COMMAND_ACK \
15 { \
16 "COMMAND_ACK", \
17 2, \
18 { \
19 { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_command_ack_t, command) }, \
20 { "result", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_command_ack_t, result) }, \
21 } \
25 /**
26 * @brief Pack a command_ack message
27 * @param system_id ID of this system
28 * @param component_id ID of this component (e.g. 200 for IMU)
29 * @param msg The MAVLink message to compress the data into
31 * @param command Command ID, as defined by MAV_CMD enum.
32 * @param result See MAV_RESULT enum
33 * @return length of the message in bytes (excluding serial stream start sign)
35 static inline uint16_t mavlink_msg_command_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg,
36 uint16_t command, uint8_t result)
38 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
39 char buf[3];
40 _mav_put_uint16_t(buf, 0, command);
41 _mav_put_uint8_t(buf, 2, result);
43 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3);
44 #else
45 mavlink_command_ack_t packet;
46 packet.command = command;
47 packet.result = result;
49 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3);
50 #endif
52 msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
53 return mavlink_finalize_message(msg, system_id, component_id, 3, 143);
56 /**
57 * @brief Pack a command_ack message on a channel
58 * @param system_id ID of this system
59 * @param component_id ID of this component (e.g. 200 for IMU)
60 * @param chan The MAVLink channel this message was sent over
61 * @param msg The MAVLink message to compress the data into
62 * @param command Command ID, as defined by MAV_CMD enum.
63 * @param result See MAV_RESULT enum
64 * @return length of the message in bytes (excluding serial stream start sign)
66 static inline uint16_t mavlink_msg_command_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
67 mavlink_message_t *msg,
68 uint16_t command, uint8_t result)
70 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 char buf[3];
72 _mav_put_uint16_t(buf, 0, command);
73 _mav_put_uint8_t(buf, 2, result);
75 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3);
76 #else
77 mavlink_command_ack_t packet;
78 packet.command = command;
79 packet.result = result;
81 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3);
82 #endif
84 msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
85 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 3, 143);
88 /**
89 * @brief Encode a command_ack struct into a message
91 * @param system_id ID of this system
92 * @param component_id ID of this component (e.g. 200 for IMU)
93 * @param msg The MAVLink message to compress the data into
94 * @param command_ack C-struct to read the message contents from
96 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)
98 return mavlink_msg_command_ack_pack(system_id, component_id, msg, command_ack->command, command_ack->result);
102 * @brief Send a command_ack message
103 * @param chan MAVLink channel to send the message
105 * @param command Command ID, as defined by MAV_CMD enum.
106 * @param result See MAV_RESULT enum
108 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
110 static inline void mavlink_msg_command_ack_send(mavlink_channel_t chan, uint16_t command, uint8_t result)
112 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 char buf[3];
114 _mav_put_uint16_t(buf, 0, command);
115 _mav_put_uint8_t(buf, 2, result);
117 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, buf, 3, 143);
118 #else
119 mavlink_command_ack_t packet;
120 packet.command = command;
121 packet.result = result;
123 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, (const char *)&packet, 3, 143);
124 #endif
127 #endif
129 // MESSAGE COMMAND_ACK UNPACKING
133 * @brief Get field command from command_ack message
135 * @return Command ID, as defined by MAV_CMD enum.
137 static inline uint16_t mavlink_msg_command_ack_get_command(const mavlink_message_t *msg)
139 return _MAV_RETURN_uint16_t(msg, 0);
143 * @brief Get field result from command_ack message
145 * @return See MAV_RESULT enum
147 static inline uint8_t mavlink_msg_command_ack_get_result(const mavlink_message_t *msg)
149 return _MAV_RETURN_uint8_t(msg, 2);
153 * @brief Decode a command_ack message into a struct
155 * @param msg The message to decode
156 * @param command_ack C-struct to decode the message contents into
158 static inline void mavlink_msg_command_ack_decode(const mavlink_message_t *msg, mavlink_command_ack_t *command_ack)
160 #if MAVLINK_NEED_BYTE_SWAP
161 command_ack->command = mavlink_msg_command_ack_get_command(msg);
162 command_ack->result = mavlink_msg_command_ack_get_result(msg);
163 #else
164 memcpy(command_ack, _MAV_PAYLOAD(msg), 3);
165 #endif