Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / libraries / mavlink / v1.0 / common / mavlink_msg_param_set.h
blobdc241f273760c30d3c6370b7ec5a4cdb0b6f6515
1 // MESSAGE PARAM_SET PACKING
3 #define MAVLINK_MSG_ID_PARAM_SET 23
5 typedef struct __mavlink_param_set_t {
6 float param_value; ///< Onboard parameter value
7 uint8_t target_system; ///< System ID
8 uint8_t target_component; ///< Component ID
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_set_t;
13 #define MAVLINK_MSG_ID_PARAM_SET_LEN 23
14 #define MAVLINK_MSG_ID_23_LEN 23
16 #define MAVLINK_MSG_PARAM_SET_FIELD_PARAM_ID_LEN 16
18 #define MAVLINK_MESSAGE_INFO_PARAM_SET \
19 { \
20 "PARAM_SET", \
21 5, \
22 { \
23 { "param_value", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_param_set_t, param_value) }, \
24 { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_param_set_t, target_system) }, \
25 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_param_set_t, target_component) }, \
26 { "param_id", NULL, MAVLINK_TYPE_CHAR, 16, 6, offsetof(mavlink_param_set_t, param_id) }, \
27 { "param_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 22, offsetof(mavlink_param_set_t, param_type) }, \
28 } \
32 /**
33 * @brief Pack a param_set 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 target_system System ID
39 * @param target_component Component ID
40 * @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
41 * @param param_value Onboard parameter value
42 * @param param_type Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types.
43 * @return length of the message in bytes (excluding serial stream start sign)
45 static inline uint16_t mavlink_msg_param_set_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg,
46 uint8_t target_system, uint8_t target_component, const char *param_id, float param_value, uint8_t param_type)
48 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
49 char buf[23];
50 _mav_put_float(buf, 0, param_value);
51 _mav_put_uint8_t(buf, 4, target_system);
52 _mav_put_uint8_t(buf, 5, target_component);
53 _mav_put_uint8_t(buf, 22, param_type);
54 _mav_put_char_array(buf, 6, param_id, 16);
55 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 23);
56 #else
57 mavlink_param_set_t packet;
58 packet.param_value = param_value;
59 packet.target_system = target_system;
60 packet.target_component = target_component;
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, 23);
64 #endif
66 msg->msgid = MAVLINK_MSG_ID_PARAM_SET;
67 return mavlink_finalize_message(msg, system_id, component_id, 23, 168);
70 /**
71 * @brief Pack a param_set 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 target_system System ID
77 * @param target_component Component ID
78 * @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
79 * @param param_value Onboard parameter value
80 * @param param_type Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types.
81 * @return length of the message in bytes (excluding serial stream start sign)
83 static inline uint16_t mavlink_msg_param_set_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
84 mavlink_message_t *msg,
85 uint8_t target_system, uint8_t target_component, const char *param_id, float param_value, uint8_t param_type)
87 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
88 char buf[23];
89 _mav_put_float(buf, 0, param_value);
90 _mav_put_uint8_t(buf, 4, target_system);
91 _mav_put_uint8_t(buf, 5, target_component);
92 _mav_put_uint8_t(buf, 22, param_type);
93 _mav_put_char_array(buf, 6, param_id, 16);
94 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 23);
95 #else
96 mavlink_param_set_t packet;
97 packet.param_value = param_value;
98 packet.target_system = target_system;
99 packet.target_component = target_component;
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, 23);
103 #endif
105 msg->msgid = MAVLINK_MSG_ID_PARAM_SET;
106 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 23, 168);
110 * @brief Encode a param_set 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_set C-struct to read the message contents from
117 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)
119 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, param_set->param_type);
123 * @brief Send a param_set message
124 * @param chan MAVLink channel to send the message
126 * @param target_system System ID
127 * @param target_component Component ID
128 * @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
129 * @param param_value Onboard parameter value
130 * @param param_type Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types.
132 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
134 static inline void mavlink_msg_param_set_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, const char *param_id, float param_value, uint8_t param_type)
136 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
137 char buf[23];
138 _mav_put_float(buf, 0, param_value);
139 _mav_put_uint8_t(buf, 4, target_system);
140 _mav_put_uint8_t(buf, 5, target_component);
141 _mav_put_uint8_t(buf, 22, param_type);
142 _mav_put_char_array(buf, 6, param_id, 16);
143 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_SET, buf, 23, 168);
144 #else
145 mavlink_param_set_t packet;
146 packet.param_value = param_value;
147 packet.target_system = target_system;
148 packet.target_component = target_component;
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_SET, (const char *)&packet, 23, 168);
152 #endif
155 #endif // ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
157 // MESSAGE PARAM_SET UNPACKING
161 * @brief Get field target_system from param_set message
163 * @return System ID
165 static inline uint8_t mavlink_msg_param_set_get_target_system(const mavlink_message_t *msg)
167 return _MAV_RETURN_uint8_t(msg, 4);
171 * @brief Get field target_component from param_set message
173 * @return Component ID
175 static inline uint8_t mavlink_msg_param_set_get_target_component(const mavlink_message_t *msg)
177 return _MAV_RETURN_uint8_t(msg, 5);
181 * @brief Get field param_id from param_set message
183 * @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
185 static inline uint16_t mavlink_msg_param_set_get_param_id(const mavlink_message_t *msg, char *param_id)
187 return _MAV_RETURN_char_array(msg, param_id, 16, 6);
191 * @brief Get field param_value from param_set message
193 * @return Onboard parameter value
195 static inline float mavlink_msg_param_set_get_param_value(const mavlink_message_t *msg)
197 return _MAV_RETURN_float(msg, 0);
201 * @brief Get field param_type from param_set message
203 * @return Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types.
205 static inline uint8_t mavlink_msg_param_set_get_param_type(const mavlink_message_t *msg)
207 return _MAV_RETURN_uint8_t(msg, 22);
211 * @brief Decode a param_set message into a struct
213 * @param msg The message to decode
214 * @param param_set C-struct to decode the message contents into
216 static inline void mavlink_msg_param_set_decode(const mavlink_message_t *msg, mavlink_param_set_t *param_set)
218 #if MAVLINK_NEED_BYTE_SWAP
219 param_set->param_value = mavlink_msg_param_set_get_param_value(msg);
220 param_set->target_system = mavlink_msg_param_set_get_target_system(msg);
221 param_set->target_component = mavlink_msg_param_set_get_target_component(msg);
222 mavlink_msg_param_set_get_param_id(msg, param_set->param_id);
223 param_set->param_type = mavlink_msg_param_set_get_param_type(msg);
224 #else
225 memcpy(param_set, _MAV_PAYLOAD(msg), 23);
226 #endif