source: flair-src/branches/mavlink/tools/Controller/Mavlink/src/include/common/mavlink_msg_distance_sensor.h@ 75

Last change on this file since 75 was 75, checked in by Thomas Fuhrmann, 8 years ago

Change the version of mavlink generated messages and rename it to include

File size: 17.0 KB
Line 
1// MESSAGE DISTANCE_SENSOR PACKING
2
3#define MAVLINK_MSG_ID_DISTANCE_SENSOR 132
4
5typedef struct MAVLINK_PACKED __mavlink_distance_sensor_t
6{
7 uint32_t time_boot_ms; /*< Time since system boot*/
8 uint16_t min_distance; /*< Minimum distance the sensor can measure in centimeters*/
9 uint16_t max_distance; /*< Maximum distance the sensor can measure in centimeters*/
10 uint16_t current_distance; /*< Current distance reading*/
11 uint8_t type; /*< Type from MAV_DISTANCE_SENSOR enum.*/
12 uint8_t id; /*< Onboard ID of the sensor*/
13 uint8_t orientation; /*< Direction the sensor faces from MAV_SENSOR_ORIENTATION enum.*/
14 uint8_t covariance; /*< Measurement covariance in centimeters, 0 for unknown / invalid readings*/
15} mavlink_distance_sensor_t;
16
17#define MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN 14
18#define MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN 14
19#define MAVLINK_MSG_ID_132_LEN 14
20#define MAVLINK_MSG_ID_132_MIN_LEN 14
21
22#define MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC 85
23#define MAVLINK_MSG_ID_132_CRC 85
24
25
26
27#if MAVLINK_COMMAND_24BIT
28#define MAVLINK_MESSAGE_INFO_DISTANCE_SENSOR { \
29 132, \
30 "DISTANCE_SENSOR", \
31 8, \
32 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_distance_sensor_t, time_boot_ms) }, \
33 { "min_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_distance_sensor_t, min_distance) }, \
34 { "max_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_distance_sensor_t, max_distance) }, \
35 { "current_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_distance_sensor_t, current_distance) }, \
36 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_distance_sensor_t, type) }, \
37 { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 11, offsetof(mavlink_distance_sensor_t, id) }, \
38 { "orientation", NULL, MAVLINK_TYPE_UINT8_T, 0, 12, offsetof(mavlink_distance_sensor_t, orientation) }, \
39 { "covariance", NULL, MAVLINK_TYPE_UINT8_T, 0, 13, offsetof(mavlink_distance_sensor_t, covariance) }, \
40 } \
41}
42#else
43#define MAVLINK_MESSAGE_INFO_DISTANCE_SENSOR { \
44 "DISTANCE_SENSOR", \
45 8, \
46 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_distance_sensor_t, time_boot_ms) }, \
47 { "min_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_distance_sensor_t, min_distance) }, \
48 { "max_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_distance_sensor_t, max_distance) }, \
49 { "current_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_distance_sensor_t, current_distance) }, \
50 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_distance_sensor_t, type) }, \
51 { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 11, offsetof(mavlink_distance_sensor_t, id) }, \
52 { "orientation", NULL, MAVLINK_TYPE_UINT8_T, 0, 12, offsetof(mavlink_distance_sensor_t, orientation) }, \
53 { "covariance", NULL, MAVLINK_TYPE_UINT8_T, 0, 13, offsetof(mavlink_distance_sensor_t, covariance) }, \
54 } \
55}
56#endif
57
58/**
59 * @brief Pack a distance_sensor message
60 * @param system_id ID of this system
61 * @param component_id ID of this component (e.g. 200 for IMU)
62 * @param msg The MAVLink message to compress the data into
63 *
64 * @param time_boot_ms Time since system boot
65 * @param min_distance Minimum distance the sensor can measure in centimeters
66 * @param max_distance Maximum distance the sensor can measure in centimeters
67 * @param current_distance Current distance reading
68 * @param type Type from MAV_DISTANCE_SENSOR enum.
69 * @param id Onboard ID of the sensor
70 * @param orientation Direction the sensor faces from MAV_SENSOR_ORIENTATION enum.
71 * @param covariance Measurement covariance in centimeters, 0 for unknown / invalid readings
72 * @return length of the message in bytes (excluding serial stream start sign)
73 */
74static inline uint16_t mavlink_msg_distance_sensor_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
75 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)
76{
77#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
78 char buf[MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN];
79 _mav_put_uint32_t(buf, 0, time_boot_ms);
80 _mav_put_uint16_t(buf, 4, min_distance);
81 _mav_put_uint16_t(buf, 6, max_distance);
82 _mav_put_uint16_t(buf, 8, current_distance);
83 _mav_put_uint8_t(buf, 10, type);
84 _mav_put_uint8_t(buf, 11, id);
85 _mav_put_uint8_t(buf, 12, orientation);
86 _mav_put_uint8_t(buf, 13, covariance);
87
88 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
89#else
90 mavlink_distance_sensor_t packet;
91 packet.time_boot_ms = time_boot_ms;
92 packet.min_distance = min_distance;
93 packet.max_distance = max_distance;
94 packet.current_distance = current_distance;
95 packet.type = type;
96 packet.id = id;
97 packet.orientation = orientation;
98 packet.covariance = covariance;
99
100 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
101#endif
102
103 msg->msgid = MAVLINK_MSG_ID_DISTANCE_SENSOR;
104 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
105}
106
107/**
108 * @brief Pack a distance_sensor message on a channel
109 * @param system_id ID of this system
110 * @param component_id ID of this component (e.g. 200 for IMU)
111 * @param chan The MAVLink channel this message will be sent over
112 * @param msg The MAVLink message to compress the data into
113 * @param time_boot_ms Time since system boot
114 * @param min_distance Minimum distance the sensor can measure in centimeters
115 * @param max_distance Maximum distance the sensor can measure in centimeters
116 * @param current_distance Current distance reading
117 * @param type Type from MAV_DISTANCE_SENSOR enum.
118 * @param id Onboard ID of the sensor
119 * @param orientation Direction the sensor faces from MAV_SENSOR_ORIENTATION enum.
120 * @param covariance Measurement covariance in centimeters, 0 for unknown / invalid readings
121 * @return length of the message in bytes (excluding serial stream start sign)
122 */
123static inline uint16_t mavlink_msg_distance_sensor_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
124 mavlink_message_t* msg,
125 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)
126{
127#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
128 char buf[MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN];
129 _mav_put_uint32_t(buf, 0, time_boot_ms);
130 _mav_put_uint16_t(buf, 4, min_distance);
131 _mav_put_uint16_t(buf, 6, max_distance);
132 _mav_put_uint16_t(buf, 8, current_distance);
133 _mav_put_uint8_t(buf, 10, type);
134 _mav_put_uint8_t(buf, 11, id);
135 _mav_put_uint8_t(buf, 12, orientation);
136 _mav_put_uint8_t(buf, 13, covariance);
137
138 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
139#else
140 mavlink_distance_sensor_t packet;
141 packet.time_boot_ms = time_boot_ms;
142 packet.min_distance = min_distance;
143 packet.max_distance = max_distance;
144 packet.current_distance = current_distance;
145 packet.type = type;
146 packet.id = id;
147 packet.orientation = orientation;
148 packet.covariance = covariance;
149
150 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
151#endif
152
153 msg->msgid = MAVLINK_MSG_ID_DISTANCE_SENSOR;
154 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
155}
156
157/**
158 * @brief Encode a distance_sensor struct
159 *
160 * @param system_id ID of this system
161 * @param component_id ID of this component (e.g. 200 for IMU)
162 * @param msg The MAVLink message to compress the data into
163 * @param distance_sensor C-struct to read the message contents from
164 */
165static 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)
166{
167 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);
168}
169
170/**
171 * @brief Encode a distance_sensor struct on a channel
172 *
173 * @param system_id ID of this system
174 * @param component_id ID of this component (e.g. 200 for IMU)
175 * @param chan The MAVLink channel this message will be sent over
176 * @param msg The MAVLink message to compress the data into
177 * @param distance_sensor C-struct to read the message contents from
178 */
179static 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)
180{
181 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);
182}
183
184/**
185 * @brief Send a distance_sensor message
186 * @param chan MAVLink channel to send the message
187 *
188 * @param time_boot_ms Time since system boot
189 * @param min_distance Minimum distance the sensor can measure in centimeters
190 * @param max_distance Maximum distance the sensor can measure in centimeters
191 * @param current_distance Current distance reading
192 * @param type Type from MAV_DISTANCE_SENSOR enum.
193 * @param id Onboard ID of the sensor
194 * @param orientation Direction the sensor faces from MAV_SENSOR_ORIENTATION enum.
195 * @param covariance Measurement covariance in centimeters, 0 for unknown / invalid readings
196 */
197#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
198
199static 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)
200{
201#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
202 char buf[MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN];
203 _mav_put_uint32_t(buf, 0, time_boot_ms);
204 _mav_put_uint16_t(buf, 4, min_distance);
205 _mav_put_uint16_t(buf, 6, max_distance);
206 _mav_put_uint16_t(buf, 8, current_distance);
207 _mav_put_uint8_t(buf, 10, type);
208 _mav_put_uint8_t(buf, 11, id);
209 _mav_put_uint8_t(buf, 12, orientation);
210 _mav_put_uint8_t(buf, 13, covariance);
211
212 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
213#else
214 mavlink_distance_sensor_t packet;
215 packet.time_boot_ms = time_boot_ms;
216 packet.min_distance = min_distance;
217 packet.max_distance = max_distance;
218 packet.current_distance = current_distance;
219 packet.type = type;
220 packet.id = id;
221 packet.orientation = orientation;
222 packet.covariance = covariance;
223
224 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, (const char *)&packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
225#endif
226}
227
228/**
229 * @brief Send a distance_sensor message
230 * @param chan MAVLink channel to send the message
231 * @param struct The MAVLink struct to serialize
232 */
233static inline void mavlink_msg_distance_sensor_send_struct(mavlink_channel_t chan, const mavlink_distance_sensor_t* distance_sensor)
234{
235#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
236 mavlink_msg_distance_sensor_send(chan, 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);
237#else
238 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, (const char *)distance_sensor, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
239#endif
240}
241
242#if MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN <= MAVLINK_MAX_PAYLOAD_LEN
243/*
244 This varient of _send() can be used to save stack space by re-using
245 memory from the receive buffer. The caller provides a
246 mavlink_message_t which is the size of a full mavlink message. This
247 is usually the receive buffer for the channel, and allows a reply to an
248 incoming message with minimum stack space usage.
249 */
250static 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)
251{
252#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
253 char *buf = (char *)msgbuf;
254 _mav_put_uint32_t(buf, 0, time_boot_ms);
255 _mav_put_uint16_t(buf, 4, min_distance);
256 _mav_put_uint16_t(buf, 6, max_distance);
257 _mav_put_uint16_t(buf, 8, current_distance);
258 _mav_put_uint8_t(buf, 10, type);
259 _mav_put_uint8_t(buf, 11, id);
260 _mav_put_uint8_t(buf, 12, orientation);
261 _mav_put_uint8_t(buf, 13, covariance);
262
263 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
264#else
265 mavlink_distance_sensor_t *packet = (mavlink_distance_sensor_t *)msgbuf;
266 packet->time_boot_ms = time_boot_ms;
267 packet->min_distance = min_distance;
268 packet->max_distance = max_distance;
269 packet->current_distance = current_distance;
270 packet->type = type;
271 packet->id = id;
272 packet->orientation = orientation;
273 packet->covariance = covariance;
274
275 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, (const char *)packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
276#endif
277}
278#endif
279
280#endif
281
282// MESSAGE DISTANCE_SENSOR UNPACKING
283
284
285/**
286 * @brief Get field time_boot_ms from distance_sensor message
287 *
288 * @return Time since system boot
289 */
290static inline uint32_t mavlink_msg_distance_sensor_get_time_boot_ms(const mavlink_message_t* msg)
291{
292 return _MAV_RETURN_uint32_t(msg, 0);
293}
294
295/**
296 * @brief Get field min_distance from distance_sensor message
297 *
298 * @return Minimum distance the sensor can measure in centimeters
299 */
300static inline uint16_t mavlink_msg_distance_sensor_get_min_distance(const mavlink_message_t* msg)
301{
302 return _MAV_RETURN_uint16_t(msg, 4);
303}
304
305/**
306 * @brief Get field max_distance from distance_sensor message
307 *
308 * @return Maximum distance the sensor can measure in centimeters
309 */
310static inline uint16_t mavlink_msg_distance_sensor_get_max_distance(const mavlink_message_t* msg)
311{
312 return _MAV_RETURN_uint16_t(msg, 6);
313}
314
315/**
316 * @brief Get field current_distance from distance_sensor message
317 *
318 * @return Current distance reading
319 */
320static inline uint16_t mavlink_msg_distance_sensor_get_current_distance(const mavlink_message_t* msg)
321{
322 return _MAV_RETURN_uint16_t(msg, 8);
323}
324
325/**
326 * @brief Get field type from distance_sensor message
327 *
328 * @return Type from MAV_DISTANCE_SENSOR enum.
329 */
330static inline uint8_t mavlink_msg_distance_sensor_get_type(const mavlink_message_t* msg)
331{
332 return _MAV_RETURN_uint8_t(msg, 10);
333}
334
335/**
336 * @brief Get field id from distance_sensor message
337 *
338 * @return Onboard ID of the sensor
339 */
340static inline uint8_t mavlink_msg_distance_sensor_get_id(const mavlink_message_t* msg)
341{
342 return _MAV_RETURN_uint8_t(msg, 11);
343}
344
345/**
346 * @brief Get field orientation from distance_sensor message
347 *
348 * @return Direction the sensor faces from MAV_SENSOR_ORIENTATION enum.
349 */
350static inline uint8_t mavlink_msg_distance_sensor_get_orientation(const mavlink_message_t* msg)
351{
352 return _MAV_RETURN_uint8_t(msg, 12);
353}
354
355/**
356 * @brief Get field covariance from distance_sensor message
357 *
358 * @return Measurement covariance in centimeters, 0 for unknown / invalid readings
359 */
360static inline uint8_t mavlink_msg_distance_sensor_get_covariance(const mavlink_message_t* msg)
361{
362 return _MAV_RETURN_uint8_t(msg, 13);
363}
364
365/**
366 * @brief Decode a distance_sensor message into a struct
367 *
368 * @param msg The message to decode
369 * @param distance_sensor C-struct to decode the message contents into
370 */
371static inline void mavlink_msg_distance_sensor_decode(const mavlink_message_t* msg, mavlink_distance_sensor_t* distance_sensor)
372{
373#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
374 distance_sensor->time_boot_ms = mavlink_msg_distance_sensor_get_time_boot_ms(msg);
375 distance_sensor->min_distance = mavlink_msg_distance_sensor_get_min_distance(msg);
376 distance_sensor->max_distance = mavlink_msg_distance_sensor_get_max_distance(msg);
377 distance_sensor->current_distance = mavlink_msg_distance_sensor_get_current_distance(msg);
378 distance_sensor->type = mavlink_msg_distance_sensor_get_type(msg);
379 distance_sensor->id = mavlink_msg_distance_sensor_get_id(msg);
380 distance_sensor->orientation = mavlink_msg_distance_sensor_get_orientation(msg);
381 distance_sensor->covariance = mavlink_msg_distance_sensor_get_covariance(msg);
382#else
383 uint8_t len = msg->len < MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN? msg->len : MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN;
384 memset(distance_sensor, 0, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
385 memcpy(distance_sensor, _MAV_PAYLOAD(msg), len);
386#endif
387}
Note: See TracBrowser for help on using the repository browser.