NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mavlink_msg_sensor_diag.h
Go to the documentation of this file.
1 // MESSAGE SENSOR_DIAG PACKING
2 
3 #define MAVLINK_MSG_ID_SENSOR_DIAG 196
4 
5 typedef struct __mavlink_sensor_diag_t
6 {
7  float float1;
8  float float2;
9  int16_t int1;
10  int8_t char1;
12 
13 #define MAVLINK_MSG_ID_SENSOR_DIAG_LEN 11
14 #define MAVLINK_MSG_ID_196_LEN 11
15 
16 #define MAVLINK_MSG_ID_SENSOR_DIAG_CRC 129
17 #define MAVLINK_MSG_ID_196_CRC 129
18 
19 
20 
21 #define MAVLINK_MESSAGE_INFO_SENSOR_DIAG { \
22  "SENSOR_DIAG", \
23  4, \
24  { { "float1", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_sensor_diag_t, float1) }, \
25  { "float2", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_sensor_diag_t, float2) }, \
26  { "int1", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_sensor_diag_t, int1) }, \
27  { "char1", NULL, MAVLINK_TYPE_INT8_T, 0, 10, offsetof(mavlink_sensor_diag_t, char1) }, \
28  } \
29 }
30 
31 
44 static inline uint16_t mavlink_msg_sensor_diag_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
45  float float1, float float2, int16_t int1, int8_t char1)
46 {
47 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
49  _mav_put_float(buf, 0, float1);
50  _mav_put_float(buf, 4, float2);
51  _mav_put_int16_t(buf, 8, int1);
52  _mav_put_int8_t(buf, 10, char1);
53 
55 #else
56  mavlink_sensor_diag_t packet;
57  packet.float1 = float1;
58  packet.float2 = float2;
59  packet.int1 = int1;
60  packet.char1 = char1;
61 
63 #endif
64 
65  msg->msgid = MAVLINK_MSG_ID_SENSOR_DIAG;
66 #if MAVLINK_CRC_EXTRA
68 #else
69  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SENSOR_DIAG_LEN);
70 #endif
71 }
72 
85 static inline uint16_t mavlink_msg_sensor_diag_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
86  mavlink_message_t* msg,
87  float float1,float float2,int16_t int1,int8_t char1)
88 {
89 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
91  _mav_put_float(buf, 0, float1);
92  _mav_put_float(buf, 4, float2);
93  _mav_put_int16_t(buf, 8, int1);
94  _mav_put_int8_t(buf, 10, char1);
95 
97 #else
98  mavlink_sensor_diag_t packet;
99  packet.float1 = float1;
100  packet.float2 = float2;
101  packet.int1 = int1;
102  packet.char1 = char1;
103 
105 #endif
106 
107  msg->msgid = MAVLINK_MSG_ID_SENSOR_DIAG;
108 #if MAVLINK_CRC_EXTRA
110 #else
111  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SENSOR_DIAG_LEN);
112 #endif
113 }
114 
123 static inline uint16_t mavlink_msg_sensor_diag_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_sensor_diag_t* sensor_diag)
124 {
125  return mavlink_msg_sensor_diag_pack(system_id, component_id, msg, sensor_diag->float1, sensor_diag->float2, sensor_diag->int1, sensor_diag->char1);
126 }
127 
137 static inline uint16_t mavlink_msg_sensor_diag_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_sensor_diag_t* sensor_diag)
138 {
139  return mavlink_msg_sensor_diag_pack_chan(system_id, component_id, chan, msg, sensor_diag->float1, sensor_diag->float2, sensor_diag->int1, sensor_diag->char1);
140 }
141 
151 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
152 
153 static inline void mavlink_msg_sensor_diag_send(mavlink_channel_t chan, float float1, float float2, int16_t int1, int8_t char1)
154 {
155 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
157  _mav_put_float(buf, 0, float1);
158  _mav_put_float(buf, 4, float2);
159  _mav_put_int16_t(buf, 8, int1);
160  _mav_put_int8_t(buf, 10, char1);
161 
162 #if MAVLINK_CRC_EXTRA
164 #else
165  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_DIAG, buf, MAVLINK_MSG_ID_SENSOR_DIAG_LEN);
166 #endif
167 #else
168  mavlink_sensor_diag_t packet;
169  packet.float1 = float1;
170  packet.float2 = float2;
171  packet.int1 = int1;
172  packet.char1 = char1;
173 
174 #if MAVLINK_CRC_EXTRA
175  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_DIAG, (const char *)&packet, MAVLINK_MSG_ID_SENSOR_DIAG_LEN, MAVLINK_MSG_ID_SENSOR_DIAG_CRC);
176 #else
177  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_DIAG, (const char *)&packet, MAVLINK_MSG_ID_SENSOR_DIAG_LEN);
178 #endif
179 #endif
180 }
181 
182 #if MAVLINK_MSG_ID_SENSOR_DIAG_LEN <= MAVLINK_MAX_PAYLOAD_LEN
183 /*
184  This varient of _send() can be used to save stack space by re-using
185  memory from the receive buffer. The caller provides a
186  mavlink_message_t which is the size of a full mavlink message. This
187  is usually the receive buffer for the channel, and allows a reply to an
188  incoming message with minimum stack space usage.
189  */
190 static inline void mavlink_msg_sensor_diag_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float float1, float float2, int16_t int1, int8_t char1)
191 {
192 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193  char *buf = (char *)msgbuf;
194  _mav_put_float(buf, 0, float1);
195  _mav_put_float(buf, 4, float2);
196  _mav_put_int16_t(buf, 8, int1);
197  _mav_put_int8_t(buf, 10, char1);
198 
199 #if MAVLINK_CRC_EXTRA
201 #else
202  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_DIAG, buf, MAVLINK_MSG_ID_SENSOR_DIAG_LEN);
203 #endif
204 #else
205  mavlink_sensor_diag_t *packet = (mavlink_sensor_diag_t *)msgbuf;
206  packet->float1 = float1;
207  packet->float2 = float2;
208  packet->int1 = int1;
209  packet->char1 = char1;
210 
211 #if MAVLINK_CRC_EXTRA
212  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_DIAG, (const char *)packet, MAVLINK_MSG_ID_SENSOR_DIAG_LEN, MAVLINK_MSG_ID_SENSOR_DIAG_CRC);
213 #else
214  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_DIAG, (const char *)packet, MAVLINK_MSG_ID_SENSOR_DIAG_LEN);
215 #endif
216 #endif
217 }
218 #endif
219 
220 #endif
221 
222 // MESSAGE SENSOR_DIAG UNPACKING
223 
224 
230 static inline float mavlink_msg_sensor_diag_get_float1(const mavlink_message_t* msg)
231 {
232  return _MAV_RETURN_float(msg, 0);
233 }
234 
240 static inline float mavlink_msg_sensor_diag_get_float2(const mavlink_message_t* msg)
241 {
242  return _MAV_RETURN_float(msg, 4);
243 }
244 
250 static inline int16_t mavlink_msg_sensor_diag_get_int1(const mavlink_message_t* msg)
251 {
252  return _MAV_RETURN_int16_t(msg, 8);
253 }
254 
260 static inline int8_t mavlink_msg_sensor_diag_get_char1(const mavlink_message_t* msg)
261 {
262  return _MAV_RETURN_int8_t(msg, 10);
263 }
264 
271 static inline void mavlink_msg_sensor_diag_decode(const mavlink_message_t* msg, mavlink_sensor_diag_t* sensor_diag)
272 {
273 #if MAVLINK_NEED_BYTE_SWAP
274  sensor_diag->float1 = mavlink_msg_sensor_diag_get_float1(msg);
275  sensor_diag->float2 = mavlink_msg_sensor_diag_get_float2(msg);
276  sensor_diag->int1 = mavlink_msg_sensor_diag_get_int1(msg);
277  sensor_diag->char1 = mavlink_msg_sensor_diag_get_char1(msg);
278 #else
279  memcpy(sensor_diag, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_SENSOR_DIAG_LEN);
280 #endif
281 }
#define _mav_put_float(buf, wire_offset, b)
Definition: protocol.h:145
#define _MAV_RETURN_int8_t(msg, wire_offset)
Definition: protocol.h:237
#define _mav_put_int8_t(buf, wire_offset, b)
Definition: protocol.h:135
#define _mav_put_int16_t(buf, wire_offset, b)
Definition: protocol.h:140