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

3 4
#define MAVLINK_MSG_ID_COMMAND_SHORT 75
#define MAVLINK_MSG_ID_COMMAND_SHORT_LEN 20
lm's avatar
lm committed
5
#define MAVLINK_MSG_75_LEN 20
6
#define MAVLINK_MSG_ID_COMMAND_SHORT_KEY 0x14
lm's avatar
lm committed
7
#define MAVLINK_MSG_75_KEY 0x14
James Goppert's avatar
James Goppert committed
8

9
typedef struct __mavlink_command_short_t 
James Goppert's avatar
James Goppert committed
10
{
lm's avatar
lm committed
11 12 13 14 15 16 17 18
	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)
James Goppert's avatar
James Goppert committed
19

20
} mavlink_command_short_t;
James Goppert's avatar
James Goppert committed
21 22

/**
23
 * @brief Pack a command_short message
James Goppert's avatar
James Goppert committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37
 * @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)
 */
38
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
39
{
40 41
	mavlink_command_short_t *p = (mavlink_command_short_t *)&msg->payload[0];
	msg->msgid = MAVLINK_MSG_ID_COMMAND_SHORT;
James Goppert's avatar
James Goppert committed
42

lm's avatar
lm committed
43 44 45 46 47 48 49 50
	p->target_system = target_system;	// uint8_t:System which should execute the command
	p->target_component = target_component;	// uint8_t:Component which should execute the command, 0 for all components
	p->command = command;	// uint8_t:Command ID, as defined by MAV_CMD enum.
	p->confirmation = confirmation;	// uint8_t:0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command)
	p->param1 = param1;	// float:Parameter 1, as defined by MAV_CMD enum.
	p->param2 = param2;	// float:Parameter 2, as defined by MAV_CMD enum.
	p->param3 = param3;	// float:Parameter 3, as defined by MAV_CMD enum.
	p->param4 = param4;	// float:Parameter 4, as defined by MAV_CMD enum.
James Goppert's avatar
James Goppert committed
51

52
	return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMMAND_SHORT_LEN);
James Goppert's avatar
James Goppert committed
53 54 55
}

/**
56
 * @brief Pack a command_short message
James Goppert's avatar
James Goppert committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70
 * @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)
 */
71
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)
James Goppert's avatar
James Goppert committed
72
{
73 74
	mavlink_command_short_t *p = (mavlink_command_short_t *)&msg->payload[0];
	msg->msgid = MAVLINK_MSG_ID_COMMAND_SHORT;
James Goppert's avatar
James Goppert committed
75

lm's avatar
lm committed
76 77 78 79 80 81 82 83
	p->target_system = target_system;	// uint8_t:System which should execute the command
	p->target_component = target_component;	// uint8_t:Component which should execute the command, 0 for all components
	p->command = command;	// uint8_t:Command ID, as defined by MAV_CMD enum.
	p->confirmation = confirmation;	// uint8_t:0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command)
	p->param1 = param1;	// float:Parameter 1, as defined by MAV_CMD enum.
	p->param2 = param2;	// float:Parameter 2, as defined by MAV_CMD enum.
	p->param3 = param3;	// float:Parameter 3, as defined by MAV_CMD enum.
	p->param4 = param4;	// float:Parameter 4, as defined by MAV_CMD enum.
James Goppert's avatar
James Goppert committed
84

85
	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_COMMAND_SHORT_LEN);
James Goppert's avatar
James Goppert committed
86 87 88
}

/**
89
 * @brief Encode a command_short struct into a message
James Goppert's avatar
James Goppert committed
90 91 92 93
 *
 * @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
94
 * @param command_short C-struct to read the message contents from
James Goppert's avatar
James Goppert committed
95
 */
96
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
97
{
98
	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
99 100
}

lm's avatar
lm committed
101 102

#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
James Goppert's avatar
James Goppert committed
103
/**
104
 * @brief Send a command_short message
James Goppert's avatar
James Goppert committed
105 106 107 108 109 110 111 112 113 114 115
 * @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.
 */
116
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
117 118
{
	mavlink_header_t hdr;
119
	mavlink_command_short_t payload;
lm's avatar
lm committed
120

121
	MAVLINK_BUFFER_CHECK_START( chan, MAVLINK_MSG_ID_COMMAND_SHORT_LEN )
lm's avatar
lm committed
122 123 124 125 126 127 128 129
	payload.target_system = target_system;	// uint8_t:System which should execute the command
	payload.target_component = target_component;	// uint8_t:Component which should execute the command, 0 for all components
	payload.command = command;	// uint8_t:Command ID, as defined by MAV_CMD enum.
	payload.confirmation = confirmation;	// uint8_t:0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command)
	payload.param1 = param1;	// float:Parameter 1, as defined by MAV_CMD enum.
	payload.param2 = param2;	// float:Parameter 2, as defined by MAV_CMD enum.
	payload.param3 = param3;	// float:Parameter 3, as defined by MAV_CMD enum.
	payload.param4 = param4;	// float:Parameter 4, as defined by MAV_CMD enum.
lm's avatar
lm committed
130 131

	hdr.STX = MAVLINK_STX;
132 133
	hdr.len = MAVLINK_MSG_ID_COMMAND_SHORT_LEN;
	hdr.msgid = MAVLINK_MSG_ID_COMMAND_SHORT;
lm's avatar
lm committed
134 135 136 137 138
	hdr.sysid = mavlink_system.sysid;
	hdr.compid = mavlink_system.compid;
	hdr.seq = mavlink_get_channel_status(chan)->current_tx_seq;
	mavlink_get_channel_status(chan)->current_tx_seq = hdr.seq + 1;
	mavlink_send_mem(chan, (uint8_t *)&hdr.STX, MAVLINK_NUM_HEADER_BYTES );
139
	mavlink_send_mem(chan, (uint8_t *)&payload, sizeof(payload) );
lm's avatar
lm committed
140

lm's avatar
lm committed
141 142 143 144 145 146
	crc_init(&hdr.ck);
	crc_calculate_mem((uint8_t *)&hdr.len, &hdr.ck, MAVLINK_CORE_HEADER_LEN);
	crc_calculate_mem((uint8_t *)&payload, &hdr.ck, hdr.len );
	crc_accumulate( 0x14, &hdr.ck); /// include key in X25 checksum
	mavlink_send_mem(chan, (uint8_t *)&hdr.ck, MAVLINK_NUM_CHECKSUM_BYTES);
	MAVLINK_BUFFER_CHECK_END
James Goppert's avatar
James Goppert committed
147 148 149
}

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

/**
153
 * @brief Get field target_system from command_short message
James Goppert's avatar
James Goppert committed
154 155 156
 *
 * @return System which should execute the command
 */
157
static inline uint8_t mavlink_msg_command_short_get_target_system(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
158
{
159
	mavlink_command_short_t *p = (mavlink_command_short_t *)&msg->payload[0];
lm's avatar
lm committed
160
	return (uint8_t)(p->target_system);
James Goppert's avatar
James Goppert committed
161 162 163
}

/**
164
 * @brief Get field target_component from command_short message
James Goppert's avatar
James Goppert committed
165 166 167
 *
 * @return Component which should execute the command, 0 for all components
 */
168
static inline uint8_t mavlink_msg_command_short_get_target_component(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
169
{
170
	mavlink_command_short_t *p = (mavlink_command_short_t *)&msg->payload[0];
lm's avatar
lm committed
171
	return (uint8_t)(p->target_component);
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
{
181
	mavlink_command_short_t *p = (mavlink_command_short_t *)&msg->payload[0];
lm's avatar
lm committed
182
	return (uint8_t)(p->command);
James Goppert's avatar
James Goppert committed
183 184 185
}

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

/**
197
 * @brief Get field param1 from command_short message
James Goppert's avatar
James Goppert committed
198 199 200
 *
 * @return Parameter 1, as defined by MAV_CMD enum.
 */
201
static inline float mavlink_msg_command_short_get_param1(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
202
{
203
	mavlink_command_short_t *p = (mavlink_command_short_t *)&msg->payload[0];
lm's avatar
lm committed
204
	return (float)(p->param1);
James Goppert's avatar
James Goppert committed
205 206 207
}

/**
208
 * @brief Get field param2 from command_short message
James Goppert's avatar
James Goppert committed
209 210 211
 *
 * @return Parameter 2, as defined by MAV_CMD enum.
 */
212
static inline float mavlink_msg_command_short_get_param2(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
213
{
214
	mavlink_command_short_t *p = (mavlink_command_short_t *)&msg->payload[0];
lm's avatar
lm committed
215
	return (float)(p->param2);
James Goppert's avatar
James Goppert committed
216 217 218
}

/**
219
 * @brief Get field param3 from command_short message
James Goppert's avatar
James Goppert committed
220 221 222
 *
 * @return Parameter 3, as defined by MAV_CMD enum.
 */
223
static inline float mavlink_msg_command_short_get_param3(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
224
{
225
	mavlink_command_short_t *p = (mavlink_command_short_t *)&msg->payload[0];
lm's avatar
lm committed
226
	return (float)(p->param3);
James Goppert's avatar
James Goppert committed
227 228 229
}

/**
230
 * @brief Get field param4 from command_short message
James Goppert's avatar
James Goppert committed
231 232 233
 *
 * @return Parameter 4, as defined by MAV_CMD enum.
 */
234
static inline float mavlink_msg_command_short_get_param4(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
235
{
236
	mavlink_command_short_t *p = (mavlink_command_short_t *)&msg->payload[0];
lm's avatar
lm committed
237
	return (float)(p->param4);
James Goppert's avatar
James Goppert committed
238 239 240
}

/**
241
 * @brief Decode a command_short message into a struct
James Goppert's avatar
James Goppert committed
242 243
 *
 * @param msg The message to decode
244
 * @param command_short C-struct to decode the message contents into
James Goppert's avatar
James Goppert committed
245
 */
246
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
247
{
248
	memcpy( command_short, msg->payload, sizeof(mavlink_command_short_t));
James Goppert's avatar
James Goppert committed
249
}