Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_param_error.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE PARAM_ERROR PACKING
3
4#define MAVLINK_MSG_ID_PARAM_ERROR 345
5
6
7typedef struct __mavlink_param_error_t {
8 int16_t param_index; /*< Parameter index. Will be -1 if the param ID field should be used as an identifier (else the param id will be ignored)*/
9 uint8_t target_system; /*< System ID*/
10 uint8_t target_component; /*< Component ID*/
11 char param_id[16]; /*< 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*/
12 uint8_t error; /*< Error being returned to client.*/
13} mavlink_param_error_t;
14
15#define MAVLINK_MSG_ID_PARAM_ERROR_LEN 21
16#define MAVLINK_MSG_ID_PARAM_ERROR_MIN_LEN 21
17#define MAVLINK_MSG_ID_345_LEN 21
18#define MAVLINK_MSG_ID_345_MIN_LEN 21
19
20#define MAVLINK_MSG_ID_PARAM_ERROR_CRC 209
21#define MAVLINK_MSG_ID_345_CRC 209
22
23#define MAVLINK_MSG_PARAM_ERROR_FIELD_PARAM_ID_LEN 16
24
25#if MAVLINK_COMMAND_24BIT
26#define MAVLINK_MESSAGE_INFO_PARAM_ERROR {
27 345,
28 "PARAM_ERROR",
29 5,
30 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_param_error_t, target_system) },
31 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_param_error_t, target_component) },
32 { "param_id", NULL, MAVLINK_TYPE_CHAR, 16, 4, offsetof(mavlink_param_error_t, param_id) },
33 { "param_index", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_param_error_t, param_index) },
34 { "error", NULL, MAVLINK_TYPE_UINT8_T, 0, 20, offsetof(mavlink_param_error_t, error) },
35 } \
36}
37#else
38#define MAVLINK_MESSAGE_INFO_PARAM_ERROR {
39 "PARAM_ERROR",
40 5,
41 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_param_error_t, target_system) },
42 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_param_error_t, target_component) },
43 { "param_id", NULL, MAVLINK_TYPE_CHAR, 16, 4, offsetof(mavlink_param_error_t, param_id) },
44 { "param_index", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_param_error_t, param_index) },
45 { "error", NULL, MAVLINK_TYPE_UINT8_T, 0, 20, offsetof(mavlink_param_error_t, error) },
46 } \
47}
48#endif
49
50/**
51 * @brief Pack a param_error message
52 * @param system_id ID of this system
53 * @param component_id ID of this component (e.g. 200 for IMU)
54 * @param msg The MAVLink message to compress the data into
55 *
56 * @param target_system System ID
57 * @param target_component Component ID
58 * @param param_id 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
59 * @param param_index Parameter index. Will be -1 if the param ID field should be used as an identifier (else the param id will be ignored)
60 * @param error Error being returned to client.
61 * @return length of the message in bytes (excluding serial stream start sign)
62 */
63MAVLINK_WIP
64static inline uint16_t mavlink_msg_param_error_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
65 uint8_t target_system, uint8_t target_component, const char *param_id, int16_t param_index, uint8_t error)
66{
67#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
69 _mav_put_int16_t(buf, 0, param_index);
70 _mav_put_uint8_t(buf, 2, target_system);
71 _mav_put_uint8_t(buf, 3, target_component);
72 _mav_put_uint8_t(buf, 20, error);
73 _mav_put_char_array(buf, 4, param_id, 16);
74 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_ERROR_LEN);
75#else
76 mavlink_param_error_t packet;
77 packet.param_index = param_index;
78 packet.target_system = target_system;
79 packet.target_component = target_component;
80 packet.error = error;
81 mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16);
82 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_ERROR_LEN);
83#endif
84
85 msg->msgid = MAVLINK_MSG_ID_PARAM_ERROR;
86 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_ERROR_MIN_LEN, MAVLINK_MSG_ID_PARAM_ERROR_LEN, MAVLINK_MSG_ID_PARAM_ERROR_CRC);
87}
88
89/**
90 * @brief Pack a param_error message
91 * @param system_id ID of this system
92 * @param component_id ID of this component (e.g. 200 for IMU)
93 * @param status MAVLink status structure
94 * @param msg The MAVLink message to compress the data into
95 *
96 * @param target_system System ID
97 * @param target_component Component ID
98 * @param param_id 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
99 * @param param_index Parameter index. Will be -1 if the param ID field should be used as an identifier (else the param id will be ignored)
100 * @param error Error being returned to client.
101 * @return length of the message in bytes (excluding serial stream start sign)
102 */
103static inline uint16_t mavlink_msg_param_error_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
104 uint8_t target_system, uint8_t target_component, const char *param_id, int16_t param_index, uint8_t error)
105{
106#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
108 _mav_put_int16_t(buf, 0, param_index);
109 _mav_put_uint8_t(buf, 2, target_system);
110 _mav_put_uint8_t(buf, 3, target_component);
111 _mav_put_uint8_t(buf, 20, error);
112 _mav_put_char_array(buf, 4, param_id, 16);
113 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_ERROR_LEN);
114#else
115 mavlink_param_error_t packet;
116 packet.param_index = param_index;
117 packet.target_system = target_system;
118 packet.target_component = target_component;
119 packet.error = error;
120 mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16);
121 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_ERROR_LEN);
122#endif
123
124 msg->msgid = MAVLINK_MSG_ID_PARAM_ERROR;
125#if MAVLINK_CRC_EXTRA
126 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_ERROR_MIN_LEN, MAVLINK_MSG_ID_PARAM_ERROR_LEN, MAVLINK_MSG_ID_PARAM_ERROR_CRC);
127#else
128 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_ERROR_MIN_LEN, MAVLINK_MSG_ID_PARAM_ERROR_LEN);
129#endif
130}
131
132/**
133 * @brief Pack a param_error message on a channel
134 * @param system_id ID of this system
135 * @param component_id ID of this component (e.g. 200 for IMU)
136 * @param chan The MAVLink channel this message will be sent over
137 * @param msg The MAVLink message to compress the data into
138 * @param target_system System ID
139 * @param target_component Component ID
140 * @param param_id 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
141 * @param param_index Parameter index. Will be -1 if the param ID field should be used as an identifier (else the param id will be ignored)
142 * @param error Error being returned to client.
143 * @return length of the message in bytes (excluding serial stream start sign)
144 */
145MAVLINK_WIP
146static inline uint16_t mavlink_msg_param_error_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
147 mavlink_message_t* msg,
148 uint8_t target_system,uint8_t target_component,const char *param_id,int16_t param_index,uint8_t error)
149{
150#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
152 _mav_put_int16_t(buf, 0, param_index);
153 _mav_put_uint8_t(buf, 2, target_system);
154 _mav_put_uint8_t(buf, 3, target_component);
155 _mav_put_uint8_t(buf, 20, error);
156 _mav_put_char_array(buf, 4, param_id, 16);
157 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_ERROR_LEN);
158#else
159 mavlink_param_error_t packet;
160 packet.param_index = param_index;
161 packet.target_system = target_system;
162 packet.target_component = target_component;
163 packet.error = error;
164 mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16);
165 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_ERROR_LEN);
166#endif
167
168 msg->msgid = MAVLINK_MSG_ID_PARAM_ERROR;
169 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_PARAM_ERROR_MIN_LEN, MAVLINK_MSG_ID_PARAM_ERROR_LEN, MAVLINK_MSG_ID_PARAM_ERROR_CRC);
170}
171
172/**
173 * @brief Encode a param_error struct
174 *
175 * @param system_id ID of this system
176 * @param component_id ID of this component (e.g. 200 for IMU)
177 * @param msg The MAVLink message to compress the data into
178 * @param param_error C-struct to read the message contents from
179 */
180MAVLINK_WIP
181static inline uint16_t mavlink_msg_param_error_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_param_error_t* param_error)
182{
183 return mavlink_msg_param_error_pack(system_id, component_id, msg, param_error->target_system, param_error->target_component, param_error->param_id, param_error->param_index, param_error->error);
184}
185
186/**
187 * @brief Encode a param_error struct on a channel
188 *
189 * @param system_id ID of this system
190 * @param component_id ID of this component (e.g. 200 for IMU)
191 * @param chan The MAVLink channel this message will be sent over
192 * @param msg The MAVLink message to compress the data into
193 * @param param_error C-struct to read the message contents from
194 */
195MAVLINK_WIP
196static inline uint16_t mavlink_msg_param_error_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_param_error_t* param_error)
197{
198 return mavlink_msg_param_error_pack_chan(system_id, component_id, chan, msg, param_error->target_system, param_error->target_component, param_error->param_id, param_error->param_index, param_error->error);
199}
200
201/**
202 * @brief Encode a param_error struct with provided status structure
203 *
204 * @param system_id ID of this system
205 * @param component_id ID of this component (e.g. 200 for IMU)
206 * @param status MAVLink status structure
207 * @param msg The MAVLink message to compress the data into
208 * @param param_error C-struct to read the message contents from
209 */
210static inline uint16_t mavlink_msg_param_error_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_error_t* param_error)
211{
212 return mavlink_msg_param_error_pack_status(system_id, component_id, _status, msg, param_error->target_system, param_error->target_component, param_error->param_id, param_error->param_index, param_error->error);
213}
214
215/**
216 * @brief Send a param_error message
217 * @param chan MAVLink channel to send the message
218 *
219 * @param target_system System ID
220 * @param target_component Component ID
221 * @param param_id 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
222 * @param param_index Parameter index. Will be -1 if the param ID field should be used as an identifier (else the param id will be ignored)
223 * @param error Error being returned to client.
224 */
225#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
226
227MAVLINK_WIP
228static inline void mavlink_msg_param_error_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, const char *param_id, int16_t param_index, uint8_t error)
229{
230#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
231 char buf[MAVLINK_MSG_ID_PARAM_ERROR_LEN];
232 _mav_put_int16_t(buf, 0, param_index);
233 _mav_put_uint8_t(buf, 2, target_system);
234 _mav_put_uint8_t(buf, 3, target_component);
235 _mav_put_uint8_t(buf, 20, error);
236 _mav_put_char_array(buf, 4, param_id, 16);
237 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_ERROR, buf, MAVLINK_MSG_ID_PARAM_ERROR_MIN_LEN, MAVLINK_MSG_ID_PARAM_ERROR_LEN, MAVLINK_MSG_ID_PARAM_ERROR_CRC);
238#else
239 mavlink_param_error_t packet;
240 packet.param_index = param_index;
241 packet.target_system = target_system;
242 packet.target_component = target_component;
243 packet.error = error;
244 mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16);
245 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_ERROR, (const char *)&packet, MAVLINK_MSG_ID_PARAM_ERROR_MIN_LEN, MAVLINK_MSG_ID_PARAM_ERROR_LEN, MAVLINK_MSG_ID_PARAM_ERROR_CRC);
246#endif
247}
248
249/**
250 * @brief Send a param_error message
251 * @param chan MAVLink channel to send the message
252 * @param struct The MAVLink struct to serialize
253 */
254MAVLINK_WIP
255static inline void mavlink_msg_param_error_send_struct(mavlink_channel_t chan, const mavlink_param_error_t* param_error)
256{
257#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
258 mavlink_msg_param_error_send(chan, param_error->target_system, param_error->target_component, param_error->param_id, param_error->param_index, param_error->error);
259#else
260 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_ERROR, (const char *)param_error, MAVLINK_MSG_ID_PARAM_ERROR_MIN_LEN, MAVLINK_MSG_ID_PARAM_ERROR_LEN, MAVLINK_MSG_ID_PARAM_ERROR_CRC);
261#endif
262}
263
264#if MAVLINK_MSG_ID_PARAM_ERROR_LEN <= MAVLINK_MAX_PAYLOAD_LEN
265/*
266 This variant of _send() can be used to save stack space by reusing
267 memory from the receive buffer. The caller provides a
268 mavlink_message_t which is the size of a full mavlink message. This
269 is usually the receive buffer for the channel, and allows a reply to an
270 incoming message with minimum stack space usage.
271 */
272MAVLINK_WIP
273static inline void mavlink_msg_param_error_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, const char *param_id, int16_t param_index, uint8_t error)
274{
275#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
276 char *buf = (char *)msgbuf;
277 _mav_put_int16_t(buf, 0, param_index);
278 _mav_put_uint8_t(buf, 2, target_system);
279 _mav_put_uint8_t(buf, 3, target_component);
280 _mav_put_uint8_t(buf, 20, error);
281 _mav_put_char_array(buf, 4, param_id, 16);
282 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_ERROR, buf, MAVLINK_MSG_ID_PARAM_ERROR_MIN_LEN, MAVLINK_MSG_ID_PARAM_ERROR_LEN, MAVLINK_MSG_ID_PARAM_ERROR_CRC);
283#else
284 mavlink_param_error_t *packet = (mavlink_param_error_t *)msgbuf;
285 packet->param_index = param_index;
286 packet->target_system = target_system;
287 packet->target_component = target_component;
288 packet->error = error;
289 mav_array_memcpy(packet->param_id, param_id, sizeof(char)*16);
290 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_ERROR, (const char *)packet, MAVLINK_MSG_ID_PARAM_ERROR_MIN_LEN, MAVLINK_MSG_ID_PARAM_ERROR_LEN, MAVLINK_MSG_ID_PARAM_ERROR_CRC);
291#endif
292}
293#endif
294
295#endif
296
297// MESSAGE PARAM_ERROR UNPACKING
298
299
300/**
301 * @brief Get field target_system from param_error message
302 *
303 * @return System ID
304 */
305MAVLINK_WIP
306static inline uint8_t mavlink_msg_param_error_get_target_system(const mavlink_message_t* msg)
307{
308 return _MAV_RETURN_uint8_t(msg, 2);
309}
310
311/**
312 * @brief Get field target_component from param_error message
313 *
314 * @return Component ID
315 */
316MAVLINK_WIP
317static inline uint8_t mavlink_msg_param_error_get_target_component(const mavlink_message_t* msg)
318{
319 return _MAV_RETURN_uint8_t(msg, 3);
320}
321
322/**
323 * @brief Get field param_id from param_error message
324 *
325 * @return 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
326 */
327MAVLINK_WIP
328static inline uint16_t mavlink_msg_param_error_get_param_id(const mavlink_message_t* msg, char *param_id)
329{
330 return _MAV_RETURN_char_array(msg, param_id, 16, 4);
331}
332
333/**
334 * @brief Get field param_index from param_error message
335 *
336 * @return Parameter index. Will be -1 if the param ID field should be used as an identifier (else the param id will be ignored)
337 */
338MAVLINK_WIP
339static inline int16_t mavlink_msg_param_error_get_param_index(const mavlink_message_t* msg)
340{
341 return _MAV_RETURN_int16_t(msg, 0);
342}
343
344/**
345 * @brief Get field error from param_error message
346 *
347 * @return Error being returned to client.
348 */
349MAVLINK_WIP
350static inline uint8_t mavlink_msg_param_error_get_error(const mavlink_message_t* msg)
351{
352 return _MAV_RETURN_uint8_t(msg, 20);
353}
354
355/**
356 * @brief Decode a param_error message into a struct
357 *
358 * @param msg The message to decode
359 * @param param_error C-struct to decode the message contents into
360 */
361MAVLINK_WIP
362static inline void mavlink_msg_param_error_decode(const mavlink_message_t* msg, mavlink_param_error_t* param_error)
363{
364#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
365 param_error->param_index = mavlink_msg_param_error_get_param_index(msg);
366 param_error->target_system = mavlink_msg_param_error_get_target_system(msg);
367 param_error->target_component = mavlink_msg_param_error_get_target_component(msg);
368 mavlink_msg_param_error_get_param_id(msg, param_error->param_id);
369 param_error->error = mavlink_msg_param_error_get_error(msg);
370#else
371 uint8_t len = msg->len < MAVLINK_MSG_ID_PARAM_ERROR_LEN? msg->len : MAVLINK_MSG_ID_PARAM_ERROR_LEN;
372 memset(param_error, 0, MAVLINK_MSG_ID_PARAM_ERROR_LEN);
373 memcpy(param_error, _MAV_PAYLOAD(msg), len);
374#endif
375}