NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mavlink_msg_sensor_offsets.h
Go to the documentation of this file.
1 // MESSAGE SENSOR_OFFSETS PACKING
2 
3 #define MAVLINK_MSG_ID_SENSOR_OFFSETS 150
4 
6 {
8  int32_t raw_press;
9  int32_t raw_temp;
10  float gyro_cal_x;
11  float gyro_cal_y;
12  float gyro_cal_z;
13  float accel_cal_x;
14  float accel_cal_y;
15  float accel_cal_z;
16  int16_t mag_ofs_x;
17  int16_t mag_ofs_y;
18  int16_t mag_ofs_z;
20 
21 #define MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN 42
22 #define MAVLINK_MSG_ID_150_LEN 42
23 
24 #define MAVLINK_MSG_ID_SENSOR_OFFSETS_CRC 134
25 #define MAVLINK_MSG_ID_150_CRC 134
26 
27 
28 
29 #define MAVLINK_MESSAGE_INFO_SENSOR_OFFSETS { \
30  "SENSOR_OFFSETS", \
31  12, \
32  { { "mag_declination", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_sensor_offsets_t, mag_declination) }, \
33  { "raw_press", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_sensor_offsets_t, raw_press) }, \
34  { "raw_temp", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_sensor_offsets_t, raw_temp) }, \
35  { "gyro_cal_x", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_sensor_offsets_t, gyro_cal_x) }, \
36  { "gyro_cal_y", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_sensor_offsets_t, gyro_cal_y) }, \
37  { "gyro_cal_z", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_sensor_offsets_t, gyro_cal_z) }, \
38  { "accel_cal_x", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_sensor_offsets_t, accel_cal_x) }, \
39  { "accel_cal_y", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_sensor_offsets_t, accel_cal_y) }, \
40  { "accel_cal_z", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_sensor_offsets_t, accel_cal_z) }, \
41  { "mag_ofs_x", NULL, MAVLINK_TYPE_INT16_T, 0, 36, offsetof(mavlink_sensor_offsets_t, mag_ofs_x) }, \
42  { "mag_ofs_y", NULL, MAVLINK_TYPE_INT16_T, 0, 38, offsetof(mavlink_sensor_offsets_t, mag_ofs_y) }, \
43  { "mag_ofs_z", NULL, MAVLINK_TYPE_INT16_T, 0, 40, offsetof(mavlink_sensor_offsets_t, mag_ofs_z) }, \
44  } \
45 }
46 
47 
68 static inline uint16_t mavlink_msg_sensor_offsets_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
69  int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z, float mag_declination, int32_t raw_press, int32_t raw_temp, float gyro_cal_x, float gyro_cal_y, float gyro_cal_z, float accel_cal_x, float accel_cal_y, float accel_cal_z)
70 {
71 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
73  _mav_put_float(buf, 0, mag_declination);
74  _mav_put_int32_t(buf, 4, raw_press);
75  _mav_put_int32_t(buf, 8, raw_temp);
76  _mav_put_float(buf, 12, gyro_cal_x);
77  _mav_put_float(buf, 16, gyro_cal_y);
78  _mav_put_float(buf, 20, gyro_cal_z);
79  _mav_put_float(buf, 24, accel_cal_x);
80  _mav_put_float(buf, 28, accel_cal_y);
81  _mav_put_float(buf, 32, accel_cal_z);
82  _mav_put_int16_t(buf, 36, mag_ofs_x);
83  _mav_put_int16_t(buf, 38, mag_ofs_y);
84  _mav_put_int16_t(buf, 40, mag_ofs_z);
85 
87 #else
90  packet.raw_press = raw_press;
91  packet.raw_temp = raw_temp;
92  packet.gyro_cal_x = gyro_cal_x;
93  packet.gyro_cal_y = gyro_cal_y;
94  packet.gyro_cal_z = gyro_cal_z;
95  packet.accel_cal_x = accel_cal_x;
96  packet.accel_cal_y = accel_cal_y;
97  packet.accel_cal_z = accel_cal_z;
98  packet.mag_ofs_x = mag_ofs_x;
99  packet.mag_ofs_y = mag_ofs_y;
100  packet.mag_ofs_z = mag_ofs_z;
101 
103 #endif
104 
105  msg->msgid = MAVLINK_MSG_ID_SENSOR_OFFSETS;
106 #if MAVLINK_CRC_EXTRA
108 #else
109  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN);
110 #endif
111 }
112 
133 static inline uint16_t mavlink_msg_sensor_offsets_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
134  mavlink_message_t* msg,
135  int16_t mag_ofs_x,int16_t mag_ofs_y,int16_t mag_ofs_z,float mag_declination,int32_t raw_press,int32_t raw_temp,float gyro_cal_x,float gyro_cal_y,float gyro_cal_z,float accel_cal_x,float accel_cal_y,float accel_cal_z)
136 {
137 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
139  _mav_put_float(buf, 0, mag_declination);
140  _mav_put_int32_t(buf, 4, raw_press);
141  _mav_put_int32_t(buf, 8, raw_temp);
142  _mav_put_float(buf, 12, gyro_cal_x);
143  _mav_put_float(buf, 16, gyro_cal_y);
144  _mav_put_float(buf, 20, gyro_cal_z);
145  _mav_put_float(buf, 24, accel_cal_x);
146  _mav_put_float(buf, 28, accel_cal_y);
147  _mav_put_float(buf, 32, accel_cal_z);
148  _mav_put_int16_t(buf, 36, mag_ofs_x);
149  _mav_put_int16_t(buf, 38, mag_ofs_y);
150  _mav_put_int16_t(buf, 40, mag_ofs_z);
151 
153 #else
156  packet.raw_press = raw_press;
157  packet.raw_temp = raw_temp;
158  packet.gyro_cal_x = gyro_cal_x;
159  packet.gyro_cal_y = gyro_cal_y;
160  packet.gyro_cal_z = gyro_cal_z;
161  packet.accel_cal_x = accel_cal_x;
162  packet.accel_cal_y = accel_cal_y;
163  packet.accel_cal_z = accel_cal_z;
164  packet.mag_ofs_x = mag_ofs_x;
165  packet.mag_ofs_y = mag_ofs_y;
166  packet.mag_ofs_z = mag_ofs_z;
167 
169 #endif
170 
171  msg->msgid = MAVLINK_MSG_ID_SENSOR_OFFSETS;
172 #if MAVLINK_CRC_EXTRA
174 #else
175  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN);
176 #endif
177 }
178 
187 static inline uint16_t mavlink_msg_sensor_offsets_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_sensor_offsets_t* sensor_offsets)
188 {
189  return mavlink_msg_sensor_offsets_pack(system_id, component_id, msg, sensor_offsets->mag_ofs_x, sensor_offsets->mag_ofs_y, sensor_offsets->mag_ofs_z, sensor_offsets->mag_declination, sensor_offsets->raw_press, sensor_offsets->raw_temp, sensor_offsets->gyro_cal_x, sensor_offsets->gyro_cal_y, sensor_offsets->gyro_cal_z, sensor_offsets->accel_cal_x, sensor_offsets->accel_cal_y, sensor_offsets->accel_cal_z);
190 }
191 
201 static inline uint16_t mavlink_msg_sensor_offsets_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_sensor_offsets_t* sensor_offsets)
202 {
203  return mavlink_msg_sensor_offsets_pack_chan(system_id, component_id, chan, msg, sensor_offsets->mag_ofs_x, sensor_offsets->mag_ofs_y, sensor_offsets->mag_ofs_z, sensor_offsets->mag_declination, sensor_offsets->raw_press, sensor_offsets->raw_temp, sensor_offsets->gyro_cal_x, sensor_offsets->gyro_cal_y, sensor_offsets->gyro_cal_z, sensor_offsets->accel_cal_x, sensor_offsets->accel_cal_y, sensor_offsets->accel_cal_z);
204 }
205 
223 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
224 
225 static inline void mavlink_msg_sensor_offsets_send(mavlink_channel_t chan, int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z, float mag_declination, int32_t raw_press, int32_t raw_temp, float gyro_cal_x, float gyro_cal_y, float gyro_cal_z, float accel_cal_x, float accel_cal_y, float accel_cal_z)
226 {
227 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
229  _mav_put_float(buf, 0, mag_declination);
230  _mav_put_int32_t(buf, 4, raw_press);
231  _mav_put_int32_t(buf, 8, raw_temp);
232  _mav_put_float(buf, 12, gyro_cal_x);
233  _mav_put_float(buf, 16, gyro_cal_y);
234  _mav_put_float(buf, 20, gyro_cal_z);
235  _mav_put_float(buf, 24, accel_cal_x);
236  _mav_put_float(buf, 28, accel_cal_y);
237  _mav_put_float(buf, 32, accel_cal_z);
238  _mav_put_int16_t(buf, 36, mag_ofs_x);
239  _mav_put_int16_t(buf, 38, mag_ofs_y);
240  _mav_put_int16_t(buf, 40, mag_ofs_z);
241 
242 #if MAVLINK_CRC_EXTRA
244 #else
245  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_OFFSETS, buf, MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN);
246 #endif
247 #else
250  packet.raw_press = raw_press;
251  packet.raw_temp = raw_temp;
252  packet.gyro_cal_x = gyro_cal_x;
253  packet.gyro_cal_y = gyro_cal_y;
254  packet.gyro_cal_z = gyro_cal_z;
255  packet.accel_cal_x = accel_cal_x;
256  packet.accel_cal_y = accel_cal_y;
257  packet.accel_cal_z = accel_cal_z;
258  packet.mag_ofs_x = mag_ofs_x;
259  packet.mag_ofs_y = mag_ofs_y;
260  packet.mag_ofs_z = mag_ofs_z;
261 
262 #if MAVLINK_CRC_EXTRA
263  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_OFFSETS, (const char *)&packet, MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN, MAVLINK_MSG_ID_SENSOR_OFFSETS_CRC);
264 #else
265  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_OFFSETS, (const char *)&packet, MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN);
266 #endif
267 #endif
268 }
269 
270 #if MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
271 /*
272  This varient of _send() can be used to save stack space by re-using
273  memory from the receive buffer. The caller provides a
274  mavlink_message_t which is the size of a full mavlink message. This
275  is usually the receive buffer for the channel, and allows a reply to an
276  incoming message with minimum stack space usage.
277  */
278 static inline void mavlink_msg_sensor_offsets_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z, float mag_declination, int32_t raw_press, int32_t raw_temp, float gyro_cal_x, float gyro_cal_y, float gyro_cal_z, float accel_cal_x, float accel_cal_y, float accel_cal_z)
279 {
280 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
281  char *buf = (char *)msgbuf;
282  _mav_put_float(buf, 0, mag_declination);
283  _mav_put_int32_t(buf, 4, raw_press);
284  _mav_put_int32_t(buf, 8, raw_temp);
285  _mav_put_float(buf, 12, gyro_cal_x);
286  _mav_put_float(buf, 16, gyro_cal_y);
287  _mav_put_float(buf, 20, gyro_cal_z);
288  _mav_put_float(buf, 24, accel_cal_x);
289  _mav_put_float(buf, 28, accel_cal_y);
290  _mav_put_float(buf, 32, accel_cal_z);
291  _mav_put_int16_t(buf, 36, mag_ofs_x);
292  _mav_put_int16_t(buf, 38, mag_ofs_y);
293  _mav_put_int16_t(buf, 40, mag_ofs_z);
294 
295 #if MAVLINK_CRC_EXTRA
297 #else
298  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_OFFSETS, buf, MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN);
299 #endif
300 #else
303  packet->raw_press = raw_press;
304  packet->raw_temp = raw_temp;
305  packet->gyro_cal_x = gyro_cal_x;
306  packet->gyro_cal_y = gyro_cal_y;
307  packet->gyro_cal_z = gyro_cal_z;
308  packet->accel_cal_x = accel_cal_x;
309  packet->accel_cal_y = accel_cal_y;
310  packet->accel_cal_z = accel_cal_z;
311  packet->mag_ofs_x = mag_ofs_x;
312  packet->mag_ofs_y = mag_ofs_y;
313  packet->mag_ofs_z = mag_ofs_z;
314 
315 #if MAVLINK_CRC_EXTRA
316  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_OFFSETS, (const char *)packet, MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN, MAVLINK_MSG_ID_SENSOR_OFFSETS_CRC);
317 #else
318  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_OFFSETS, (const char *)packet, MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN);
319 #endif
320 #endif
321 }
322 #endif
323 
324 #endif
325 
326 // MESSAGE SENSOR_OFFSETS UNPACKING
327 
328 
334 static inline int16_t mavlink_msg_sensor_offsets_get_mag_ofs_x(const mavlink_message_t* msg)
335 {
336  return _MAV_RETURN_int16_t(msg, 36);
337 }
338 
344 static inline int16_t mavlink_msg_sensor_offsets_get_mag_ofs_y(const mavlink_message_t* msg)
345 {
346  return _MAV_RETURN_int16_t(msg, 38);
347 }
348 
354 static inline int16_t mavlink_msg_sensor_offsets_get_mag_ofs_z(const mavlink_message_t* msg)
355 {
356  return _MAV_RETURN_int16_t(msg, 40);
357 }
358 
364 static inline float mavlink_msg_sensor_offsets_get_mag_declination(const mavlink_message_t* msg)
365 {
366  return _MAV_RETURN_float(msg, 0);
367 }
368 
374 static inline int32_t mavlink_msg_sensor_offsets_get_raw_press(const mavlink_message_t* msg)
375 {
376  return _MAV_RETURN_int32_t(msg, 4);
377 }
378 
384 static inline int32_t mavlink_msg_sensor_offsets_get_raw_temp(const mavlink_message_t* msg)
385 {
386  return _MAV_RETURN_int32_t(msg, 8);
387 }
388 
394 static inline float mavlink_msg_sensor_offsets_get_gyro_cal_x(const mavlink_message_t* msg)
395 {
396  return _MAV_RETURN_float(msg, 12);
397 }
398 
404 static inline float mavlink_msg_sensor_offsets_get_gyro_cal_y(const mavlink_message_t* msg)
405 {
406  return _MAV_RETURN_float(msg, 16);
407 }
408 
414 static inline float mavlink_msg_sensor_offsets_get_gyro_cal_z(const mavlink_message_t* msg)
415 {
416  return _MAV_RETURN_float(msg, 20);
417 }
418 
424 static inline float mavlink_msg_sensor_offsets_get_accel_cal_x(const mavlink_message_t* msg)
425 {
426  return _MAV_RETURN_float(msg, 24);
427 }
428 
434 static inline float mavlink_msg_sensor_offsets_get_accel_cal_y(const mavlink_message_t* msg)
435 {
436  return _MAV_RETURN_float(msg, 28);
437 }
438 
444 static inline float mavlink_msg_sensor_offsets_get_accel_cal_z(const mavlink_message_t* msg)
445 {
446  return _MAV_RETURN_float(msg, 32);
447 }
448 
455 static inline void mavlink_msg_sensor_offsets_decode(const mavlink_message_t* msg, mavlink_sensor_offsets_t* sensor_offsets)
456 {
457 #if MAVLINK_NEED_BYTE_SWAP
458  sensor_offsets->mag_declination = mavlink_msg_sensor_offsets_get_mag_declination(msg);
459  sensor_offsets->raw_press = mavlink_msg_sensor_offsets_get_raw_press(msg);
460  sensor_offsets->raw_temp = mavlink_msg_sensor_offsets_get_raw_temp(msg);
461  sensor_offsets->gyro_cal_x = mavlink_msg_sensor_offsets_get_gyro_cal_x(msg);
462  sensor_offsets->gyro_cal_y = mavlink_msg_sensor_offsets_get_gyro_cal_y(msg);
463  sensor_offsets->gyro_cal_z = mavlink_msg_sensor_offsets_get_gyro_cal_z(msg);
464  sensor_offsets->accel_cal_x = mavlink_msg_sensor_offsets_get_accel_cal_x(msg);
465  sensor_offsets->accel_cal_y = mavlink_msg_sensor_offsets_get_accel_cal_y(msg);
466  sensor_offsets->accel_cal_z = mavlink_msg_sensor_offsets_get_accel_cal_z(msg);
467  sensor_offsets->mag_ofs_x = mavlink_msg_sensor_offsets_get_mag_ofs_x(msg);
468  sensor_offsets->mag_ofs_y = mavlink_msg_sensor_offsets_get_mag_ofs_y(msg);
469  sensor_offsets->mag_ofs_z = mavlink_msg_sensor_offsets_get_mag_ofs_z(msg);
470 #else
471  memcpy(sensor_offsets, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN);
472 #endif
473 }
#define _mav_put_float(buf, wire_offset, b)
Definition: protocol.h:145
#define _mav_put_int32_t(buf, wire_offset, b)
Definition: protocol.h:142
#define _mav_put_int16_t(buf, wire_offset, b)
Definition: protocol.h:140
int16_t mag_declination
Definition: compass.h:89