1 | // MESSAGE NAMED_VALUE_FLOAT PACKING |
---|
2 | |
---|
3 | #define MAVLINK_MSG_ID_NAMED_VALUE_FLOAT 251 |
---|
4 | |
---|
5 | MAVPACKED( |
---|
6 | typedef struct __mavlink_named_value_float_t { |
---|
7 | uint32_t time_boot_ms; /*< Timestamp (milliseconds since system boot)*/ |
---|
8 | float value; /*< Floating point value*/ |
---|
9 | char name[10]; /*< Name of the debug variable*/ |
---|
10 | }) mavlink_named_value_float_t; |
---|
11 | |
---|
12 | #define MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN 18 |
---|
13 | #define MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_MIN_LEN 18 |
---|
14 | #define MAVLINK_MSG_ID_251_LEN 18 |
---|
15 | #define MAVLINK_MSG_ID_251_MIN_LEN 18 |
---|
16 | |
---|
17 | #define MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_CRC 170 |
---|
18 | #define MAVLINK_MSG_ID_251_CRC 170 |
---|
19 | |
---|
20 | #define MAVLINK_MSG_NAMED_VALUE_FLOAT_FIELD_NAME_LEN 10 |
---|
21 | |
---|
22 | #if MAVLINK_COMMAND_24BIT |
---|
23 | #define MAVLINK_MESSAGE_INFO_NAMED_VALUE_FLOAT { \ |
---|
24 | 251, \ |
---|
25 | "NAMED_VALUE_FLOAT", \ |
---|
26 | 3, \ |
---|
27 | { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_named_value_float_t, time_boot_ms) }, \ |
---|
28 | { "value", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_named_value_float_t, value) }, \ |
---|
29 | { "name", NULL, MAVLINK_TYPE_CHAR, 10, 8, offsetof(mavlink_named_value_float_t, name) }, \ |
---|
30 | } \ |
---|
31 | } |
---|
32 | #else |
---|
33 | #define MAVLINK_MESSAGE_INFO_NAMED_VALUE_FLOAT { \ |
---|
34 | "NAMED_VALUE_FLOAT", \ |
---|
35 | 3, \ |
---|
36 | { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_named_value_float_t, time_boot_ms) }, \ |
---|
37 | { "value", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_named_value_float_t, value) }, \ |
---|
38 | { "name", NULL, MAVLINK_TYPE_CHAR, 10, 8, offsetof(mavlink_named_value_float_t, name) }, \ |
---|
39 | } \ |
---|
40 | } |
---|
41 | #endif |
---|
42 | |
---|
43 | /** |
---|
44 | * @brief Pack a named_value_float message |
---|
45 | * @param system_id ID of this system |
---|
46 | * @param component_id ID of this component (e.g. 200 for IMU) |
---|
47 | * @param msg The MAVLink message to compress the data into |
---|
48 | * |
---|
49 | * @param time_boot_ms Timestamp (milliseconds since system boot) |
---|
50 | * @param name Name of the debug variable |
---|
51 | * @param value Floating point value |
---|
52 | * @return length of the message in bytes (excluding serial stream start sign) |
---|
53 | */ |
---|
54 | static inline uint16_t mavlink_msg_named_value_float_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, |
---|
55 | uint32_t time_boot_ms, const char *name, float value) |
---|
56 | { |
---|
57 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
---|
58 | char buf[MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN]; |
---|
59 | _mav_put_uint32_t(buf, 0, time_boot_ms); |
---|
60 | _mav_put_float(buf, 4, value); |
---|
61 | _mav_put_char_array(buf, 8, name, 10); |
---|
62 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN); |
---|
63 | #else |
---|
64 | mavlink_named_value_float_t packet; |
---|
65 | packet.time_boot_ms = time_boot_ms; |
---|
66 | packet.value = value; |
---|
67 | mav_array_memcpy(packet.name, name, sizeof(char)*10); |
---|
68 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN); |
---|
69 | #endif |
---|
70 | |
---|
71 | msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_FLOAT; |
---|
72 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_CRC); |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * @brief Pack a named_value_float message on a channel |
---|
77 | * @param system_id ID of this system |
---|
78 | * @param component_id ID of this component (e.g. 200 for IMU) |
---|
79 | * @param chan The MAVLink channel this message will be sent over |
---|
80 | * @param msg The MAVLink message to compress the data into |
---|
81 | * @param time_boot_ms Timestamp (milliseconds since system boot) |
---|
82 | * @param name Name of the debug variable |
---|
83 | * @param value Floating point value |
---|
84 | * @return length of the message in bytes (excluding serial stream start sign) |
---|
85 | */ |
---|
86 | static inline uint16_t mavlink_msg_named_value_float_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, |
---|
87 | mavlink_message_t* msg, |
---|
88 | uint32_t time_boot_ms,const char *name,float value) |
---|
89 | { |
---|
90 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
---|
91 | char buf[MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN]; |
---|
92 | _mav_put_uint32_t(buf, 0, time_boot_ms); |
---|
93 | _mav_put_float(buf, 4, value); |
---|
94 | _mav_put_char_array(buf, 8, name, 10); |
---|
95 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN); |
---|
96 | #else |
---|
97 | mavlink_named_value_float_t packet; |
---|
98 | packet.time_boot_ms = time_boot_ms; |
---|
99 | packet.value = value; |
---|
100 | mav_array_memcpy(packet.name, name, sizeof(char)*10); |
---|
101 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN); |
---|
102 | #endif |
---|
103 | |
---|
104 | msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_FLOAT; |
---|
105 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_CRC); |
---|
106 | } |
---|
107 | |
---|
108 | /** |
---|
109 | * @brief Encode a named_value_float struct |
---|
110 | * |
---|
111 | * @param system_id ID of this system |
---|
112 | * @param component_id ID of this component (e.g. 200 for IMU) |
---|
113 | * @param msg The MAVLink message to compress the data into |
---|
114 | * @param named_value_float C-struct to read the message contents from |
---|
115 | */ |
---|
116 | 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) |
---|
117 | { |
---|
118 | return mavlink_msg_named_value_float_pack(system_id, component_id, msg, named_value_float->time_boot_ms, named_value_float->name, named_value_float->value); |
---|
119 | } |
---|
120 | |
---|
121 | /** |
---|
122 | * @brief Encode a named_value_float struct on a channel |
---|
123 | * |
---|
124 | * @param system_id ID of this system |
---|
125 | * @param component_id ID of this component (e.g. 200 for IMU) |
---|
126 | * @param chan The MAVLink channel this message will be sent over |
---|
127 | * @param msg The MAVLink message to compress the data into |
---|
128 | * @param named_value_float C-struct to read the message contents from |
---|
129 | */ |
---|
130 | static inline uint16_t mavlink_msg_named_value_float_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_named_value_float_t* named_value_float) |
---|
131 | { |
---|
132 | return mavlink_msg_named_value_float_pack_chan(system_id, component_id, chan, msg, named_value_float->time_boot_ms, named_value_float->name, named_value_float->value); |
---|
133 | } |
---|
134 | |
---|
135 | /** |
---|
136 | * @brief Send a named_value_float message |
---|
137 | * @param chan MAVLink channel to send the message |
---|
138 | * |
---|
139 | * @param time_boot_ms Timestamp (milliseconds since system boot) |
---|
140 | * @param name Name of the debug variable |
---|
141 | * @param value Floating point value |
---|
142 | */ |
---|
143 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
---|
144 | |
---|
145 | static inline void mavlink_msg_named_value_float_send(mavlink_channel_t chan, uint32_t time_boot_ms, const char *name, float value) |
---|
146 | { |
---|
147 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
---|
148 | char buf[MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN]; |
---|
149 | _mav_put_uint32_t(buf, 0, time_boot_ms); |
---|
150 | _mav_put_float(buf, 4, value); |
---|
151 | _mav_put_char_array(buf, 8, name, 10); |
---|
152 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT, buf, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_CRC); |
---|
153 | #else |
---|
154 | mavlink_named_value_float_t packet; |
---|
155 | packet.time_boot_ms = time_boot_ms; |
---|
156 | packet.value = value; |
---|
157 | mav_array_memcpy(packet.name, name, sizeof(char)*10); |
---|
158 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT, (const char *)&packet, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_CRC); |
---|
159 | #endif |
---|
160 | } |
---|
161 | |
---|
162 | /** |
---|
163 | * @brief Send a named_value_float message |
---|
164 | * @param chan MAVLink channel to send the message |
---|
165 | * @param struct The MAVLink struct to serialize |
---|
166 | */ |
---|
167 | static inline void mavlink_msg_named_value_float_send_struct(mavlink_channel_t chan, const mavlink_named_value_float_t* named_value_float) |
---|
168 | { |
---|
169 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
---|
170 | mavlink_msg_named_value_float_send(chan, named_value_float->time_boot_ms, named_value_float->name, named_value_float->value); |
---|
171 | #else |
---|
172 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT, (const char *)named_value_float, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_CRC); |
---|
173 | #endif |
---|
174 | } |
---|
175 | |
---|
176 | #if MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN <= MAVLINK_MAX_PAYLOAD_LEN |
---|
177 | /* |
---|
178 | This varient of _send() can be used to save stack space by re-using |
---|
179 | memory from the receive buffer. The caller provides a |
---|
180 | mavlink_message_t which is the size of a full mavlink message. This |
---|
181 | is usually the receive buffer for the channel, and allows a reply to an |
---|
182 | incoming message with minimum stack space usage. |
---|
183 | */ |
---|
184 | static inline void mavlink_msg_named_value_float_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, const char *name, float value) |
---|
185 | { |
---|
186 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
---|
187 | char *buf = (char *)msgbuf; |
---|
188 | _mav_put_uint32_t(buf, 0, time_boot_ms); |
---|
189 | _mav_put_float(buf, 4, value); |
---|
190 | _mav_put_char_array(buf, 8, name, 10); |
---|
191 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT, buf, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_CRC); |
---|
192 | #else |
---|
193 | mavlink_named_value_float_t *packet = (mavlink_named_value_float_t *)msgbuf; |
---|
194 | packet->time_boot_ms = time_boot_ms; |
---|
195 | packet->value = value; |
---|
196 | mav_array_memcpy(packet->name, name, sizeof(char)*10); |
---|
197 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT, (const char *)packet, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_CRC); |
---|
198 | #endif |
---|
199 | } |
---|
200 | #endif |
---|
201 | |
---|
202 | #endif |
---|
203 | |
---|
204 | // MESSAGE NAMED_VALUE_FLOAT UNPACKING |
---|
205 | |
---|
206 | |
---|
207 | /** |
---|
208 | * @brief Get field time_boot_ms from named_value_float message |
---|
209 | * |
---|
210 | * @return Timestamp (milliseconds since system boot) |
---|
211 | */ |
---|
212 | static inline uint32_t mavlink_msg_named_value_float_get_time_boot_ms(const mavlink_message_t* msg) |
---|
213 | { |
---|
214 | return _MAV_RETURN_uint32_t(msg, 0); |
---|
215 | } |
---|
216 | |
---|
217 | /** |
---|
218 | * @brief Get field name from named_value_float message |
---|
219 | * |
---|
220 | * @return Name of the debug variable |
---|
221 | */ |
---|
222 | static inline uint16_t mavlink_msg_named_value_float_get_name(const mavlink_message_t* msg, char *name) |
---|
223 | { |
---|
224 | return _MAV_RETURN_char_array(msg, name, 10, 8); |
---|
225 | } |
---|
226 | |
---|
227 | /** |
---|
228 | * @brief Get field value from named_value_float message |
---|
229 | * |
---|
230 | * @return Floating point value |
---|
231 | */ |
---|
232 | static inline float mavlink_msg_named_value_float_get_value(const mavlink_message_t* msg) |
---|
233 | { |
---|
234 | return _MAV_RETURN_float(msg, 4); |
---|
235 | } |
---|
236 | |
---|
237 | /** |
---|
238 | * @brief Decode a named_value_float message into a struct |
---|
239 | * |
---|
240 | * @param msg The message to decode |
---|
241 | * @param named_value_float C-struct to decode the message contents into |
---|
242 | */ |
---|
243 | static inline void mavlink_msg_named_value_float_decode(const mavlink_message_t* msg, mavlink_named_value_float_t* named_value_float) |
---|
244 | { |
---|
245 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
---|
246 | named_value_float->time_boot_ms = mavlink_msg_named_value_float_get_time_boot_ms(msg); |
---|
247 | named_value_float->value = mavlink_msg_named_value_float_get_value(msg); |
---|
248 | mavlink_msg_named_value_float_get_name(msg, named_value_float->name); |
---|
249 | #else |
---|
250 | uint8_t len = msg->len < MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN? msg->len : MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN; |
---|
251 | memset(named_value_float, 0, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN); |
---|
252 | memcpy(named_value_float, _MAV_PAYLOAD(msg), len); |
---|
253 | #endif |
---|
254 | } |
---|