Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / libraries / mavlink / v1.0 / common / mavlink_msg_param_value.h
blob2b96fb9fe8075ee05e5aafaa5dcc8de5dae5e1e1
1 // MESSAGE PARAM_VALUE PACKING
3 #define MAVLINK_MSG_ID_PARAM_VALUE 22
5 typedef struct __mavlink_param_value_t {
6 float param_value; ///< Onboard parameter value
7 uint16_t param_count; ///< Total number of onboard parameters
8 uint16_t param_index; ///< Index of this onboard parameter
9 char param_id[16]; ///< Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string
10 uint8_t param_type; ///< Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types.
11 } mavlink_param_value_t;
13 #define MAVLINK_MSG_ID_PARAM_VALUE_LEN 25
14 #define MAVLINK_MSG_ID_22_LEN 25
16 #define MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN 16
18 #define MAVLINK_MESSAGE_INFO_PARAM_VALUE \
19 { \
20 "PARAM_VALUE", \
21 5, \
22 { \
23 { "param_value", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_param_value_t, param_value) }, \
24 { "param_count", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_param_value_t, param_count) }, \
25 { "param_index", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_param_value_t, param_index) }, \
26 { "param_id", NULL, MAVLINK_TYPE_CHAR, 16, 8, offsetof(mavlink_param_value_t, param_id) }, \
27 { "param_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_param_value_t, param_type) }, \
28 } \
32 /**
33 * @brief Pack a param_value message
34 * @param system_id ID of this system
35 * @param component_id ID of this component (e.g. 200 for IMU)
36 * @param msg The MAVLink message to compress the data into
38 * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string
39 * @param param_value Onboard parameter value
40 * @param param_type Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types.
41 * @param param_count Total number of onboard parameters
42 * @param param_index Index of this onboard parameter
43 * @return length of the message in bytes (excluding serial stream start sign)
45 static inline uint16_t mavlink_msg_param_value_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg,
46 const char *param_id, float param_value, uint8_t param_type, uint16_t param_count, uint16_t param_index)
48 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
49 char buf[25];
50 _mav_put_float(buf, 0, param_value);
51 _mav_put_uint16_t(buf, 4, param_count);
52 _mav_put_uint16_t(buf, 6, param_index);
53 _mav_put_uint8_t(buf, 24, param_type);
54 _mav_put_char_array(buf, 8, param_id, 16);
55 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 25);
56 #else
57 mavlink_param_value_t packet;
58 packet.param_value = param_value;
59 packet.param_count = param_count;
60 packet.param_index = param_index;
61 packet.param_type = param_type;
62 mav_array_memcpy(packet.param_id, param_id, sizeof(char) * 16);
63 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 25);
64 #endif
66 msg->msgid = MAVLINK_MSG_ID_PARAM_VALUE;
67 return mavlink_finalize_message(msg, system_id, component_id, 25, 220);
70 /**
71 * @brief Pack a param_value message on a channel
72 * @param system_id ID of this system
73 * @param component_id ID of this component (e.g. 200 for IMU)
74 * @param chan The MAVLink channel this message was sent over
75 * @param msg The MAVLink message to compress the data into
76 * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string
77 * @param param_value Onboard parameter value
78 * @param param_type Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types.
79 * @param param_count Total number of onboard parameters
80 * @param param_index Index of this onboard parameter
81 * @return length of the message in bytes (excluding serial stream start sign)
83 static inline uint16_t mavlink_msg_param_value_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
84 mavlink_message_t *msg,
85 const char *param_id, float param_value, uint8_t param_type, uint16_t param_count, uint16_t param_index)
87 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
88 char buf[25];
89 _mav_put_float(buf, 0, param_value);
90 _mav_put_uint16_t(buf, 4, param_count);
91 _mav_put_uint16_t(buf, 6, param_index);
92 _mav_put_uint8_t(buf, 24, param_type);
93 _mav_put_char_array(buf, 8, param_id, 16);
94 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 25);
95 #else
96 mavlink_param_value_t packet;
97 packet.param_value = param_value;
98 packet.param_count = param_count;
99 packet.param_index = param_index;
100 packet.param_type = param_type;
101 mav_array_memcpy(packet.param_id, param_id, sizeof(char) * 16);
102 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 25);
103 #endif
105 msg->msgid = MAVLINK_MSG_ID_PARAM_VALUE;
106 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 25, 220);
110 * @brief Encode a param_value struct into a message
112 * @param system_id ID of this system
113 * @param component_id ID of this component (e.g. 200 for IMU)
114 * @param msg The MAVLink message to compress the data into
115 * @param param_value C-struct to read the message contents from
117 static inline uint16_t mavlink_msg_param_value_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg, const mavlink_param_value_t *param_value)
119 return mavlink_msg_param_value_pack(system_id, component_id, msg, param_value->param_id, param_value->param_value, param_value->param_type, param_value->param_count, param_value->param_index);
123 * @brief Send a param_value message
124 * @param chan MAVLink channel to send the message
126 * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string
127 * @param param_value Onboard parameter value
128 * @param param_type Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types.
129 * @param param_count Total number of onboard parameters
130 * @param param_index Index of this onboard parameter
132 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
134 static inline void mavlink_msg_param_value_send(mavlink_channel_t chan, const char *param_id, float param_value, uint8_t param_type, uint16_t param_count, uint16_t param_index)
136 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
137 char buf[25];
138 _mav_put_float(buf, 0, param_value);
139 _mav_put_uint16_t(buf, 4, param_count);
140 _mav_put_uint16_t(buf, 6, param_index);
141 _mav_put_uint8_t(buf, 24, param_type);
142 _mav_put_char_array(buf, 8, param_id, 16);
143 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_VALUE, buf, 25, 220);
144 #else
145 mavlink_param_value_t packet;
146 packet.param_value = param_value;
147 packet.param_count = param_count;
148 packet.param_index = param_index;
149 packet.param_type = param_type;
150 mav_array_memcpy(packet.param_id, param_id, sizeof(char) * 16);
151 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_VALUE, (const char *)&packet, 25, 220);
152 #endif
155 #endif // ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
157 // MESSAGE PARAM_VALUE UNPACKING
161 * @brief Get field param_id from param_value message
163 * @return Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string
165 static inline uint16_t mavlink_msg_param_value_get_param_id(const mavlink_message_t *msg, char *param_id)
167 return _MAV_RETURN_char_array(msg, param_id, 16, 8);
171 * @brief Get field param_value from param_value message
173 * @return Onboard parameter value
175 static inline float mavlink_msg_param_value_get_param_value(const mavlink_message_t *msg)
177 return _MAV_RETURN_float(msg, 0);
181 * @brief Get field param_type from param_value message
183 * @return Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types.
185 static inline uint8_t mavlink_msg_param_value_get_param_type(const mavlink_message_t *msg)
187 return _MAV_RETURN_uint8_t(msg, 24);
191 * @brief Get field param_count from param_value message
193 * @return Total number of onboard parameters
195 static inline uint16_t mavlink_msg_param_value_get_param_count(const mavlink_message_t *msg)
197 return _MAV_RETURN_uint16_t(msg, 4);
201 * @brief Get field param_index from param_value message
203 * @return Index of this onboard parameter
205 static inline uint16_t mavlink_msg_param_value_get_param_index(const mavlink_message_t *msg)
207 return _MAV_RETURN_uint16_t(msg, 6);
211 * @brief Decode a param_value message into a struct
213 * @param msg The message to decode
214 * @param param_value C-struct to decode the message contents into
216 static inline void mavlink_msg_param_value_decode(const mavlink_message_t *msg, mavlink_param_value_t *param_value)
218 #if MAVLINK_NEED_BYTE_SWAP
219 param_value->param_value = mavlink_msg_param_value_get_param_value(msg);
220 param_value->param_count = mavlink_msg_param_value_get_param_count(msg);
221 param_value->param_index = mavlink_msg_param_value_get_param_index(msg);
222 mavlink_msg_param_value_get_param_id(msg, param_value->param_id);
223 param_value->param_type = mavlink_msg_param_value_get_param_type(msg);
224 #else
225 memcpy(param_value, _MAV_PAYLOAD(msg), 25);
226 #endif