Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
mavlink_msg_command_ack.h
00001 // MESSAGE COMMAND_ACK PACKING 00002 00003 #define MAVLINK_MSG_ID_COMMAND_ACK 76 00004 00005 typedef struct __mavlink_command_ack_t 00006 { 00007 float command; ///< Current airspeed in m/s 00008 float result; ///< 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION 00009 00010 } mavlink_command_ack_t; 00011 00012 00013 00014 /** 00015 * @brief Pack a command_ack message 00016 * @param system_id ID of this system 00017 * @param component_id ID of this component (e.g. 200 for IMU) 00018 * @param msg The MAVLink message to compress the data into 00019 * 00020 * @param command Current airspeed in m/s 00021 * @param result 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION 00022 * @return length of the message in bytes (excluding serial stream start sign) 00023 */ 00024 static inline uint16_t mavlink_msg_command_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, float command, float result) 00025 { 00026 uint16_t i = 0; 00027 msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK; 00028 00029 i += put_float_by_index(command, i, msg->payload); // Current airspeed in m/s 00030 i += put_float_by_index(result, i, msg->payload); // 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION 00031 00032 return mavlink_finalize_message(msg, system_id, component_id, i); 00033 } 00034 00035 /** 00036 * @brief Pack a command_ack message 00037 * @param system_id ID of this system 00038 * @param component_id ID of this component (e.g. 200 for IMU) 00039 * @param chan The MAVLink channel this message was sent over 00040 * @param msg The MAVLink message to compress the data into 00041 * @param command Current airspeed in m/s 00042 * @param result 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION 00043 * @return length of the message in bytes (excluding serial stream start sign) 00044 */ 00045 static inline uint16_t mavlink_msg_command_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, float command, float result) 00046 { 00047 uint16_t i = 0; 00048 msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK; 00049 00050 i += put_float_by_index(command, i, msg->payload); // Current airspeed in m/s 00051 i += put_float_by_index(result, i, msg->payload); // 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION 00052 00053 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); 00054 } 00055 00056 /** 00057 * @brief Encode a command_ack struct into a message 00058 * 00059 * @param system_id ID of this system 00060 * @param component_id ID of this component (e.g. 200 for IMU) 00061 * @param msg The MAVLink message to compress the data into 00062 * @param command_ack C-struct to read the message contents from 00063 */ 00064 static inline uint16_t mavlink_msg_command_ack_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_command_ack_t* command_ack) 00065 { 00066 return mavlink_msg_command_ack_pack(system_id, component_id, msg, command_ack->command, command_ack->result); 00067 } 00068 00069 /** 00070 * @brief Send a command_ack message 00071 * @param chan MAVLink channel to send the message 00072 * 00073 * @param command Current airspeed in m/s 00074 * @param result 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION 00075 */ 00076 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 00077 00078 static inline void mavlink_msg_command_ack_send(mavlink_channel_t chan, float command, float result) 00079 { 00080 mavlink_message_t msg; 00081 mavlink_msg_command_ack_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, command, result); 00082 mavlink_send_uart(chan, &msg); 00083 } 00084 00085 #endif 00086 // MESSAGE COMMAND_ACK UNPACKING 00087 00088 /** 00089 * @brief Get field command from command_ack message 00090 * 00091 * @return Current airspeed in m/s 00092 */ 00093 static inline float mavlink_msg_command_ack_get_command(const mavlink_message_t* msg) 00094 { 00095 generic_32bit r; 00096 r.b[3] = (msg->payload)[0]; 00097 r.b[2] = (msg->payload)[1]; 00098 r.b[1] = (msg->payload)[2]; 00099 r.b[0] = (msg->payload)[3]; 00100 return (float)r.f; 00101 } 00102 00103 /** 00104 * @brief Get field result from command_ack message 00105 * 00106 * @return 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION 00107 */ 00108 static inline float mavlink_msg_command_ack_get_result(const mavlink_message_t* msg) 00109 { 00110 generic_32bit r; 00111 r.b[3] = (msg->payload+sizeof(float))[0]; 00112 r.b[2] = (msg->payload+sizeof(float))[1]; 00113 r.b[1] = (msg->payload+sizeof(float))[2]; 00114 r.b[0] = (msg->payload+sizeof(float))[3]; 00115 return (float)r.f; 00116 } 00117 00118 /** 00119 * @brief Decode a command_ack message into a struct 00120 * 00121 * @param msg The message to decode 00122 * @param command_ack C-struct to decode the message contents into 00123 */ 00124 static inline void mavlink_msg_command_ack_decode(const mavlink_message_t* msg, mavlink_command_ack_t* command_ack) 00125 { 00126 command_ack->command = mavlink_msg_command_ack_get_command(msg); 00127 command_ack->result = mavlink_msg_command_ack_get_result(msg); 00128 }
Generated on Tue Jul 12 2022 14:09:26 by 1.7.2