NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mavlink_msg_distance_sensor.h
Go to the documentation of this file.
1 // MESSAGE DISTANCE_SENSOR PACKING
2 
3 #define MAVLINK_MSG_ID_DISTANCE_SENSOR 132
4 
6 {
7  uint32_t time_boot_ms;
8  uint16_t min_distance;
9  uint16_t max_distance;
10  uint16_t current_distance;
11  uint8_t type;
12  uint8_t id;
13  uint8_t orientation;
14  uint8_t covariance;
16 
17 #define MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN 14
18 #define MAVLINK_MSG_ID_132_LEN 14
19 
20 #define MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC 85
21 #define MAVLINK_MSG_ID_132_CRC 85
22 
23 
24 
25 #define MAVLINK_MESSAGE_INFO_DISTANCE_SENSOR { \
26  "DISTANCE_SENSOR", \
27  8, \
28  { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_distance_sensor_t, time_boot_ms) }, \
29  { "min_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_distance_sensor_t, min_distance) }, \
30  { "max_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_distance_sensor_t, max_distance) }, \
31  { "current_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_distance_sensor_t, current_distance) }, \
32  { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_distance_sensor_t, type) }, \
33  { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 11, offsetof(mavlink_distance_sensor_t, id) }, \
34  { "orientation", NULL, MAVLINK_TYPE_UINT8_T, 0, 12, offsetof(mavlink_distance_sensor_t, orientation) }, \
35  { "covariance", NULL, MAVLINK_TYPE_UINT8_T, 0, 13, offsetof(mavlink_distance_sensor_t, covariance) }, \
36  } \
37 }
38 
39 
56 static inline uint16_t mavlink_msg_distance_sensor_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
57  uint32_t time_boot_ms, uint16_t min_distance, uint16_t max_distance, uint16_t current_distance, uint8_t type, uint8_t id, uint8_t orientation, uint8_t covariance)
58 {
59 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
61  _mav_put_uint32_t(buf, 0, time_boot_ms);
62  _mav_put_uint16_t(buf, 4, min_distance);
63  _mav_put_uint16_t(buf, 6, max_distance);
64  _mav_put_uint16_t(buf, 8, current_distance);
65  _mav_put_uint8_t(buf, 10, type);
66  _mav_put_uint8_t(buf, 11, id);
67  _mav_put_uint8_t(buf, 12, orientation);
68  _mav_put_uint8_t(buf, 13, covariance);
69 
71 #else
73  packet.time_boot_ms = time_boot_ms;
74  packet.min_distance = min_distance;
75  packet.max_distance = max_distance;
76  packet.current_distance = current_distance;
77  packet.type = type;
78  packet.id = id;
79  packet.orientation = orientation;
80  packet.covariance = covariance;
81 
83 #endif
84 
85  msg->msgid = MAVLINK_MSG_ID_DISTANCE_SENSOR;
86 #if MAVLINK_CRC_EXTRA
88 #else
89  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
90 #endif
91 }
92 
109 static inline uint16_t mavlink_msg_distance_sensor_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
110  mavlink_message_t* msg,
111  uint32_t time_boot_ms,uint16_t min_distance,uint16_t max_distance,uint16_t current_distance,uint8_t type,uint8_t id,uint8_t orientation,uint8_t covariance)
112 {
113 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
115  _mav_put_uint32_t(buf, 0, time_boot_ms);
116  _mav_put_uint16_t(buf, 4, min_distance);
117  _mav_put_uint16_t(buf, 6, max_distance);
118  _mav_put_uint16_t(buf, 8, current_distance);
119  _mav_put_uint8_t(buf, 10, type);
120  _mav_put_uint8_t(buf, 11, id);
121  _mav_put_uint8_t(buf, 12, orientation);
122  _mav_put_uint8_t(buf, 13, covariance);
123 
125 #else
127  packet.time_boot_ms = time_boot_ms;
128  packet.min_distance = min_distance;
129  packet.max_distance = max_distance;
130  packet.current_distance = current_distance;
131  packet.type = type;
132  packet.id = id;
133  packet.orientation = orientation;
134  packet.covariance = covariance;
135 
137 #endif
138 
139  msg->msgid = MAVLINK_MSG_ID_DISTANCE_SENSOR;
140 #if MAVLINK_CRC_EXTRA
142 #else
143  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
144 #endif
145 }
146 
155 static inline uint16_t mavlink_msg_distance_sensor_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_distance_sensor_t* distance_sensor)
156 {
157  return mavlink_msg_distance_sensor_pack(system_id, component_id, msg, distance_sensor->time_boot_ms, distance_sensor->min_distance, distance_sensor->max_distance, distance_sensor->current_distance, distance_sensor->type, distance_sensor->id, distance_sensor->orientation, distance_sensor->covariance);
158 }
159 
169 static inline uint16_t mavlink_msg_distance_sensor_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_distance_sensor_t* distance_sensor)
170 {
171  return mavlink_msg_distance_sensor_pack_chan(system_id, component_id, chan, msg, distance_sensor->time_boot_ms, distance_sensor->min_distance, distance_sensor->max_distance, distance_sensor->current_distance, distance_sensor->type, distance_sensor->id, distance_sensor->orientation, distance_sensor->covariance);
172 }
173 
187 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
188 
189 static inline void mavlink_msg_distance_sensor_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint16_t min_distance, uint16_t max_distance, uint16_t current_distance, uint8_t type, uint8_t id, uint8_t orientation, uint8_t covariance)
190 {
191 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193  _mav_put_uint32_t(buf, 0, time_boot_ms);
194  _mav_put_uint16_t(buf, 4, min_distance);
195  _mav_put_uint16_t(buf, 6, max_distance);
196  _mav_put_uint16_t(buf, 8, current_distance);
197  _mav_put_uint8_t(buf, 10, type);
198  _mav_put_uint8_t(buf, 11, id);
199  _mav_put_uint8_t(buf, 12, orientation);
200  _mav_put_uint8_t(buf, 13, covariance);
201 
202 #if MAVLINK_CRC_EXTRA
204 #else
205  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
206 #endif
207 #else
209  packet.time_boot_ms = time_boot_ms;
210  packet.min_distance = min_distance;
211  packet.max_distance = max_distance;
212  packet.current_distance = current_distance;
213  packet.type = type;
214  packet.id = id;
215  packet.orientation = orientation;
216  packet.covariance = covariance;
217 
218 #if MAVLINK_CRC_EXTRA
219  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, (const char *)&packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
220 #else
221  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, (const char *)&packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
222 #endif
223 #endif
224 }
225 
226 #if MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN <= MAVLINK_MAX_PAYLOAD_LEN
227 /*
228  This varient of _send() can be used to save stack space by re-using
229  memory from the receive buffer. The caller provides a
230  mavlink_message_t which is the size of a full mavlink message. This
231  is usually the receive buffer for the channel, and allows a reply to an
232  incoming message with minimum stack space usage.
233  */
234 static inline void mavlink_msg_distance_sensor_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint16_t min_distance, uint16_t max_distance, uint16_t current_distance, uint8_t type, uint8_t id, uint8_t orientation, uint8_t covariance)
235 {
236 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
237  char *buf = (char *)msgbuf;
238  _mav_put_uint32_t(buf, 0, time_boot_ms);
239  _mav_put_uint16_t(buf, 4, min_distance);
240  _mav_put_uint16_t(buf, 6, max_distance);
241  _mav_put_uint16_t(buf, 8, current_distance);
242  _mav_put_uint8_t(buf, 10, type);
243  _mav_put_uint8_t(buf, 11, id);
244  _mav_put_uint8_t(buf, 12, orientation);
245  _mav_put_uint8_t(buf, 13, covariance);
246 
247 #if MAVLINK_CRC_EXTRA
249 #else
250  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
251 #endif
252 #else
254  packet->time_boot_ms = time_boot_ms;
255  packet->min_distance = min_distance;
256  packet->max_distance = max_distance;
257  packet->current_distance = current_distance;
258  packet->type = type;
259  packet->id = id;
260  packet->orientation = orientation;
261  packet->covariance = covariance;
262 
263 #if MAVLINK_CRC_EXTRA
264  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, (const char *)packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
265 #else
266  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, (const char *)packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
267 #endif
268 #endif
269 }
270 #endif
271 
272 #endif
273 
274 // MESSAGE DISTANCE_SENSOR UNPACKING
275 
276 
282 static inline uint32_t mavlink_msg_distance_sensor_get_time_boot_ms(const mavlink_message_t* msg)
283 {
284  return _MAV_RETURN_uint32_t(msg, 0);
285 }
286 
292 static inline uint16_t mavlink_msg_distance_sensor_get_min_distance(const mavlink_message_t* msg)
293 {
294  return _MAV_RETURN_uint16_t(msg, 4);
295 }
296 
302 static inline uint16_t mavlink_msg_distance_sensor_get_max_distance(const mavlink_message_t* msg)
303 {
304  return _MAV_RETURN_uint16_t(msg, 6);
305 }
306 
312 static inline uint16_t mavlink_msg_distance_sensor_get_current_distance(const mavlink_message_t* msg)
313 {
314  return _MAV_RETURN_uint16_t(msg, 8);
315 }
316 
322 static inline uint8_t mavlink_msg_distance_sensor_get_type(const mavlink_message_t* msg)
323 {
324  return _MAV_RETURN_uint8_t(msg, 10);
325 }
326 
332 static inline uint8_t mavlink_msg_distance_sensor_get_id(const mavlink_message_t* msg)
333 {
334  return _MAV_RETURN_uint8_t(msg, 11);
335 }
336 
342 static inline uint8_t mavlink_msg_distance_sensor_get_orientation(const mavlink_message_t* msg)
343 {
344  return _MAV_RETURN_uint8_t(msg, 12);
345 }
346 
352 static inline uint8_t mavlink_msg_distance_sensor_get_covariance(const mavlink_message_t* msg)
353 {
354  return _MAV_RETURN_uint8_t(msg, 13);
355 }
356 
363 static inline void mavlink_msg_distance_sensor_decode(const mavlink_message_t* msg, mavlink_distance_sensor_t* distance_sensor)
364 {
365 #if MAVLINK_NEED_BYTE_SWAP
366  distance_sensor->time_boot_ms = mavlink_msg_distance_sensor_get_time_boot_ms(msg);
367  distance_sensor->min_distance = mavlink_msg_distance_sensor_get_min_distance(msg);
368  distance_sensor->max_distance = mavlink_msg_distance_sensor_get_max_distance(msg);
369  distance_sensor->current_distance = mavlink_msg_distance_sensor_get_current_distance(msg);
370  distance_sensor->type = mavlink_msg_distance_sensor_get_type(msg);
371  distance_sensor->id = mavlink_msg_distance_sensor_get_id(msg);
372  distance_sensor->orientation = mavlink_msg_distance_sensor_get_orientation(msg);
373  distance_sensor->covariance = mavlink_msg_distance_sensor_get_covariance(msg);
374 #else
375  memcpy(distance_sensor, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
376 #endif
377 }
uint8_t type
Definition: fat_standard.h:67
#define _MAV_RETURN_uint8_t(msg, wire_offset)
Definition: protocol.h:238
#define _mav_put_uint8_t(buf, wire_offset, b)
Definition: protocol.h:134
#define _mav_put_uint16_t(buf, wire_offset, b)
Definition: protocol.h:139
#define _mav_put_uint32_t(buf, wire_offset, b)
Definition: protocol.h:141