![](/media/cache/profiles/2012_sf_avc_095.jpg.50x50_q85.jpg)
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_named_value_float.h
00001 // MESSAGE NAMED_VALUE_FLOAT PACKING 00002 00003 #define MAVLINK_MSG_ID_NAMED_VALUE_FLOAT 252 00004 00005 typedef struct __mavlink_named_value_float_t 00006 { 00007 char name[10]; ///< Name of the debug variable 00008 float value; ///< Floating point value 00009 00010 } mavlink_named_value_float_t; 00011 00012 #define MAVLINK_MSG_NAMED_VALUE_FLOAT_FIELD_NAME_LEN 10 00013 00014 00015 /** 00016 * @brief Pack a named_value_float message 00017 * @param system_id ID of this system 00018 * @param component_id ID of this component (e.g. 200 for IMU) 00019 * @param msg The MAVLink message to compress the data into 00020 * 00021 * @param name Name of the debug variable 00022 * @param value Floating point value 00023 * @return length of the message in bytes (excluding serial stream start sign) 00024 */ 00025 static inline uint16_t mavlink_msg_named_value_float_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const char* name, float value) 00026 { 00027 uint16_t i = 0; 00028 msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_FLOAT; 00029 00030 i += put_array_by_index((const int8_t*)name, sizeof(char)*10, i, msg->payload); // Name of the debug variable 00031 i += put_float_by_index(value, i, msg->payload); // Floating point value 00032 00033 return mavlink_finalize_message(msg, system_id, component_id, i); 00034 } 00035 00036 /** 00037 * @brief Pack a named_value_float message 00038 * @param system_id ID of this system 00039 * @param component_id ID of this component (e.g. 200 for IMU) 00040 * @param chan The MAVLink channel this message was sent over 00041 * @param msg The MAVLink message to compress the data into 00042 * @param name Name of the debug variable 00043 * @param value Floating point value 00044 * @return length of the message in bytes (excluding serial stream start sign) 00045 */ 00046 static inline uint16_t mavlink_msg_named_value_float_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const char* name, float value) 00047 { 00048 uint16_t i = 0; 00049 msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_FLOAT; 00050 00051 i += put_array_by_index((const int8_t*)name, sizeof(char)*10, i, msg->payload); // Name of the debug variable 00052 i += put_float_by_index(value, i, msg->payload); // Floating point value 00053 00054 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); 00055 } 00056 00057 /** 00058 * @brief Encode a named_value_float struct into a message 00059 * 00060 * @param system_id ID of this system 00061 * @param component_id ID of this component (e.g. 200 for IMU) 00062 * @param msg The MAVLink message to compress the data into 00063 * @param named_value_float C-struct to read the message contents from 00064 */ 00065 static inline uint16_t mavlink_msg_named_value_float_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_named_value_float_t* named_value_float) 00066 { 00067 return mavlink_msg_named_value_float_pack(system_id, component_id, msg, named_value_float->name, named_value_float->value); 00068 } 00069 00070 /** 00071 * @brief Send a named_value_float message 00072 * @param chan MAVLink channel to send the message 00073 * 00074 * @param name Name of the debug variable 00075 * @param value Floating point value 00076 */ 00077 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 00078 00079 static inline void mavlink_msg_named_value_float_send(mavlink_channel_t chan, const char* name, float value) 00080 { 00081 mavlink_message_t msg; 00082 mavlink_msg_named_value_float_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, name, value); 00083 mavlink_send_uart(chan, &msg); 00084 } 00085 00086 #endif 00087 // MESSAGE NAMED_VALUE_FLOAT UNPACKING 00088 00089 /** 00090 * @brief Get field name from named_value_float message 00091 * 00092 * @return Name of the debug variable 00093 */ 00094 static inline uint16_t mavlink_msg_named_value_float_get_name(const mavlink_message_t* msg, char* r_data) 00095 { 00096 00097 memcpy(r_data, msg->payload, sizeof(char)*10); 00098 return sizeof(char)*10; 00099 } 00100 00101 /** 00102 * @brief Get field value from named_value_float message 00103 * 00104 * @return Floating point value 00105 */ 00106 static inline float mavlink_msg_named_value_float_get_value(const mavlink_message_t* msg) 00107 { 00108 generic_32bit r; 00109 r.b[3] = (msg->payload+sizeof(char)*10)[0]; 00110 r.b[2] = (msg->payload+sizeof(char)*10)[1]; 00111 r.b[1] = (msg->payload+sizeof(char)*10)[2]; 00112 r.b[0] = (msg->payload+sizeof(char)*10)[3]; 00113 return (float)r.f; 00114 } 00115 00116 /** 00117 * @brief Decode a named_value_float message into a struct 00118 * 00119 * @param msg The message to decode 00120 * @param named_value_float C-struct to decode the message contents into 00121 */ 00122 static inline void mavlink_msg_named_value_float_decode(const mavlink_message_t* msg, mavlink_named_value_float_t* named_value_float) 00123 { 00124 mavlink_msg_named_value_float_get_name(msg, named_value_float->name); 00125 named_value_float->value = mavlink_msg_named_value_float_get_value(msg); 00126 }
Generated on Tue Jul 12 2022 14:09:26 by
![doxygen](doxygen.png)