mavlink_msg_mid_lvl_cmds.h 5.91 KB
Newer Older
James Goppert's avatar
James Goppert committed
1 2 3 4
// MESSAGE MID_LVL_CMDS PACKING

#define MAVLINK_MSG_ID_MID_LVL_CMDS 180

lm's avatar
lm committed
5
typedef struct __mavlink_mid_lvl_cmds_t
James Goppert's avatar
James Goppert committed
6
{
lm's avatar
lm committed
7 8 9 10
 float hCommand; ///< Commanded Airspeed
 float uCommand; ///< Log value 2 
 float rCommand; ///< Log value 3 
 uint8_t target; ///< The system setting the commands
James Goppert's avatar
James Goppert committed
11 12
} mavlink_mid_lvl_cmds_t;

lm's avatar
lm committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#define MAVLINK_MSG_ID_MID_LVL_CMDS_LEN 13
#define MAVLINK_MSG_ID_180_LEN 13



#define MAVLINK_MESSAGE_INFO_MID_LVL_CMDS { \
	"MID_LVL_CMDS", \
	4, \
	{  { "hCommand", MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_mid_lvl_cmds_t, hCommand) }, \
         { "uCommand", MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_mid_lvl_cmds_t, uCommand) }, \
         { "rCommand", MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_mid_lvl_cmds_t, rCommand) }, \
         { "target", MAVLINK_TYPE_UINT8_T, 0, 12, offsetof(mavlink_mid_lvl_cmds_t, target) }, \
         } \
}


James Goppert's avatar
James Goppert committed
29
/**
James Goppert's avatar
James Goppert committed
30 31 32 33
 * @brief Pack a mid_lvl_cmds message
 * @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
James Goppert's avatar
James Goppert committed
34 35 36 37 38 39 40
 *
 * @param target The system setting the commands
 * @param hCommand Commanded Airspeed
 * @param uCommand Log value 2 
 * @param rCommand Log value 3 
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
41 42
static inline uint16_t mavlink_msg_mid_lvl_cmds_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
						       uint8_t target, float hCommand, float uCommand, float rCommand)
James Goppert's avatar
James Goppert committed
43 44 45
{
	msg->msgid = MAVLINK_MSG_ID_MID_LVL_CMDS;

lm's avatar
lm committed
46 47 48 49
	put_float_by_index(msg, 0, hCommand); // Commanded Airspeed
	put_float_by_index(msg, 4, uCommand); // Log value 2 
	put_float_by_index(msg, 8, rCommand); // Log value 3 
	put_uint8_t_by_index(msg, 12, target); // The system setting the commands
James Goppert's avatar
James Goppert committed
50

lm's avatar
lm committed
51
	return mavlink_finalize_message(msg, system_id, component_id, 13, 146);
James Goppert's avatar
James Goppert committed
52 53
}

James Goppert's avatar
James Goppert committed
54
/**
lm's avatar
lm committed
55
 * @brief Pack a mid_lvl_cmds message on a channel
James Goppert's avatar
James Goppert committed
56 57 58 59 60 61 62 63 64 65
 * @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 The system setting the commands
 * @param hCommand Commanded Airspeed
 * @param uCommand Log value 2 
 * @param rCommand Log value 3 
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79
static inline uint16_t mavlink_msg_mid_lvl_cmds_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
							   mavlink_message_t* msg,
						           uint8_t target,float hCommand,float uCommand,float rCommand)
{
	msg->msgid = MAVLINK_MSG_ID_MID_LVL_CMDS;

	put_float_by_index(msg, 0, hCommand); // Commanded Airspeed
	put_float_by_index(msg, 4, uCommand); // Log value 2 
	put_float_by_index(msg, 8, rCommand); // Log value 3 
	put_uint8_t_by_index(msg, 12, target); // The system setting the commands

	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 13, 146);
}

James Goppert's avatar
James Goppert committed
80 81 82 83 84 85 86 87
/**
 * @brief Encode a mid_lvl_cmds struct into a message
 *
 * @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 mid_lvl_cmds C-struct to read the message contents from
 */
James Goppert's avatar
James Goppert committed
88 89 90 91 92
static inline uint16_t mavlink_msg_mid_lvl_cmds_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mid_lvl_cmds_t* mid_lvl_cmds)
{
	return mavlink_msg_mid_lvl_cmds_pack(system_id, component_id, msg, mid_lvl_cmds->target, mid_lvl_cmds->hCommand, mid_lvl_cmds->uCommand, mid_lvl_cmds->rCommand);
}

James Goppert's avatar
James Goppert committed
93 94 95 96 97 98 99 100 101
/**
 * @brief Send a mid_lvl_cmds message
 * @param chan MAVLink channel to send the message
 *
 * @param target The system setting the commands
 * @param hCommand Commanded Airspeed
 * @param uCommand Log value 2 
 * @param rCommand Log value 3 
 */
lm's avatar
lm committed
102 103
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

lm's avatar
lm committed
104 105
static inline void mavlink_msg_mid_lvl_cmds_send(mavlink_channel_t chan, uint8_t target, float hCommand, float uCommand, float rCommand)
{
lm's avatar
lm committed
106
	MAVLINK_ALIGNED_MESSAGE(msg, 13);
LM's avatar
LM committed
107 108 109 110 111 112 113 114
	msg->msgid = MAVLINK_MSG_ID_MID_LVL_CMDS;

	put_float_by_index(msg, 0, hCommand); // Commanded Airspeed
	put_float_by_index(msg, 4, uCommand); // Log value 2 
	put_float_by_index(msg, 8, rCommand); // Log value 3 
	put_uint8_t_by_index(msg, 12, target); // The system setting the commands

	mavlink_finalize_message_chan_send(msg, chan, 13, 146);
James Goppert's avatar
James Goppert committed
115 116 117
}

#endif
lm's avatar
lm committed
118

James Goppert's avatar
James Goppert committed
119 120
// MESSAGE MID_LVL_CMDS UNPACKING

lm's avatar
lm committed
121

James Goppert's avatar
James Goppert committed
122 123 124 125 126 127 128
/**
 * @brief Get field target from mid_lvl_cmds message
 *
 * @return The system setting the commands
 */
static inline uint8_t mavlink_msg_mid_lvl_cmds_get_target(const mavlink_message_t* msg)
{
lm's avatar
lm committed
129
	return MAVLINK_MSG_RETURN_uint8_t(msg,  12);
James Goppert's avatar
James Goppert committed
130 131 132 133 134 135 136 137 138
}

/**
 * @brief Get field hCommand from mid_lvl_cmds message
 *
 * @return Commanded Airspeed
 */
static inline float mavlink_msg_mid_lvl_cmds_get_hCommand(const mavlink_message_t* msg)
{
lm's avatar
lm committed
139
	return MAVLINK_MSG_RETURN_float(msg,  0);
James Goppert's avatar
James Goppert committed
140 141 142 143 144 145 146 147 148
}

/**
 * @brief Get field uCommand from mid_lvl_cmds message
 *
 * @return Log value 2 
 */
static inline float mavlink_msg_mid_lvl_cmds_get_uCommand(const mavlink_message_t* msg)
{
lm's avatar
lm committed
149
	return MAVLINK_MSG_RETURN_float(msg,  4);
James Goppert's avatar
James Goppert committed
150 151 152 153 154 155 156 157 158
}

/**
 * @brief Get field rCommand from mid_lvl_cmds message
 *
 * @return Log value 3 
 */
static inline float mavlink_msg_mid_lvl_cmds_get_rCommand(const mavlink_message_t* msg)
{
lm's avatar
lm committed
159
	return MAVLINK_MSG_RETURN_float(msg,  8);
James Goppert's avatar
James Goppert committed
160 161
}

James Goppert's avatar
James Goppert committed
162 163 164 165 166 167
/**
 * @brief Decode a mid_lvl_cmds message into a struct
 *
 * @param msg The message to decode
 * @param mid_lvl_cmds C-struct to decode the message contents into
 */
James Goppert's avatar
James Goppert committed
168 169
static inline void mavlink_msg_mid_lvl_cmds_decode(const mavlink_message_t* msg, mavlink_mid_lvl_cmds_t* mid_lvl_cmds)
{
lm's avatar
lm committed
170 171 172 173 174 175 176 177
#if MAVLINK_NEED_BYTE_SWAP
	mid_lvl_cmds->hCommand = mavlink_msg_mid_lvl_cmds_get_hCommand(msg);
	mid_lvl_cmds->uCommand = mavlink_msg_mid_lvl_cmds_get_uCommand(msg);
	mid_lvl_cmds->rCommand = mavlink_msg_mid_lvl_cmds_get_rCommand(msg);
	mid_lvl_cmds->target = mavlink_msg_mid_lvl_cmds_get_target(msg);
#else
	memcpy(mid_lvl_cmds, MAVLINK_PAYLOAD(msg), 13);
#endif
James Goppert's avatar
James Goppert committed
178
}