mavlink_msg_command_short.h 11.4 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 25 26 27 28 29 30 31 32 33 34 35 36
#define MAVLINK_MSG_ID_COMMAND_SHORT_LEN 20
#define MAVLINK_MSG_ID_75_LEN 20



#define MAVLINK_MESSAGE_INFO_COMMAND_SHORT { \
	"COMMAND_SHORT", \
	8, \
	{  { "param1", MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_command_short_t, param1) }, \
         { "param2", MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_command_short_t, param2) }, \
         { "param3", MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_command_short_t, param3) }, \
         { "param4", MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_command_short_t, param4) }, \
         { "target_system", MAVLINK_TYPE_UINT8_T, 0, 16, offsetof(mavlink_command_short_t, target_system) }, \
         { "target_component", MAVLINK_TYPE_UINT8_T, 0, 17, offsetof(mavlink_command_short_t, target_component) }, \
         { "command", MAVLINK_TYPE_UINT8_T, 0, 18, offsetof(mavlink_command_short_t, command) }, \
         { "confirmation", MAVLINK_TYPE_UINT8_T, 0, 19, offsetof(mavlink_command_short_t, confirmation) }, \
         } \
}


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
{
56
	msg->msgid = MAVLINK_MSG_ID_COMMAND_SHORT;
James Goppert's avatar
James Goppert committed
57

lm's avatar
lm committed
58 59 60 61 62 63 64 65
	put_float_by_index(msg, 0, param1); // Parameter 1, as defined by MAV_CMD enum.
	put_float_by_index(msg, 4, param2); // Parameter 2, as defined by MAV_CMD enum.
	put_float_by_index(msg, 8, param3); // Parameter 3, as defined by MAV_CMD enum.
	put_float_by_index(msg, 12, param4); // Parameter 4, as defined by MAV_CMD enum.
	put_uint8_t_by_index(msg, 16, target_system); // System which should execute the command
	put_uint8_t_by_index(msg, 17, target_component); // Component which should execute the command, 0 for all components
	put_uint8_t_by_index(msg, 18, command); // Command ID, as defined by MAV_CMD enum.
	put_uint8_t_by_index(msg, 19, confirmation); // 0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command)
James Goppert's avatar
James Goppert committed
66

lm's avatar
lm committed
67
	return mavlink_finalize_message(msg, system_id, component_id, 20, 160);
James Goppert's avatar
James Goppert committed
68 69 70
}

/**
lm's avatar
lm committed
71
 * @brief Pack a command_short message on a channel
James Goppert's avatar
James Goppert committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85
 * @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
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
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)
{
	msg->msgid = MAVLINK_MSG_ID_COMMAND_SHORT;

	put_float_by_index(msg, 0, param1); // Parameter 1, as defined by MAV_CMD enum.
	put_float_by_index(msg, 4, param2); // Parameter 2, as defined by MAV_CMD enum.
	put_float_by_index(msg, 8, param3); // Parameter 3, as defined by MAV_CMD enum.
	put_float_by_index(msg, 12, param4); // Parameter 4, as defined by MAV_CMD enum.
	put_uint8_t_by_index(msg, 16, target_system); // System which should execute the command
	put_uint8_t_by_index(msg, 17, target_component); // Component which should execute the command, 0 for all components
	put_uint8_t_by_index(msg, 18, command); // Command ID, as defined by MAV_CMD enum.
	put_uint8_t_by_index(msg, 19, confirmation); // 0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command)

	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 20, 160);
}

James Goppert's avatar
James Goppert committed
104
/**
105
 * @brief Encode a command_short struct into a message
James Goppert's avatar
James Goppert committed
106 107 108 109
 *
 * @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
110
 * @param command_short C-struct to read the message contents from
James Goppert's avatar
James Goppert committed
111
 */
112
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
113
{
114
	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
115 116 117
}

/**
118
 * @brief Send a command_short message
James Goppert's avatar
James Goppert committed
119 120 121 122 123 124 125 126 127 128 129
 * @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
130 131
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

132
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
133
{
lm's avatar
lm committed
134
	MAVLINK_ALIGNED_MESSAGE(msg, 20);
LM's avatar
LM committed
135 136 137 138 139 140 141 142 143 144 145 146
	msg->msgid = MAVLINK_MSG_ID_COMMAND_SHORT;

	put_float_by_index(msg, 0, param1); // Parameter 1, as defined by MAV_CMD enum.
	put_float_by_index(msg, 4, param2); // Parameter 2, as defined by MAV_CMD enum.
	put_float_by_index(msg, 8, param3); // Parameter 3, as defined by MAV_CMD enum.
	put_float_by_index(msg, 12, param4); // Parameter 4, as defined by MAV_CMD enum.
	put_uint8_t_by_index(msg, 16, target_system); // System which should execute the command
	put_uint8_t_by_index(msg, 17, target_component); // Component which should execute the command, 0 for all components
	put_uint8_t_by_index(msg, 18, command); // Command ID, as defined by MAV_CMD enum.
	put_uint8_t_by_index(msg, 19, confirmation); // 0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command)

	mavlink_finalize_message_chan_send(msg, chan, 20, 160);
James Goppert's avatar
James Goppert committed
147 148 149
}

#endif
lm's avatar
lm committed
150

151
// MESSAGE COMMAND_SHORT UNPACKING
James Goppert's avatar
James Goppert committed
152

lm's avatar
lm committed
153

James Goppert's avatar
James Goppert committed
154
/**
155
 * @brief Get field target_system from command_short message
James Goppert's avatar
James Goppert committed
156 157 158
 *
 * @return System which should execute the command
 */
159
static inline uint8_t mavlink_msg_command_short_get_target_system(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
160
{
lm's avatar
lm committed
161
	return MAVLINK_MSG_RETURN_uint8_t(msg,  16);
James Goppert's avatar
James Goppert committed
162 163 164
}

/**
165
 * @brief Get field target_component from command_short message
James Goppert's avatar
James Goppert committed
166 167 168
 *
 * @return Component which should execute the command, 0 for all components
 */
169
static inline uint8_t mavlink_msg_command_short_get_target_component(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
170
{
lm's avatar
lm committed
171
	return MAVLINK_MSG_RETURN_uint8_t(msg,  17);
James Goppert's avatar
James Goppert committed
172 173 174
}

/**
175
 * @brief Get field command from command_short message
James Goppert's avatar
James Goppert committed
176 177 178
 *
 * @return Command ID, as defined by MAV_CMD enum.
 */
179
static inline uint8_t mavlink_msg_command_short_get_command(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
180
{
lm's avatar
lm committed
181
	return MAVLINK_MSG_RETURN_uint8_t(msg,  18);
James Goppert's avatar
James Goppert committed
182 183 184
}

/**
185
 * @brief Get field confirmation from command_short message
James Goppert's avatar
James Goppert committed
186 187 188
 *
 * @return 0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command)
 */
189
static inline uint8_t mavlink_msg_command_short_get_confirmation(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
190
{
lm's avatar
lm committed
191
	return MAVLINK_MSG_RETURN_uint8_t(msg,  19);
James Goppert's avatar
James Goppert committed
192 193 194
}

/**
195
 * @brief Get field param1 from command_short message
James Goppert's avatar
James Goppert committed
196 197 198
 *
 * @return Parameter 1, as defined by MAV_CMD enum.
 */
199
static inline float mavlink_msg_command_short_get_param1(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
200
{
lm's avatar
lm committed
201
	return MAVLINK_MSG_RETURN_float(msg,  0);
James Goppert's avatar
James Goppert committed
202 203 204
}

/**
205
 * @brief Get field param2 from command_short message
James Goppert's avatar
James Goppert committed
206 207 208
 *
 * @return Parameter 2, as defined by MAV_CMD enum.
 */
209
static inline float mavlink_msg_command_short_get_param2(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
210
{
lm's avatar
lm committed
211
	return MAVLINK_MSG_RETURN_float(msg,  4);
James Goppert's avatar
James Goppert committed
212 213 214
}

/**
215
 * @brief Get field param3 from command_short message
James Goppert's avatar
James Goppert committed
216 217 218
 *
 * @return Parameter 3, as defined by MAV_CMD enum.
 */
219
static inline float mavlink_msg_command_short_get_param3(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
220
{
lm's avatar
lm committed
221
	return MAVLINK_MSG_RETURN_float(msg,  8);
James Goppert's avatar
James Goppert committed
222 223 224
}

/**
225
 * @brief Get field param4 from command_short message
James Goppert's avatar
James Goppert committed
226 227 228
 *
 * @return Parameter 4, as defined by MAV_CMD enum.
 */
229
static inline float mavlink_msg_command_short_get_param4(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
230
{
lm's avatar
lm committed
231
	return MAVLINK_MSG_RETURN_float(msg,  12);
James Goppert's avatar
James Goppert committed
232 233 234
}

/**
235
 * @brief Decode a command_short message into a struct
James Goppert's avatar
James Goppert committed
236 237
 *
 * @param msg The message to decode
238
 * @param command_short C-struct to decode the message contents into
James Goppert's avatar
James Goppert committed
239
 */
240
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
241
{
lm's avatar
lm committed
242 243 244 245 246 247 248 249 250 251 252 253
#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
	memcpy(command_short, MAVLINK_PAYLOAD(msg), 20);
#endif
James Goppert's avatar
James Goppert committed
254
}