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 76
4
 
5
typedef struct __mavlink_command_ack_t
6
{
7
 float command; ///< Current airspeed in m/s
8
 float result; ///< 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION
9
} mavlink_command_ack_t;
10
 
11
#define MAVLINK_MSG_ID_COMMAND_ACK_LEN 8
12
#define MAVLINK_MSG_ID_76_LEN 8
13
 
14
 
15
 
16
#define MAVLINK_MESSAGE_INFO_COMMAND_ACK { \
17
        "COMMAND_ACK", \
18
        2, \
19
        {  { "command", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_command_ack_t, command) }, \
20
         { "result", NULL, MAVLINK_TYPE_FLOAT, 0, 4, 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 Current airspeed in m/s
32
 * @param result 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION
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
                                                       float command, float result)
37
{
38
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
39
        char buf[8];
40
        _mav_put_float(buf, 0, command);
41
        _mav_put_float(buf, 4, result);
42
 
43
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8);
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, 8);
50
#endif
51
 
52
        msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
53
        return mavlink_finalize_message(msg, system_id, component_id, 8);
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 Current airspeed in m/s
63
 * @param result 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION
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
                                                           float command,float result)
69
{
70
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71
        char buf[8];
72
        _mav_put_float(buf, 0, command);
73
        _mav_put_float(buf, 4, result);
74
 
75
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8);
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, 8);
82
#endif
83
 
84
        msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
85
        return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 8);
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 Current airspeed in m/s
106
 * @param result 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION
107
 */
108
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
109
 
110
static inline void mavlink_msg_command_ack_send(mavlink_channel_t chan, float command, float result)
111
{
112
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113
        char buf[8];
114
        _mav_put_float(buf, 0, command);
115
        _mav_put_float(buf, 4, result);
116
 
117
        _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, buf, 8);
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, 8);
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 Current airspeed in m/s
136
 */
137
static inline float mavlink_msg_command_ack_get_command(const mavlink_message_t* msg)
138
{
139
        return _MAV_RETURN_float(msg,  0);
140
}
141
 
142
/**
143
 * @brief Get field result from command_ack message
144
 *
145
 * @return 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION
146
 */
147
static inline float mavlink_msg_command_ack_get_result(const mavlink_message_t* msg)
148
{
149
        return _MAV_RETURN_float(msg,  4);
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), 8);
165
#endif
166
}