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_param_set.h
00001 // MESSAGE PARAM_SET PACKING 00002 00003 #define MAVLINK_MSG_ID_PARAM_SET 23 00004 00005 typedef struct __mavlink_param_set_t 00006 { 00007 uint8_t target_system; ///< System ID 00008 uint8_t target_component; ///< Component ID 00009 int8_t param_id[15]; ///< Onboard parameter id 00010 float param_value; ///< Onboard parameter value 00011 00012 } mavlink_param_set_t; 00013 00014 #define MAVLINK_MSG_PARAM_SET_FIELD_PARAM_ID_LEN 15 00015 00016 00017 /** 00018 * @brief Pack a param_set message 00019 * @param system_id ID of this system 00020 * @param component_id ID of this component (e.g. 200 for IMU) 00021 * @param msg The MAVLink message to compress the data into 00022 * 00023 * @param target_system System ID 00024 * @param target_component Component ID 00025 * @param param_id Onboard parameter id 00026 * @param param_value Onboard parameter value 00027 * @return length of the message in bytes (excluding serial stream start sign) 00028 */ 00029 static inline uint16_t mavlink_msg_param_set_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t target_system, uint8_t target_component, const int8_t* param_id, float param_value) 00030 { 00031 uint16_t i = 0; 00032 msg->msgid = MAVLINK_MSG_ID_PARAM_SET; 00033 00034 i += put_uint8_t_by_index(target_system, i, msg->payload); // System ID 00035 i += put_uint8_t_by_index(target_component, i, msg->payload); // Component ID 00036 i += put_array_by_index(param_id, 15, i, msg->payload); // Onboard parameter id 00037 i += put_float_by_index(param_value, i, msg->payload); // Onboard parameter value 00038 00039 return mavlink_finalize_message(msg, system_id, component_id, i); 00040 } 00041 00042 /** 00043 * @brief Pack a param_set message 00044 * @param system_id ID of this system 00045 * @param component_id ID of this component (e.g. 200 for IMU) 00046 * @param chan The MAVLink channel this message was sent over 00047 * @param msg The MAVLink message to compress the data into 00048 * @param target_system System ID 00049 * @param target_component Component ID 00050 * @param param_id Onboard parameter id 00051 * @param param_value Onboard parameter value 00052 * @return length of the message in bytes (excluding serial stream start sign) 00053 */ 00054 static inline uint16_t mavlink_msg_param_set_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, const int8_t* param_id, float param_value) 00055 { 00056 uint16_t i = 0; 00057 msg->msgid = MAVLINK_MSG_ID_PARAM_SET; 00058 00059 i += put_uint8_t_by_index(target_system, i, msg->payload); // System ID 00060 i += put_uint8_t_by_index(target_component, i, msg->payload); // Component ID 00061 i += put_array_by_index(param_id, 15, i, msg->payload); // Onboard parameter id 00062 i += put_float_by_index(param_value, i, msg->payload); // Onboard parameter value 00063 00064 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); 00065 } 00066 00067 /** 00068 * @brief Encode a param_set struct into a message 00069 * 00070 * @param system_id ID of this system 00071 * @param component_id ID of this component (e.g. 200 for IMU) 00072 * @param msg The MAVLink message to compress the data into 00073 * @param param_set C-struct to read the message contents from 00074 */ 00075 static inline uint16_t mavlink_msg_param_set_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_param_set_t* param_set) 00076 { 00077 return mavlink_msg_param_set_pack(system_id, component_id, msg, param_set->target_system, param_set->target_component, param_set->param_id, param_set->param_value); 00078 } 00079 00080 /** 00081 * @brief Send a param_set message 00082 * @param chan MAVLink channel to send the message 00083 * 00084 * @param target_system System ID 00085 * @param target_component Component ID 00086 * @param param_id Onboard parameter id 00087 * @param param_value Onboard parameter value 00088 */ 00089 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 00090 00091 static inline void mavlink_msg_param_set_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, const int8_t* param_id, float param_value) 00092 { 00093 mavlink_message_t msg; 00094 mavlink_msg_param_set_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, target_system, target_component, param_id, param_value); 00095 mavlink_send_uart(chan, &msg); 00096 } 00097 00098 #endif 00099 // MESSAGE PARAM_SET UNPACKING 00100 00101 /** 00102 * @brief Get field target_system from param_set message 00103 * 00104 * @return System ID 00105 */ 00106 static inline uint8_t mavlink_msg_param_set_get_target_system(const mavlink_message_t* msg) 00107 { 00108 return (uint8_t)(msg->payload)[0]; 00109 } 00110 00111 /** 00112 * @brief Get field target_component from param_set message 00113 * 00114 * @return Component ID 00115 */ 00116 static inline uint8_t mavlink_msg_param_set_get_target_component(const mavlink_message_t* msg) 00117 { 00118 return (uint8_t)(msg->payload+sizeof(uint8_t))[0]; 00119 } 00120 00121 /** 00122 * @brief Get field param_id from param_set message 00123 * 00124 * @return Onboard parameter id 00125 */ 00126 static inline uint16_t mavlink_msg_param_set_get_param_id(const mavlink_message_t* msg, int8_t* r_data) 00127 { 00128 00129 memcpy(r_data, msg->payload+sizeof(uint8_t)+sizeof(uint8_t), 15); 00130 return 15; 00131 } 00132 00133 /** 00134 * @brief Get field param_value from param_set message 00135 * 00136 * @return Onboard parameter value 00137 */ 00138 static inline float mavlink_msg_param_set_get_param_value(const mavlink_message_t* msg) 00139 { 00140 generic_32bit r; 00141 r.b[3] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+15)[0]; 00142 r.b[2] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+15)[1]; 00143 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+15)[2]; 00144 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+15)[3]; 00145 return (float)r.f; 00146 } 00147 00148 /** 00149 * @brief Decode a param_set message into a struct 00150 * 00151 * @param msg The message to decode 00152 * @param param_set C-struct to decode the message contents into 00153 */ 00154 static inline void mavlink_msg_param_set_decode(const mavlink_message_t* msg, mavlink_param_set_t* param_set) 00155 { 00156 param_set->target_system = mavlink_msg_param_set_get_target_system(msg); 00157 param_set->target_component = mavlink_msg_param_set_get_target_component(msg); 00158 mavlink_msg_param_set_get_param_id(msg, param_set->param_id); 00159 param_set->param_value = mavlink_msg_param_set_get_param_value(msg); 00160 }
Generated on Tue Jul 12 2022 14:09:26 by 1.7.2