mavlink_msg_pwm_commands.h 9.95 KB
Newer Older
James Goppert's avatar
James Goppert committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
// MESSAGE PWM_COMMANDS PACKING

#define MAVLINK_MSG_ID_PWM_COMMANDS 175

typedef struct __mavlink_pwm_commands_t 
{
	uint16_t dt_c; ///< AutoPilot's throttle command 
	uint16_t dla_c; ///< AutoPilot's left aileron command 
	uint16_t dra_c; ///< AutoPilot's right aileron command 
	uint16_t dr_c; ///< AutoPilot's rudder command 
	uint16_t dle_c; ///< AutoPilot's left elevator command 
	uint16_t dre_c; ///< AutoPilot's right elevator command 
	uint16_t dlf_c; ///< AutoPilot's left  flap command 
	uint16_t drf_c; ///< AutoPilot's right flap command 
	uint16_t aux1; ///< AutoPilot's aux1 command 
	uint16_t aux2; ///< AutoPilot's aux2 command 

} mavlink_pwm_commands_t;



/**
 * @brief Send a pwm_commands message
 *
 * @param dt_c AutoPilot's throttle command 
 * @param dla_c AutoPilot's left aileron command 
 * @param dra_c AutoPilot's right aileron command 
 * @param dr_c AutoPilot's rudder command 
 * @param dle_c AutoPilot's left elevator command 
 * @param dre_c AutoPilot's right elevator command 
 * @param dlf_c AutoPilot's left  flap command 
 * @param drf_c AutoPilot's right flap command 
 * @param aux1 AutoPilot's aux1 command 
 * @param aux2 AutoPilot's aux2 command 
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_pwm_commands_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint16_t dt_c, uint16_t dla_c, uint16_t dra_c, uint16_t dr_c, uint16_t dle_c, uint16_t dre_c, uint16_t dlf_c, uint16_t drf_c, uint16_t aux1, uint16_t aux2)
{
	uint16_t i = 0;
	msg->msgid = MAVLINK_MSG_ID_PWM_COMMANDS;

	i += put_uint16_t_by_index(dt_c, i, msg->payload); //AutoPilot's throttle command 
	i += put_uint16_t_by_index(dla_c, i, msg->payload); //AutoPilot's left aileron command 
	i += put_uint16_t_by_index(dra_c, i, msg->payload); //AutoPilot's right aileron command 
	i += put_uint16_t_by_index(dr_c, i, msg->payload); //AutoPilot's rudder command 
	i += put_uint16_t_by_index(dle_c, i, msg->payload); //AutoPilot's left elevator command 
	i += put_uint16_t_by_index(dre_c, i, msg->payload); //AutoPilot's right elevator command 
	i += put_uint16_t_by_index(dlf_c, i, msg->payload); //AutoPilot's left  flap command 
	i += put_uint16_t_by_index(drf_c, i, msg->payload); //AutoPilot's right flap command 
	i += put_uint16_t_by_index(aux1, i, msg->payload); //AutoPilot's aux1 command 
	i += put_uint16_t_by_index(aux2, i, msg->payload); //AutoPilot's aux2 command 

	return mavlink_finalize_message(msg, system_id, component_id, i);
}

static inline uint16_t mavlink_msg_pwm_commands_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t target, uint16_t dt_c, uint16_t dla_c, uint16_t dra_c, uint16_t dr_c, uint16_t dle_c, uint16_t dre_c, uint16_t dlf_c, uint16_t drf_c, uint16_t aux1, uint16_t aux2)
{
	uint16_t i = 0;
	msg->msgid = MAVLINK_MSG_ID_PWM_COMMANDS;

	i += put_uint8_t_by_index(target, i, msg->payload); //The system reporting the diagnostic
	i += put_uint16_t_by_index(dt_c, i, msg->payload); //AutoPilot's throttle command 
	i += put_uint16_t_by_index(dla_c, i, msg->payload); //AutoPilot's left aileron command 
	i += put_uint16_t_by_index(dra_c, i, msg->payload); //AutoPilot's right aileron command 
	i += put_uint16_t_by_index(dr_c, i, msg->payload); //AutoPilot's rudder command 
	i += put_uint16_t_by_index(dle_c, i, msg->payload); //AutoPilot's left elevator command 
	i += put_uint16_t_by_index(dre_c, i, msg->payload); //AutoPilot's right elevator command 
	i += put_uint16_t_by_index(dlf_c, i, msg->payload); //AutoPilot's left  flap command 
	i += put_uint16_t_by_index(drf_c, i, msg->payload); //AutoPilot's right flap command 
	i += put_uint16_t_by_index(aux1, i, msg->payload); //AutoPilot's aux1 command 
	i += put_uint16_t_by_index(aux2, i, msg->payload); //AutoPilot's aux2 command 

	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
}

static inline uint16_t mavlink_msg_pwm_commands_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_pwm_commands_t* pwm_commands)
{
	return mavlink_msg_pwm_commands_pack(system_id, component_id, msg, pwm_commands->dt_c, pwm_commands->dla_c, pwm_commands->dra_c, pwm_commands->dr_c, pwm_commands->dle_c, pwm_commands->dre_c, pwm_commands->dlf_c, pwm_commands->drf_c, pwm_commands->aux1, pwm_commands->aux2);
}

#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_pwm_commands_send(mavlink_channel_t chan, uint16_t dt_c, uint16_t dla_c, uint16_t dra_c, uint16_t dr_c, uint16_t dle_c, uint16_t dre_c, uint16_t dlf_c, uint16_t drf_c, uint16_t aux1, uint16_t aux2)
{
	mavlink_message_t msg;
	mavlink_msg_pwm_commands_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, target, dt_c, dla_c, dra_c, dr_c, dle_c, dre_c, dlf_c, drf_c, aux1, aux2);
	mavlink_send_uart(chan, &msg);
}

#endif
// MESSAGE PWM_COMMANDS UNPACKING

/**
 * @brief Get field dt_c from pwm_commands message
 *
 * @return AutoPilot's throttle command 
 */
static inline uint16_t mavlink_msg_pwm_commands_get_dt_c(const mavlink_message_t* msg)
{
	generic_16bit r;
	r.b[1] = (msg->payload)[0];
	r.b[0] = (msg->payload)[1];
	return (uint16_t)r.s;
}

/**
 * @brief Get field dla_c from pwm_commands message
 *
 * @return AutoPilot's left aileron command 
 */
static inline uint16_t mavlink_msg_pwm_commands_get_dla_c(const mavlink_message_t* msg)
{
	generic_16bit r;
	r.b[1] = (msg->payload+sizeof(uint16_t))[0];
	r.b[0] = (msg->payload+sizeof(uint16_t))[1];
	return (uint16_t)r.s;
}

/**
 * @brief Get field dra_c from pwm_commands message
 *
 * @return AutoPilot's right aileron command 
 */
static inline uint16_t mavlink_msg_pwm_commands_get_dra_c(const mavlink_message_t* msg)
{
	generic_16bit r;
	r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t))[0];
	r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t))[1];
	return (uint16_t)r.s;
}

/**
 * @brief Get field dr_c from pwm_commands message
 *
 * @return AutoPilot's rudder command 
 */
static inline uint16_t mavlink_msg_pwm_commands_get_dr_c(const mavlink_message_t* msg)
{
	generic_16bit r;
	r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0];
	r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1];
	return (uint16_t)r.s;
}

/**
 * @brief Get field dle_c from pwm_commands message
 *
 * @return AutoPilot's left elevator command 
 */
static inline uint16_t mavlink_msg_pwm_commands_get_dle_c(const mavlink_message_t* msg)
{
	generic_16bit r;
	r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0];
	r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1];
	return (uint16_t)r.s;
}

/**
 * @brief Get field dre_c from pwm_commands message
 *
 * @return AutoPilot's right elevator command 
 */
static inline uint16_t mavlink_msg_pwm_commands_get_dre_c(const mavlink_message_t* msg)
{
	generic_16bit r;
	r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0];
	r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1];
	return (uint16_t)r.s;
}

/**
 * @brief Get field dlf_c from pwm_commands message
 *
 * @return AutoPilot's left  flap command 
 */
static inline uint16_t mavlink_msg_pwm_commands_get_dlf_c(const mavlink_message_t* msg)
{
	generic_16bit r;
	r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0];
	r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1];
	return (uint16_t)r.s;
}

/**
 * @brief Get field drf_c from pwm_commands message
 *
 * @return AutoPilot's right flap command 
 */
static inline uint16_t mavlink_msg_pwm_commands_get_drf_c(const mavlink_message_t* msg)
{
	generic_16bit r;
	r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0];
	r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1];
	return (uint16_t)r.s;
}

/**
 * @brief Get field aux1 from pwm_commands message
 *
 * @return AutoPilot's aux1 command 
 */
static inline uint16_t mavlink_msg_pwm_commands_get_aux1(const mavlink_message_t* msg)
{
	generic_16bit r;
	r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0];
	r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1];
	return (uint16_t)r.s;
}

/**
 * @brief Get field aux2 from pwm_commands message
 *
 * @return AutoPilot's aux2 command 
 */
static inline uint16_t mavlink_msg_pwm_commands_get_aux2(const mavlink_message_t* msg)
{
	generic_16bit r;
	r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0];
	r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1];
	return (uint16_t)r.s;
}

static inline void mavlink_msg_pwm_commands_decode(const mavlink_message_t* msg, mavlink_pwm_commands_t* pwm_commands)
{
	pwm_commands->dt_c = mavlink_msg_pwm_commands_get_dt_c(msg);
	pwm_commands->dla_c = mavlink_msg_pwm_commands_get_dla_c(msg);
	pwm_commands->dra_c = mavlink_msg_pwm_commands_get_dra_c(msg);
	pwm_commands->dr_c = mavlink_msg_pwm_commands_get_dr_c(msg);
	pwm_commands->dle_c = mavlink_msg_pwm_commands_get_dle_c(msg);
	pwm_commands->dre_c = mavlink_msg_pwm_commands_get_dre_c(msg);
	pwm_commands->dlf_c = mavlink_msg_pwm_commands_get_dlf_c(msg);
	pwm_commands->drf_c = mavlink_msg_pwm_commands_get_drf_c(msg);
	pwm_commands->aux1 = mavlink_msg_pwm_commands_get_aux1(msg);
	pwm_commands->aux2 = mavlink_msg_pwm_commands_get_aux2(msg);
}