Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_mag_cal_report.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE MAG_CAL_REPORT PACKING
3
4#define MAVLINK_MSG_ID_MAG_CAL_REPORT 192
5
6MAVPACKED(
7typedef struct __mavlink_mag_cal_report_t {
8 float fitness; /*< [mgauss] RMS milligauss residuals.*/
9 float ofs_x; /*< X offset.*/
10 float ofs_y; /*< Y offset.*/
11 float ofs_z; /*< Z offset.*/
12 float diag_x; /*< X diagonal (matrix 11).*/
13 float diag_y; /*< Y diagonal (matrix 22).*/
14 float diag_z; /*< Z diagonal (matrix 33).*/
15 float offdiag_x; /*< X off-diagonal (matrix 12 and 21).*/
16 float offdiag_y; /*< Y off-diagonal (matrix 13 and 31).*/
17 float offdiag_z; /*< Z off-diagonal (matrix 32 and 23).*/
18 uint8_t compass_id; /*< Compass being calibrated.*/
19 uint8_t cal_mask; /*< Bitmask of compasses being calibrated.*/
20 uint8_t cal_status; /*< Calibration Status.*/
21 uint8_t autosaved; /*< 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.*/
22 float orientation_confidence; /*< Confidence in orientation (higher is better).*/
23 uint8_t old_orientation; /*< orientation before calibration.*/
24 uint8_t new_orientation; /*< orientation after calibration.*/
25 float scale_factor; /*< field radius correction factor*/
26}) mavlink_mag_cal_report_t;
27
28#define MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN 54
29#define MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN 44
30#define MAVLINK_MSG_ID_192_LEN 54
31#define MAVLINK_MSG_ID_192_MIN_LEN 44
32
33#define MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC 36
34#define MAVLINK_MSG_ID_192_CRC 36
35
36
37
38#if MAVLINK_COMMAND_24BIT
39#define MAVLINK_MESSAGE_INFO_MAG_CAL_REPORT {
40 192,
41 "MAG_CAL_REPORT",
42 18,
43 { { "compass_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 40, offsetof(mavlink_mag_cal_report_t, compass_id) },
44 { "cal_mask", NULL, MAVLINK_TYPE_UINT8_T, 0, 41, offsetof(mavlink_mag_cal_report_t, cal_mask) },
45 { "cal_status", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_mag_cal_report_t, cal_status) },
46 { "autosaved", NULL, MAVLINK_TYPE_UINT8_T, 0, 43, offsetof(mavlink_mag_cal_report_t, autosaved) },
47 { "fitness", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_mag_cal_report_t, fitness) },
48 { "ofs_x", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_mag_cal_report_t, ofs_x) },
49 { "ofs_y", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_mag_cal_report_t, ofs_y) },
50 { "ofs_z", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_mag_cal_report_t, ofs_z) },
51 { "diag_x", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_mag_cal_report_t, diag_x) },
52 { "diag_y", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_mag_cal_report_t, diag_y) },
53 { "diag_z", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_mag_cal_report_t, diag_z) },
54 { "offdiag_x", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_mag_cal_report_t, offdiag_x) },
55 { "offdiag_y", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_mag_cal_report_t, offdiag_y) },
56 { "offdiag_z", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_mag_cal_report_t, offdiag_z) },
57 { "orientation_confidence", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_mag_cal_report_t, orientation_confidence) },
58 { "old_orientation", NULL, MAVLINK_TYPE_UINT8_T, 0, 48, offsetof(mavlink_mag_cal_report_t, old_orientation) },
59 { "new_orientation", NULL, MAVLINK_TYPE_UINT8_T, 0, 49, offsetof(mavlink_mag_cal_report_t, new_orientation) },
60 { "scale_factor", NULL, MAVLINK_TYPE_FLOAT, 0, 50, offsetof(mavlink_mag_cal_report_t, scale_factor) },
61 } \
62}
63#else
64#define MAVLINK_MESSAGE_INFO_MAG_CAL_REPORT {
65 "MAG_CAL_REPORT",
66 18,
67 { { "compass_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 40, offsetof(mavlink_mag_cal_report_t, compass_id) },
68 { "cal_mask", NULL, MAVLINK_TYPE_UINT8_T, 0, 41, offsetof(mavlink_mag_cal_report_t, cal_mask) },
69 { "cal_status", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_mag_cal_report_t, cal_status) },
70 { "autosaved", NULL, MAVLINK_TYPE_UINT8_T, 0, 43, offsetof(mavlink_mag_cal_report_t, autosaved) },
71 { "fitness", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_mag_cal_report_t, fitness) },
72 { "ofs_x", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_mag_cal_report_t, ofs_x) },
73 { "ofs_y", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_mag_cal_report_t, ofs_y) },
74 { "ofs_z", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_mag_cal_report_t, ofs_z) },
75 { "diag_x", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_mag_cal_report_t, diag_x) },
76 { "diag_y", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_mag_cal_report_t, diag_y) },
77 { "diag_z", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_mag_cal_report_t, diag_z) },
78 { "offdiag_x", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_mag_cal_report_t, offdiag_x) },
79 { "offdiag_y", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_mag_cal_report_t, offdiag_y) },
80 { "offdiag_z", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_mag_cal_report_t, offdiag_z) },
81 { "orientation_confidence", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_mag_cal_report_t, orientation_confidence) },
82 { "old_orientation", NULL, MAVLINK_TYPE_UINT8_T, 0, 48, offsetof(mavlink_mag_cal_report_t, old_orientation) },
83 { "new_orientation", NULL, MAVLINK_TYPE_UINT8_T, 0, 49, offsetof(mavlink_mag_cal_report_t, new_orientation) },
84 { "scale_factor", NULL, MAVLINK_TYPE_FLOAT, 0, 50, offsetof(mavlink_mag_cal_report_t, scale_factor) },
85 } \
86}
87#endif
88
89/**
90 * @brief Pack a mag_cal_report message
91 * @param system_id ID of this system
92 * @param component_id ID of this component (e.g. 200 for IMU)
93 * @param msg The MAVLink message to compress the data into
94 *
95 * @param compass_id Compass being calibrated.
96 * @param cal_mask Bitmask of compasses being calibrated.
97 * @param cal_status Calibration Status.
98 * @param autosaved 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.
99 * @param fitness [mgauss] RMS milligauss residuals.
100 * @param ofs_x X offset.
101 * @param ofs_y Y offset.
102 * @param ofs_z Z offset.
103 * @param diag_x X diagonal (matrix 11).
104 * @param diag_y Y diagonal (matrix 22).
105 * @param diag_z Z diagonal (matrix 33).
106 * @param offdiag_x X off-diagonal (matrix 12 and 21).
107 * @param offdiag_y Y off-diagonal (matrix 13 and 31).
108 * @param offdiag_z Z off-diagonal (matrix 32 and 23).
109 * @param orientation_confidence Confidence in orientation (higher is better).
110 * @param old_orientation orientation before calibration.
111 * @param new_orientation orientation after calibration.
112 * @param scale_factor field radius correction factor
113 * @return length of the message in bytes (excluding serial stream start sign)
114 */
115static inline uint16_t mavlink_msg_mag_cal_report_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
116 uint8_t compass_id, uint8_t cal_mask, uint8_t cal_status, uint8_t autosaved, float fitness, float ofs_x, float ofs_y, float ofs_z, float diag_x, float diag_y, float diag_z, float offdiag_x, float offdiag_y, float offdiag_z, float orientation_confidence, uint8_t old_orientation, uint8_t new_orientation, float scale_factor)
117{
118#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
120 _mav_put_float(buf, 0, fitness);
121 _mav_put_float(buf, 4, ofs_x);
122 _mav_put_float(buf, 8, ofs_y);
123 _mav_put_float(buf, 12, ofs_z);
124 _mav_put_float(buf, 16, diag_x);
125 _mav_put_float(buf, 20, diag_y);
126 _mav_put_float(buf, 24, diag_z);
127 _mav_put_float(buf, 28, offdiag_x);
128 _mav_put_float(buf, 32, offdiag_y);
129 _mav_put_float(buf, 36, offdiag_z);
130 _mav_put_uint8_t(buf, 40, compass_id);
131 _mav_put_uint8_t(buf, 41, cal_mask);
132 _mav_put_uint8_t(buf, 42, cal_status);
133 _mav_put_uint8_t(buf, 43, autosaved);
134 _mav_put_float(buf, 44, orientation_confidence);
135 _mav_put_uint8_t(buf, 48, old_orientation);
136 _mav_put_uint8_t(buf, 49, new_orientation);
137 _mav_put_float(buf, 50, scale_factor);
138
139 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
140#else
141 mavlink_mag_cal_report_t packet;
142 packet.fitness = fitness;
143 packet.ofs_x = ofs_x;
144 packet.ofs_y = ofs_y;
145 packet.ofs_z = ofs_z;
146 packet.diag_x = diag_x;
147 packet.diag_y = diag_y;
148 packet.diag_z = diag_z;
149 packet.offdiag_x = offdiag_x;
150 packet.offdiag_y = offdiag_y;
151 packet.offdiag_z = offdiag_z;
152 packet.compass_id = compass_id;
153 packet.cal_mask = cal_mask;
154 packet.cal_status = cal_status;
155 packet.autosaved = autosaved;
156 packet.orientation_confidence = orientation_confidence;
157 packet.old_orientation = old_orientation;
158 packet.new_orientation = new_orientation;
159 packet.scale_factor = scale_factor;
160
161 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
162#endif
163
165 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
166}
167
168/**
169 * @brief Pack a mag_cal_report message
170 * @param system_id ID of this system
171 * @param component_id ID of this component (e.g. 200 for IMU)
172 * @param status MAVLink status structure
173 * @param msg The MAVLink message to compress the data into
174 *
175 * @param compass_id Compass being calibrated.
176 * @param cal_mask Bitmask of compasses being calibrated.
177 * @param cal_status Calibration Status.
178 * @param autosaved 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.
179 * @param fitness [mgauss] RMS milligauss residuals.
180 * @param ofs_x X offset.
181 * @param ofs_y Y offset.
182 * @param ofs_z Z offset.
183 * @param diag_x X diagonal (matrix 11).
184 * @param diag_y Y diagonal (matrix 22).
185 * @param diag_z Z diagonal (matrix 33).
186 * @param offdiag_x X off-diagonal (matrix 12 and 21).
187 * @param offdiag_y Y off-diagonal (matrix 13 and 31).
188 * @param offdiag_z Z off-diagonal (matrix 32 and 23).
189 * @param orientation_confidence Confidence in orientation (higher is better).
190 * @param old_orientation orientation before calibration.
191 * @param new_orientation orientation after calibration.
192 * @param scale_factor field radius correction factor
193 * @return length of the message in bytes (excluding serial stream start sign)
194 */
195static inline uint16_t mavlink_msg_mag_cal_report_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
196 uint8_t compass_id, uint8_t cal_mask, uint8_t cal_status, uint8_t autosaved, float fitness, float ofs_x, float ofs_y, float ofs_z, float diag_x, float diag_y, float diag_z, float offdiag_x, float offdiag_y, float offdiag_z, float orientation_confidence, uint8_t old_orientation, uint8_t new_orientation, float scale_factor)
197{
198#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
200 _mav_put_float(buf, 0, fitness);
201 _mav_put_float(buf, 4, ofs_x);
202 _mav_put_float(buf, 8, ofs_y);
203 _mav_put_float(buf, 12, ofs_z);
204 _mav_put_float(buf, 16, diag_x);
205 _mav_put_float(buf, 20, diag_y);
206 _mav_put_float(buf, 24, diag_z);
207 _mav_put_float(buf, 28, offdiag_x);
208 _mav_put_float(buf, 32, offdiag_y);
209 _mav_put_float(buf, 36, offdiag_z);
210 _mav_put_uint8_t(buf, 40, compass_id);
211 _mav_put_uint8_t(buf, 41, cal_mask);
212 _mav_put_uint8_t(buf, 42, cal_status);
213 _mav_put_uint8_t(buf, 43, autosaved);
214 _mav_put_float(buf, 44, orientation_confidence);
215 _mav_put_uint8_t(buf, 48, old_orientation);
216 _mav_put_uint8_t(buf, 49, new_orientation);
217 _mav_put_float(buf, 50, scale_factor);
218
219 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
220#else
221 mavlink_mag_cal_report_t packet;
222 packet.fitness = fitness;
223 packet.ofs_x = ofs_x;
224 packet.ofs_y = ofs_y;
225 packet.ofs_z = ofs_z;
226 packet.diag_x = diag_x;
227 packet.diag_y = diag_y;
228 packet.diag_z = diag_z;
229 packet.offdiag_x = offdiag_x;
230 packet.offdiag_y = offdiag_y;
231 packet.offdiag_z = offdiag_z;
232 packet.compass_id = compass_id;
233 packet.cal_mask = cal_mask;
234 packet.cal_status = cal_status;
235 packet.autosaved = autosaved;
236 packet.orientation_confidence = orientation_confidence;
237 packet.old_orientation = old_orientation;
238 packet.new_orientation = new_orientation;
239 packet.scale_factor = scale_factor;
240
241 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
242#endif
243
245#if MAVLINK_CRC_EXTRA
246 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
247#else
248 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
249#endif
250}
251
252/**
253 * @brief Pack a mag_cal_report message on a channel
254 * @param system_id ID of this system
255 * @param component_id ID of this component (e.g. 200 for IMU)
256 * @param chan The MAVLink channel this message will be sent over
257 * @param msg The MAVLink message to compress the data into
258 * @param compass_id Compass being calibrated.
259 * @param cal_mask Bitmask of compasses being calibrated.
260 * @param cal_status Calibration Status.
261 * @param autosaved 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.
262 * @param fitness [mgauss] RMS milligauss residuals.
263 * @param ofs_x X offset.
264 * @param ofs_y Y offset.
265 * @param ofs_z Z offset.
266 * @param diag_x X diagonal (matrix 11).
267 * @param diag_y Y diagonal (matrix 22).
268 * @param diag_z Z diagonal (matrix 33).
269 * @param offdiag_x X off-diagonal (matrix 12 and 21).
270 * @param offdiag_y Y off-diagonal (matrix 13 and 31).
271 * @param offdiag_z Z off-diagonal (matrix 32 and 23).
272 * @param orientation_confidence Confidence in orientation (higher is better).
273 * @param old_orientation orientation before calibration.
274 * @param new_orientation orientation after calibration.
275 * @param scale_factor field radius correction factor
276 * @return length of the message in bytes (excluding serial stream start sign)
277 */
278static inline uint16_t mavlink_msg_mag_cal_report_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
279 mavlink_message_t* msg,
280 uint8_t compass_id,uint8_t cal_mask,uint8_t cal_status,uint8_t autosaved,float fitness,float ofs_x,float ofs_y,float ofs_z,float diag_x,float diag_y,float diag_z,float offdiag_x,float offdiag_y,float offdiag_z,float orientation_confidence,uint8_t old_orientation,uint8_t new_orientation,float scale_factor)
281{
282#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
284 _mav_put_float(buf, 0, fitness);
285 _mav_put_float(buf, 4, ofs_x);
286 _mav_put_float(buf, 8, ofs_y);
287 _mav_put_float(buf, 12, ofs_z);
288 _mav_put_float(buf, 16, diag_x);
289 _mav_put_float(buf, 20, diag_y);
290 _mav_put_float(buf, 24, diag_z);
291 _mav_put_float(buf, 28, offdiag_x);
292 _mav_put_float(buf, 32, offdiag_y);
293 _mav_put_float(buf, 36, offdiag_z);
294 _mav_put_uint8_t(buf, 40, compass_id);
295 _mav_put_uint8_t(buf, 41, cal_mask);
296 _mav_put_uint8_t(buf, 42, cal_status);
297 _mav_put_uint8_t(buf, 43, autosaved);
298 _mav_put_float(buf, 44, orientation_confidence);
299 _mav_put_uint8_t(buf, 48, old_orientation);
300 _mav_put_uint8_t(buf, 49, new_orientation);
301 _mav_put_float(buf, 50, scale_factor);
302
303 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
304#else
305 mavlink_mag_cal_report_t packet;
306 packet.fitness = fitness;
307 packet.ofs_x = ofs_x;
308 packet.ofs_y = ofs_y;
309 packet.ofs_z = ofs_z;
310 packet.diag_x = diag_x;
311 packet.diag_y = diag_y;
312 packet.diag_z = diag_z;
313 packet.offdiag_x = offdiag_x;
314 packet.offdiag_y = offdiag_y;
315 packet.offdiag_z = offdiag_z;
316 packet.compass_id = compass_id;
317 packet.cal_mask = cal_mask;
318 packet.cal_status = cal_status;
319 packet.autosaved = autosaved;
320 packet.orientation_confidence = orientation_confidence;
321 packet.old_orientation = old_orientation;
322 packet.new_orientation = new_orientation;
323 packet.scale_factor = scale_factor;
324
325 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
326#endif
327
329 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
330}
331
332/**
333 * @brief Encode a mag_cal_report struct
334 *
335 * @param system_id ID of this system
336 * @param component_id ID of this component (e.g. 200 for IMU)
337 * @param msg The MAVLink message to compress the data into
338 * @param mag_cal_report C-struct to read the message contents from
339 */
340static inline uint16_t mavlink_msg_mag_cal_report_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mag_cal_report_t* mag_cal_report)
341{
342 return mavlink_msg_mag_cal_report_pack(system_id, component_id, msg, mag_cal_report->compass_id, mag_cal_report->cal_mask, mag_cal_report->cal_status, mag_cal_report->autosaved, mag_cal_report->fitness, mag_cal_report->ofs_x, mag_cal_report->ofs_y, mag_cal_report->ofs_z, mag_cal_report->diag_x, mag_cal_report->diag_y, mag_cal_report->diag_z, mag_cal_report->offdiag_x, mag_cal_report->offdiag_y, mag_cal_report->offdiag_z, mag_cal_report->orientation_confidence, mag_cal_report->old_orientation, mag_cal_report->new_orientation, mag_cal_report->scale_factor);
343}
344
345/**
346 * @brief Encode a mag_cal_report struct on a channel
347 *
348 * @param system_id ID of this system
349 * @param component_id ID of this component (e.g. 200 for IMU)
350 * @param chan The MAVLink channel this message will be sent over
351 * @param msg The MAVLink message to compress the data into
352 * @param mag_cal_report C-struct to read the message contents from
353 */
354static inline uint16_t mavlink_msg_mag_cal_report_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_mag_cal_report_t* mag_cal_report)
355{
356 return mavlink_msg_mag_cal_report_pack_chan(system_id, component_id, chan, msg, mag_cal_report->compass_id, mag_cal_report->cal_mask, mag_cal_report->cal_status, mag_cal_report->autosaved, mag_cal_report->fitness, mag_cal_report->ofs_x, mag_cal_report->ofs_y, mag_cal_report->ofs_z, mag_cal_report->diag_x, mag_cal_report->diag_y, mag_cal_report->diag_z, mag_cal_report->offdiag_x, mag_cal_report->offdiag_y, mag_cal_report->offdiag_z, mag_cal_report->orientation_confidence, mag_cal_report->old_orientation, mag_cal_report->new_orientation, mag_cal_report->scale_factor);
357}
358
359/**
360 * @brief Encode a mag_cal_report struct with provided status structure
361 *
362 * @param system_id ID of this system
363 * @param component_id ID of this component (e.g. 200 for IMU)
364 * @param status MAVLink status structure
365 * @param msg The MAVLink message to compress the data into
366 * @param mag_cal_report C-struct to read the message contents from
367 */
368static inline uint16_t mavlink_msg_mag_cal_report_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mag_cal_report_t* mag_cal_report)
369{
370 return mavlink_msg_mag_cal_report_pack_status(system_id, component_id, _status, msg, mag_cal_report->compass_id, mag_cal_report->cal_mask, mag_cal_report->cal_status, mag_cal_report->autosaved, mag_cal_report->fitness, mag_cal_report->ofs_x, mag_cal_report->ofs_y, mag_cal_report->ofs_z, mag_cal_report->diag_x, mag_cal_report->diag_y, mag_cal_report->diag_z, mag_cal_report->offdiag_x, mag_cal_report->offdiag_y, mag_cal_report->offdiag_z, mag_cal_report->orientation_confidence, mag_cal_report->old_orientation, mag_cal_report->new_orientation, mag_cal_report->scale_factor);
371}
372
373/**
374 * @brief Send a mag_cal_report message
375 * @param chan MAVLink channel to send the message
376 *
377 * @param compass_id Compass being calibrated.
378 * @param cal_mask Bitmask of compasses being calibrated.
379 * @param cal_status Calibration Status.
380 * @param autosaved 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.
381 * @param fitness [mgauss] RMS milligauss residuals.
382 * @param ofs_x X offset.
383 * @param ofs_y Y offset.
384 * @param ofs_z Z offset.
385 * @param diag_x X diagonal (matrix 11).
386 * @param diag_y Y diagonal (matrix 22).
387 * @param diag_z Z diagonal (matrix 33).
388 * @param offdiag_x X off-diagonal (matrix 12 and 21).
389 * @param offdiag_y Y off-diagonal (matrix 13 and 31).
390 * @param offdiag_z Z off-diagonal (matrix 32 and 23).
391 * @param orientation_confidence Confidence in orientation (higher is better).
392 * @param old_orientation orientation before calibration.
393 * @param new_orientation orientation after calibration.
394 * @param scale_factor field radius correction factor
395 */
396#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
397
398static inline void mavlink_msg_mag_cal_report_send(mavlink_channel_t chan, uint8_t compass_id, uint8_t cal_mask, uint8_t cal_status, uint8_t autosaved, float fitness, float ofs_x, float ofs_y, float ofs_z, float diag_x, float diag_y, float diag_z, float offdiag_x, float offdiag_y, float offdiag_z, float orientation_confidence, uint8_t old_orientation, uint8_t new_orientation, float scale_factor)
399{
400#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
401 char buf[MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN];
402 _mav_put_float(buf, 0, fitness);
403 _mav_put_float(buf, 4, ofs_x);
404 _mav_put_float(buf, 8, ofs_y);
405 _mav_put_float(buf, 12, ofs_z);
406 _mav_put_float(buf, 16, diag_x);
407 _mav_put_float(buf, 20, diag_y);
408 _mav_put_float(buf, 24, diag_z);
409 _mav_put_float(buf, 28, offdiag_x);
410 _mav_put_float(buf, 32, offdiag_y);
411 _mav_put_float(buf, 36, offdiag_z);
412 _mav_put_uint8_t(buf, 40, compass_id);
413 _mav_put_uint8_t(buf, 41, cal_mask);
414 _mav_put_uint8_t(buf, 42, cal_status);
415 _mav_put_uint8_t(buf, 43, autosaved);
416 _mav_put_float(buf, 44, orientation_confidence);
417 _mav_put_uint8_t(buf, 48, old_orientation);
418 _mav_put_uint8_t(buf, 49, new_orientation);
419 _mav_put_float(buf, 50, scale_factor);
420
421 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAG_CAL_REPORT, buf, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
422#else
423 mavlink_mag_cal_report_t packet;
424 packet.fitness = fitness;
425 packet.ofs_x = ofs_x;
426 packet.ofs_y = ofs_y;
427 packet.ofs_z = ofs_z;
428 packet.diag_x = diag_x;
429 packet.diag_y = diag_y;
430 packet.diag_z = diag_z;
431 packet.offdiag_x = offdiag_x;
432 packet.offdiag_y = offdiag_y;
433 packet.offdiag_z = offdiag_z;
434 packet.compass_id = compass_id;
435 packet.cal_mask = cal_mask;
436 packet.cal_status = cal_status;
437 packet.autosaved = autosaved;
438 packet.orientation_confidence = orientation_confidence;
439 packet.old_orientation = old_orientation;
440 packet.new_orientation = new_orientation;
441 packet.scale_factor = scale_factor;
442
443 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAG_CAL_REPORT, (const char *)&packet, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
444#endif
445}
446
447/**
448 * @brief Send a mag_cal_report message
449 * @param chan MAVLink channel to send the message
450 * @param struct The MAVLink struct to serialize
451 */
452static inline void mavlink_msg_mag_cal_report_send_struct(mavlink_channel_t chan, const mavlink_mag_cal_report_t* mag_cal_report)
453{
454#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
455 mavlink_msg_mag_cal_report_send(chan, mag_cal_report->compass_id, mag_cal_report->cal_mask, mag_cal_report->cal_status, mag_cal_report->autosaved, mag_cal_report->fitness, mag_cal_report->ofs_x, mag_cal_report->ofs_y, mag_cal_report->ofs_z, mag_cal_report->diag_x, mag_cal_report->diag_y, mag_cal_report->diag_z, mag_cal_report->offdiag_x, mag_cal_report->offdiag_y, mag_cal_report->offdiag_z, mag_cal_report->orientation_confidence, mag_cal_report->old_orientation, mag_cal_report->new_orientation, mag_cal_report->scale_factor);
456#else
457 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAG_CAL_REPORT, (const char *)mag_cal_report, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
458#endif
459}
460
461#if MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
462/*
463 This variant of _send() can be used to save stack space by reusing
464 memory from the receive buffer. The caller provides a
465 mavlink_message_t which is the size of a full mavlink message. This
466 is usually the receive buffer for the channel, and allows a reply to an
467 incoming message with minimum stack space usage.
468 */
469static inline void mavlink_msg_mag_cal_report_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t compass_id, uint8_t cal_mask, uint8_t cal_status, uint8_t autosaved, float fitness, float ofs_x, float ofs_y, float ofs_z, float diag_x, float diag_y, float diag_z, float offdiag_x, float offdiag_y, float offdiag_z, float orientation_confidence, uint8_t old_orientation, uint8_t new_orientation, float scale_factor)
470{
471#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
472 char *buf = (char *)msgbuf;
473 _mav_put_float(buf, 0, fitness);
474 _mav_put_float(buf, 4, ofs_x);
475 _mav_put_float(buf, 8, ofs_y);
476 _mav_put_float(buf, 12, ofs_z);
477 _mav_put_float(buf, 16, diag_x);
478 _mav_put_float(buf, 20, diag_y);
479 _mav_put_float(buf, 24, diag_z);
480 _mav_put_float(buf, 28, offdiag_x);
481 _mav_put_float(buf, 32, offdiag_y);
482 _mav_put_float(buf, 36, offdiag_z);
483 _mav_put_uint8_t(buf, 40, compass_id);
484 _mav_put_uint8_t(buf, 41, cal_mask);
485 _mav_put_uint8_t(buf, 42, cal_status);
486 _mav_put_uint8_t(buf, 43, autosaved);
487 _mav_put_float(buf, 44, orientation_confidence);
488 _mav_put_uint8_t(buf, 48, old_orientation);
489 _mav_put_uint8_t(buf, 49, new_orientation);
490 _mav_put_float(buf, 50, scale_factor);
491
492 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAG_CAL_REPORT, buf, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
493#else
494 mavlink_mag_cal_report_t *packet = (mavlink_mag_cal_report_t *)msgbuf;
495 packet->fitness = fitness;
496 packet->ofs_x = ofs_x;
497 packet->ofs_y = ofs_y;
498 packet->ofs_z = ofs_z;
499 packet->diag_x = diag_x;
500 packet->diag_y = diag_y;
501 packet->diag_z = diag_z;
502 packet->offdiag_x = offdiag_x;
503 packet->offdiag_y = offdiag_y;
504 packet->offdiag_z = offdiag_z;
505 packet->compass_id = compass_id;
506 packet->cal_mask = cal_mask;
507 packet->cal_status = cal_status;
508 packet->autosaved = autosaved;
509 packet->orientation_confidence = orientation_confidence;
510 packet->old_orientation = old_orientation;
511 packet->new_orientation = new_orientation;
512 packet->scale_factor = scale_factor;
513
514 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAG_CAL_REPORT, (const char *)packet, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
515#endif
516}
517#endif
518
519#endif
520
521// MESSAGE MAG_CAL_REPORT UNPACKING
522
523
524/**
525 * @brief Get field compass_id from mag_cal_report message
526 *
527 * @return Compass being calibrated.
528 */
529static inline uint8_t mavlink_msg_mag_cal_report_get_compass_id(const mavlink_message_t* msg)
530{
531 return _MAV_RETURN_uint8_t(msg, 40);
532}
533
534/**
535 * @brief Get field cal_mask from mag_cal_report message
536 *
537 * @return Bitmask of compasses being calibrated.
538 */
539static inline uint8_t mavlink_msg_mag_cal_report_get_cal_mask(const mavlink_message_t* msg)
540{
541 return _MAV_RETURN_uint8_t(msg, 41);
542}
543
544/**
545 * @brief Get field cal_status from mag_cal_report message
546 *
547 * @return Calibration Status.
548 */
549static inline uint8_t mavlink_msg_mag_cal_report_get_cal_status(const mavlink_message_t* msg)
550{
551 return _MAV_RETURN_uint8_t(msg, 42);
552}
553
554/**
555 * @brief Get field autosaved from mag_cal_report message
556 *
557 * @return 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.
558 */
559static inline uint8_t mavlink_msg_mag_cal_report_get_autosaved(const mavlink_message_t* msg)
560{
561 return _MAV_RETURN_uint8_t(msg, 43);
562}
563
564/**
565 * @brief Get field fitness from mag_cal_report message
566 *
567 * @return [mgauss] RMS milligauss residuals.
568 */
569static inline float mavlink_msg_mag_cal_report_get_fitness(const mavlink_message_t* msg)
570{
571 return _MAV_RETURN_float(msg, 0);
572}
573
574/**
575 * @brief Get field ofs_x from mag_cal_report message
576 *
577 * @return X offset.
578 */
579static inline float mavlink_msg_mag_cal_report_get_ofs_x(const mavlink_message_t* msg)
580{
581 return _MAV_RETURN_float(msg, 4);
582}
583
584/**
585 * @brief Get field ofs_y from mag_cal_report message
586 *
587 * @return Y offset.
588 */
589static inline float mavlink_msg_mag_cal_report_get_ofs_y(const mavlink_message_t* msg)
590{
591 return _MAV_RETURN_float(msg, 8);
592}
593
594/**
595 * @brief Get field ofs_z from mag_cal_report message
596 *
597 * @return Z offset.
598 */
599static inline float mavlink_msg_mag_cal_report_get_ofs_z(const mavlink_message_t* msg)
600{
601 return _MAV_RETURN_float(msg, 12);
602}
603
604/**
605 * @brief Get field diag_x from mag_cal_report message
606 *
607 * @return X diagonal (matrix 11).
608 */
609static inline float mavlink_msg_mag_cal_report_get_diag_x(const mavlink_message_t* msg)
610{
611 return _MAV_RETURN_float(msg, 16);
612}
613
614/**
615 * @brief Get field diag_y from mag_cal_report message
616 *
617 * @return Y diagonal (matrix 22).
618 */
619static inline float mavlink_msg_mag_cal_report_get_diag_y(const mavlink_message_t* msg)
620{
621 return _MAV_RETURN_float(msg, 20);
622}
623
624/**
625 * @brief Get field diag_z from mag_cal_report message
626 *
627 * @return Z diagonal (matrix 33).
628 */
629static inline float mavlink_msg_mag_cal_report_get_diag_z(const mavlink_message_t* msg)
630{
631 return _MAV_RETURN_float(msg, 24);
632}
633
634/**
635 * @brief Get field offdiag_x from mag_cal_report message
636 *
637 * @return X off-diagonal (matrix 12 and 21).
638 */
639static inline float mavlink_msg_mag_cal_report_get_offdiag_x(const mavlink_message_t* msg)
640{
641 return _MAV_RETURN_float(msg, 28);
642}
643
644/**
645 * @brief Get field offdiag_y from mag_cal_report message
646 *
647 * @return Y off-diagonal (matrix 13 and 31).
648 */
649static inline float mavlink_msg_mag_cal_report_get_offdiag_y(const mavlink_message_t* msg)
650{
651 return _MAV_RETURN_float(msg, 32);
652}
653
654/**
655 * @brief Get field offdiag_z from mag_cal_report message
656 *
657 * @return Z off-diagonal (matrix 32 and 23).
658 */
659static inline float mavlink_msg_mag_cal_report_get_offdiag_z(const mavlink_message_t* msg)
660{
661 return _MAV_RETURN_float(msg, 36);
662}
663
664/**
665 * @brief Get field orientation_confidence from mag_cal_report message
666 *
667 * @return Confidence in orientation (higher is better).
668 */
669static inline float mavlink_msg_mag_cal_report_get_orientation_confidence(const mavlink_message_t* msg)
670{
671 return _MAV_RETURN_float(msg, 44);
672}
673
674/**
675 * @brief Get field old_orientation from mag_cal_report message
676 *
677 * @return orientation before calibration.
678 */
679static inline uint8_t mavlink_msg_mag_cal_report_get_old_orientation(const mavlink_message_t* msg)
680{
681 return _MAV_RETURN_uint8_t(msg, 48);
682}
683
684/**
685 * @brief Get field new_orientation from mag_cal_report message
686 *
687 * @return orientation after calibration.
688 */
689static inline uint8_t mavlink_msg_mag_cal_report_get_new_orientation(const mavlink_message_t* msg)
690{
691 return _MAV_RETURN_uint8_t(msg, 49);
692}
693
694/**
695 * @brief Get field scale_factor from mag_cal_report message
696 *
697 * @return field radius correction factor
698 */
699static inline float mavlink_msg_mag_cal_report_get_scale_factor(const mavlink_message_t* msg)
700{
701 return _MAV_RETURN_float(msg, 50);
702}
703
704/**
705 * @brief Decode a mag_cal_report message into a struct
706 *
707 * @param msg The message to decode
708 * @param mag_cal_report C-struct to decode the message contents into
709 */
710static inline void mavlink_msg_mag_cal_report_decode(const mavlink_message_t* msg, mavlink_mag_cal_report_t* mag_cal_report)
711{
712#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
713 mag_cal_report->fitness = mavlink_msg_mag_cal_report_get_fitness(msg);
714 mag_cal_report->ofs_x = mavlink_msg_mag_cal_report_get_ofs_x(msg);
715 mag_cal_report->ofs_y = mavlink_msg_mag_cal_report_get_ofs_y(msg);
716 mag_cal_report->ofs_z = mavlink_msg_mag_cal_report_get_ofs_z(msg);
717 mag_cal_report->diag_x = mavlink_msg_mag_cal_report_get_diag_x(msg);
718 mag_cal_report->diag_y = mavlink_msg_mag_cal_report_get_diag_y(msg);
719 mag_cal_report->diag_z = mavlink_msg_mag_cal_report_get_diag_z(msg);
720 mag_cal_report->offdiag_x = mavlink_msg_mag_cal_report_get_offdiag_x(msg);
721 mag_cal_report->offdiag_y = mavlink_msg_mag_cal_report_get_offdiag_y(msg);
722 mag_cal_report->offdiag_z = mavlink_msg_mag_cal_report_get_offdiag_z(msg);
723 mag_cal_report->compass_id = mavlink_msg_mag_cal_report_get_compass_id(msg);
724 mag_cal_report->cal_mask = mavlink_msg_mag_cal_report_get_cal_mask(msg);
725 mag_cal_report->cal_status = mavlink_msg_mag_cal_report_get_cal_status(msg);
726 mag_cal_report->autosaved = mavlink_msg_mag_cal_report_get_autosaved(msg);
727 mag_cal_report->orientation_confidence = mavlink_msg_mag_cal_report_get_orientation_confidence(msg);
728 mag_cal_report->old_orientation = mavlink_msg_mag_cal_report_get_old_orientation(msg);
729 mag_cal_report->new_orientation = mavlink_msg_mag_cal_report_get_new_orientation(msg);
730 mag_cal_report->scale_factor = mavlink_msg_mag_cal_report_get_scale_factor(msg);
731#else
732 uint8_t len = msg->len < MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN? msg->len : MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN;
733 memset(mag_cal_report, 0, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
734 memcpy(mag_cal_report, _MAV_PAYLOAD(msg), len);
735#endif
736}