Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
// MESSAGE COMMAND_ACK PACKING
2
 
3
#define MAVLINK_MSG_ID_COMMAND_ACK 77
4
 
5
typedef struct __mavlink_command_ack_t
6
{
7
 uint16_t command; ///< Command ID, as defined by MAV_CMD enum.
8
 uint8_t result; ///< See MAV_RESULT enum
9
} mavlink_command_ack_t;
10
 
11
#define MAVLINK_MSG_ID_COMMAND_ACK_LEN 3
12
#define MAVLINK_MSG_ID_77_LEN 3
13
 
14
 
15
 
16
#define MAVLINK_MESSAGE_INFO_COMMAND_ACK { \
17
        "COMMAND_ACK", \
18
        2, \
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
         } \
22
}
23
 
24
 
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
30
 *
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)
34
 */
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)
37
{
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);
42
 
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;
48
 
49
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3);
50
#endif
51
 
52
        msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
53
        return mavlink_finalize_message(msg, system_id, component_id, 3, 143);
54
}
55
 
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)
65
 */
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)
69
{
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);
74
 
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;
80
 
81
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3);
82
#endif
83
 
84
        msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
85
        return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 3, 143);
86
}
87
 
88
/**
89
 * @brief Encode a command_ack struct into a message
90
 *
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
95
 */
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)
97
{
98
        return mavlink_msg_command_ack_pack(system_id, component_id, msg, command_ack->command, command_ack->result);
99
}
100
 
101
/**
102
 * @brief Send a command_ack message
103
 * @param chan MAVLink channel to send the message
104
 *
105
 * @param command Command ID, as defined by MAV_CMD enum.
106
 * @param result See MAV_RESULT enum
107
 */
108
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
109
 
110
static inline void mavlink_msg_command_ack_send(mavlink_channel_t chan, uint16_t command, uint8_t result)
111
{
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);
116
 
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;
122
 
123
        _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, (const char *)&packet, 3, 143);
124
#endif
125
}
126
 
127
#endif
128
 
129
// MESSAGE COMMAND_ACK UNPACKING
130
 
131
 
132
/**
133
 * @brief Get field command from command_ack message
134
 *
135
 * @return Command ID, as defined by MAV_CMD enum.
136
 */
137
static inline uint16_t mavlink_msg_command_ack_get_command(const mavlink_message_t* msg)
138
{
139
        return _MAV_RETURN_uint16_t(msg,  0);
140
}
141
 
142
/**
143
 * @brief Get field result from command_ack message
144
 *
145
 * @return See MAV_RESULT enum
146
 */
147
static inline uint8_t mavlink_msg_command_ack_get_result(const mavlink_message_t* msg)
148
{
149
        return _MAV_RETURN_uint8_t(msg,  2);
150
}
151
 
152
/**
153
 * @brief Decode a command_ack message into a struct
154
 *
155
 * @param msg The message to decode
156
 * @param command_ack C-struct to decode the message contents into
157
 */
158
static inline void mavlink_msg_command_ack_decode(const mavlink_message_t* msg, mavlink_command_ack_t* command_ack)
159
{
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
166
}