mavlink_msg_command_short.h 11.3 KB
Newer Older
1
// MESSAGE COMMAND_SHORT PACKING
James Goppert's avatar
James Goppert committed
2

3
#define MAVLINK_MSG_ID_COMMAND_SHORT 75
James Goppert's avatar
James Goppert committed
4

lm's avatar
lm committed
5
typedef struct __mavlink_command_short_t
James Goppert's avatar
James Goppert committed
6
{
lm's avatar
lm committed
7 8 9 10 11 12 13 14
 float param1; ///< Parameter 1, as defined by MAV_CMD enum.
 float param2; ///< Parameter 2, as defined by MAV_CMD enum.
 float param3; ///< Parameter 3, as defined by MAV_CMD enum.
 float param4; ///< Parameter 4, as defined by MAV_CMD enum.
 uint8_t target_system; ///< System which should execute the command
 uint8_t target_component; ///< Component which should execute the command, 0 for all components
 uint8_t command; ///< Command ID, as defined by MAV_CMD enum.
 uint8_t confirmation; ///< 0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command)
15
} mavlink_command_short_t;
James Goppert's avatar
James Goppert committed
16

lm's avatar
lm committed
17 18 19 20 21 22 23 24
#define MAVLINK_MSG_ID_COMMAND_SHORT_LEN 20
#define MAVLINK_MSG_ID_75_LEN 20



#define MAVLINK_MESSAGE_INFO_COMMAND_SHORT { \
	"COMMAND_SHORT", \
	8, \
lm's avatar
lm committed
25 26 27 28 29 30 31 32
	{  { "param1", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_command_short_t, param1) }, \
         { "param2", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_command_short_t, param2) }, \
         { "param3", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_command_short_t, param3) }, \
         { "param4", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_command_short_t, param4) }, \
         { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 16, offsetof(mavlink_command_short_t, target_system) }, \
         { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 17, offsetof(mavlink_command_short_t, target_component) }, \
         { "command", NULL, MAVLINK_TYPE_UINT8_T, 0, 18, offsetof(mavlink_command_short_t, command) }, \
         { "confirmation", NULL, MAVLINK_TYPE_UINT8_T, 0, 19, offsetof(mavlink_command_short_t, confirmation) }, \
lm's avatar
lm committed
33 34 35 36
         } \
}


James Goppert's avatar
James Goppert committed
37
/**
38
 * @brief Pack a command_short message
James Goppert's avatar
James Goppert committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param target_system System which should execute the command
 * @param target_component Component which should execute the command, 0 for all components
 * @param command Command ID, as defined by MAV_CMD enum.
 * @param confirmation 0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command)
 * @param param1 Parameter 1, as defined by MAV_CMD enum.
 * @param param2 Parameter 2, as defined by MAV_CMD enum.
 * @param param3 Parameter 3, as defined by MAV_CMD enum.
 * @param param4 Parameter 4, as defined by MAV_CMD enum.
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
53 54
static inline uint16_t mavlink_msg_command_short_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
						       uint8_t target_system, uint8_t target_component, uint8_t command, uint8_t confirmation, float param1, float param2, float param3, float param4)
James Goppert's avatar
James Goppert committed
55
{
LM's avatar
LM committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[20];
	_mav_put_float(buf, 0, param1);
	_mav_put_float(buf, 4, param2);
	_mav_put_float(buf, 8, param3);
	_mav_put_float(buf, 12, param4);
	_mav_put_uint8_t(buf, 16, target_system);
	_mav_put_uint8_t(buf, 17, target_component);
	_mav_put_uint8_t(buf, 18, command);
	_mav_put_uint8_t(buf, 19, confirmation);

        memcpy(_MAV_PAYLOAD(msg), buf, 20);
#else
	mavlink_command_short_t packet;
	packet.param1 = param1;
	packet.param2 = param2;
	packet.param3 = param3;
	packet.param4 = param4;
	packet.target_system = target_system;
	packet.target_component = target_component;
	packet.command = command;
	packet.confirmation = confirmation;
James Goppert's avatar
James Goppert committed
78

LM's avatar
LM committed
79 80
        memcpy(_MAV_PAYLOAD(msg), &packet, 20);
#endif
James Goppert's avatar
James Goppert committed
81

LM's avatar
LM committed
82
	msg->msgid = MAVLINK_MSG_ID_COMMAND_SHORT;
lm's avatar
lm committed
83
	return mavlink_finalize_message(msg, system_id, component_id, 20, 160);
James Goppert's avatar
James Goppert committed
84 85 86
}

/**
lm's avatar
lm committed
87
 * @brief Pack a command_short message on a channel
James Goppert's avatar
James Goppert committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message was sent over
 * @param msg The MAVLink message to compress the data into
 * @param target_system System which should execute the command
 * @param target_component Component which should execute the command, 0 for all components
 * @param command Command ID, as defined by MAV_CMD enum.
 * @param confirmation 0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command)
 * @param param1 Parameter 1, as defined by MAV_CMD enum.
 * @param param2 Parameter 2, as defined by MAV_CMD enum.
 * @param param3 Parameter 3, as defined by MAV_CMD enum.
 * @param param4 Parameter 4, as defined by MAV_CMD enum.
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
102 103 104 105
static inline uint16_t mavlink_msg_command_short_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
							   mavlink_message_t* msg,
						           uint8_t target_system,uint8_t target_component,uint8_t command,uint8_t confirmation,float param1,float param2,float param3,float param4)
{
LM's avatar
LM committed
106 107 108 109 110 111 112 113 114 115
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[20];
	_mav_put_float(buf, 0, param1);
	_mav_put_float(buf, 4, param2);
	_mav_put_float(buf, 8, param3);
	_mav_put_float(buf, 12, param4);
	_mav_put_uint8_t(buf, 16, target_system);
	_mav_put_uint8_t(buf, 17, target_component);
	_mav_put_uint8_t(buf, 18, command);
	_mav_put_uint8_t(buf, 19, confirmation);
lm's avatar
lm committed
116

LM's avatar
LM committed
117 118 119 120 121 122 123 124 125 126 127
        memcpy(_MAV_PAYLOAD(msg), buf, 20);
#else
	mavlink_command_short_t packet;
	packet.param1 = param1;
	packet.param2 = param2;
	packet.param3 = param3;
	packet.param4 = param4;
	packet.target_system = target_system;
	packet.target_component = target_component;
	packet.command = command;
	packet.confirmation = confirmation;
lm's avatar
lm committed
128

LM's avatar
LM committed
129 130 131 132
        memcpy(_MAV_PAYLOAD(msg), &packet, 20);
#endif

	msg->msgid = MAVLINK_MSG_ID_COMMAND_SHORT;
lm's avatar
lm committed
133 134 135
	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 20, 160);
}

James Goppert's avatar
James Goppert committed
136
/**
137
 * @brief Encode a command_short struct into a message
James Goppert's avatar
James Goppert committed
138 139 140 141
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
142
 * @param command_short C-struct to read the message contents from
James Goppert's avatar
James Goppert committed
143
 */
144
static inline uint16_t mavlink_msg_command_short_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_command_short_t* command_short)
James Goppert's avatar
James Goppert committed
145
{
146
	return mavlink_msg_command_short_pack(system_id, component_id, msg, command_short->target_system, command_short->target_component, command_short->command, command_short->confirmation, command_short->param1, command_short->param2, command_short->param3, command_short->param4);
James Goppert's avatar
James Goppert committed
147 148 149
}

/**
150
 * @brief Send a command_short message
James Goppert's avatar
James Goppert committed
151 152 153 154 155 156 157 158 159 160 161
 * @param chan MAVLink channel to send the message
 *
 * @param target_system System which should execute the command
 * @param target_component Component which should execute the command, 0 for all components
 * @param command Command ID, as defined by MAV_CMD enum.
 * @param confirmation 0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command)
 * @param param1 Parameter 1, as defined by MAV_CMD enum.
 * @param param2 Parameter 2, as defined by MAV_CMD enum.
 * @param param3 Parameter 3, as defined by MAV_CMD enum.
 * @param param4 Parameter 4, as defined by MAV_CMD enum.
 */
lm's avatar
lm committed
162 163
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

164
static inline void mavlink_msg_command_short_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t command, uint8_t confirmation, float param1, float param2, float param3, float param4)
lm's avatar
lm committed
165
{
LM's avatar
LM committed
166 167 168 169 170 171 172 173 174 175
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[20];
	_mav_put_float(buf, 0, param1);
	_mav_put_float(buf, 4, param2);
	_mav_put_float(buf, 8, param3);
	_mav_put_float(buf, 12, param4);
	_mav_put_uint8_t(buf, 16, target_system);
	_mav_put_uint8_t(buf, 17, target_component);
	_mav_put_uint8_t(buf, 18, command);
	_mav_put_uint8_t(buf, 19, confirmation);
LM's avatar
LM committed
176

LM's avatar
LM committed
177 178 179 180 181 182 183 184 185 186 187
	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_SHORT, buf, 20, 160);
#else
	mavlink_command_short_t packet;
	packet.param1 = param1;
	packet.param2 = param2;
	packet.param3 = param3;
	packet.param4 = param4;
	packet.target_system = target_system;
	packet.target_component = target_component;
	packet.command = command;
	packet.confirmation = confirmation;
LM's avatar
LM committed
188

LM's avatar
LM committed
189 190
	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_SHORT, (const char *)&packet, 20, 160);
#endif
James Goppert's avatar
James Goppert committed
191 192 193
}

#endif
lm's avatar
lm committed
194

195
// MESSAGE COMMAND_SHORT UNPACKING
James Goppert's avatar
James Goppert committed
196

lm's avatar
lm committed
197

James Goppert's avatar
James Goppert committed
198
/**
199
 * @brief Get field target_system from command_short message
James Goppert's avatar
James Goppert committed
200 201 202
 *
 * @return System which should execute the command
 */
203
static inline uint8_t mavlink_msg_command_short_get_target_system(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
204
{
LM's avatar
LM committed
205
	return _MAV_RETURN_uint8_t(msg,  16);
James Goppert's avatar
James Goppert committed
206 207 208
}

/**
209
 * @brief Get field target_component from command_short message
James Goppert's avatar
James Goppert committed
210 211 212
 *
 * @return Component which should execute the command, 0 for all components
 */
213
static inline uint8_t mavlink_msg_command_short_get_target_component(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
214
{
LM's avatar
LM committed
215
	return _MAV_RETURN_uint8_t(msg,  17);
James Goppert's avatar
James Goppert committed
216 217 218
}

/**
219
 * @brief Get field command from command_short message
James Goppert's avatar
James Goppert committed
220 221 222
 *
 * @return Command ID, as defined by MAV_CMD enum.
 */
223
static inline uint8_t mavlink_msg_command_short_get_command(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
224
{
LM's avatar
LM committed
225
	return _MAV_RETURN_uint8_t(msg,  18);
James Goppert's avatar
James Goppert committed
226 227 228
}

/**
229
 * @brief Get field confirmation from command_short message
James Goppert's avatar
James Goppert committed
230 231 232
 *
 * @return 0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command)
 */
233
static inline uint8_t mavlink_msg_command_short_get_confirmation(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
234
{
LM's avatar
LM committed
235
	return _MAV_RETURN_uint8_t(msg,  19);
James Goppert's avatar
James Goppert committed
236 237 238
}

/**
239
 * @brief Get field param1 from command_short message
James Goppert's avatar
James Goppert committed
240 241 242
 *
 * @return Parameter 1, as defined by MAV_CMD enum.
 */
243
static inline float mavlink_msg_command_short_get_param1(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
244
{
LM's avatar
LM committed
245
	return _MAV_RETURN_float(msg,  0);
James Goppert's avatar
James Goppert committed
246 247 248
}

/**
249
 * @brief Get field param2 from command_short message
James Goppert's avatar
James Goppert committed
250 251 252
 *
 * @return Parameter 2, as defined by MAV_CMD enum.
 */
253
static inline float mavlink_msg_command_short_get_param2(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
254
{
LM's avatar
LM committed
255
	return _MAV_RETURN_float(msg,  4);
James Goppert's avatar
James Goppert committed
256 257 258
}

/**
259
 * @brief Get field param3 from command_short message
James Goppert's avatar
James Goppert committed
260 261 262
 *
 * @return Parameter 3, as defined by MAV_CMD enum.
 */
263
static inline float mavlink_msg_command_short_get_param3(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
264
{
LM's avatar
LM committed
265
	return _MAV_RETURN_float(msg,  8);
James Goppert's avatar
James Goppert committed
266 267 268
}

/**
269
 * @brief Get field param4 from command_short message
James Goppert's avatar
James Goppert committed
270 271 272
 *
 * @return Parameter 4, as defined by MAV_CMD enum.
 */
273
static inline float mavlink_msg_command_short_get_param4(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
274
{
LM's avatar
LM committed
275
	return _MAV_RETURN_float(msg,  12);
James Goppert's avatar
James Goppert committed
276 277 278
}

/**
279
 * @brief Decode a command_short message into a struct
James Goppert's avatar
James Goppert committed
280 281
 *
 * @param msg The message to decode
282
 * @param command_short C-struct to decode the message contents into
James Goppert's avatar
James Goppert committed
283
 */
284
static inline void mavlink_msg_command_short_decode(const mavlink_message_t* msg, mavlink_command_short_t* command_short)
James Goppert's avatar
James Goppert committed
285
{
lm's avatar
lm committed
286 287 288 289 290 291 292 293 294 295
#if MAVLINK_NEED_BYTE_SWAP
	command_short->param1 = mavlink_msg_command_short_get_param1(msg);
	command_short->param2 = mavlink_msg_command_short_get_param2(msg);
	command_short->param3 = mavlink_msg_command_short_get_param3(msg);
	command_short->param4 = mavlink_msg_command_short_get_param4(msg);
	command_short->target_system = mavlink_msg_command_short_get_target_system(msg);
	command_short->target_component = mavlink_msg_command_short_get_target_component(msg);
	command_short->command = mavlink_msg_command_short_get_command(msg);
	command_short->confirmation = mavlink_msg_command_short_get_confirmation(msg);
#else
LM's avatar
LM committed
296
	memcpy(command_short, _MAV_PAYLOAD(msg), 20);
lm's avatar
lm committed
297
#endif
James Goppert's avatar
James Goppert committed
298
}