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_int.h
00001 // MESSAGE NAMED_VALUE_INT PACKING 00002 00003 #define MAVLINK_MSG_ID_NAMED_VALUE_INT 253 00004 00005 typedef struct __mavlink_named_value_int_t 00006 { 00007 char name[10]; ///< Name of the debug variable 00008 int32_t value; ///< Signed integer value 00009 00010 } mavlink_named_value_int_t; 00011 00012 #define MAVLINK_MSG_NAMED_VALUE_INT_FIELD_NAME_LEN 10 00013 00014 00015 /** 00016 * @brief Pack a named_value_int 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 Signed integer value 00023 * @return length of the message in bytes (excluding serial stream start sign) 00024 */ 00025 static inline uint16_t mavlink_msg_named_value_int_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const char* name, int32_t value) 00026 { 00027 uint16_t i = 0; 00028 msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_INT; 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_int32_t_by_index(value, i, msg->payload); // Signed integer value 00032 00033 return mavlink_finalize_message(msg, system_id, component_id, i); 00034 } 00035 00036 /** 00037 * @brief Pack a named_value_int 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 Signed integer value 00044 * @return length of the message in bytes (excluding serial stream start sign) 00045 */ 00046 static inline uint16_t mavlink_msg_named_value_int_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const char* name, int32_t value) 00047 { 00048 uint16_t i = 0; 00049 msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_INT; 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_int32_t_by_index(value, i, msg->payload); // Signed integer value 00053 00054 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); 00055 } 00056 00057 /** 00058 * @brief Encode a named_value_int 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_int C-struct to read the message contents from 00064 */ 00065 static inline uint16_t mavlink_msg_named_value_int_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_named_value_int_t* named_value_int) 00066 { 00067 return mavlink_msg_named_value_int_pack(system_id, component_id, msg, named_value_int->name, named_value_int->value); 00068 } 00069 00070 /** 00071 * @brief Send a named_value_int message 00072 * @param chan MAVLink channel to send the message 00073 * 00074 * @param name Name of the debug variable 00075 * @param value Signed integer value 00076 */ 00077 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 00078 00079 static inline void mavlink_msg_named_value_int_send(mavlink_channel_t chan, const char* name, int32_t value) 00080 { 00081 mavlink_message_t msg; 00082 mavlink_msg_named_value_int_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_INT UNPACKING 00088 00089 /** 00090 * @brief Get field name from named_value_int message 00091 * 00092 * @return Name of the debug variable 00093 */ 00094 static inline uint16_t mavlink_msg_named_value_int_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_int message 00103 * 00104 * @return Signed integer value 00105 */ 00106 static inline int32_t mavlink_msg_named_value_int_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 (int32_t)r.i; 00114 } 00115 00116 /** 00117 * @brief Decode a named_value_int message into a struct 00118 * 00119 * @param msg The message to decode 00120 * @param named_value_int C-struct to decode the message contents into 00121 */ 00122 static inline void mavlink_msg_named_value_int_decode(const mavlink_message_t* msg, mavlink_named_value_int_t* named_value_int) 00123 { 00124 mavlink_msg_named_value_int_get_name(msg, named_value_int->name); 00125 named_value_int->value = mavlink_msg_named_value_int_get_value(msg); 00126 }
Generated on Tue Jul 12 2022 14:09:26 by 1.7.2