Move telemetry displayport init and cms device registering
[betaflight.git] / lib / main / MAVLink / common / mavlink_msg_distance_sensor.h
blob8743b64852386cae16b699fe04593177eff74a51
1 // MESSAGE DISTANCE_SENSOR PACKING
3 #define MAVLINK_MSG_ID_DISTANCE_SENSOR 132
5 typedef struct __mavlink_distance_sensor_t
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 FIXME enum.
14 uint8_t covariance; ///< Measurement covariance in centimeters, 0 for unknown / invalid readings
15 } mavlink_distance_sensor_t;
17 #define MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN 14
18 #define MAVLINK_MSG_ID_132_LEN 14
20 #define MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC 85
21 #define MAVLINK_MSG_ID_132_CRC 85
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 } \
40 /**
41 * @brief Pack a distance_sensor message
42 * @param system_id ID of this system
43 * @param component_id ID of this component (e.g. 200 for IMU)
44 * @param msg The MAVLink message to compress the data into
46 * @param time_boot_ms Time since system boot
47 * @param min_distance Minimum distance the sensor can measure in centimeters
48 * @param max_distance Maximum distance the sensor can measure in centimeters
49 * @param current_distance Current distance reading
50 * @param type Type from MAV_DISTANCE_SENSOR enum.
51 * @param id Onboard ID of the sensor
52 * @param orientation Direction the sensor faces from FIXME enum.
53 * @param covariance Measurement covariance in centimeters, 0 for unknown / invalid readings
54 * @return length of the message in bytes (excluding serial stream start sign)
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)
59 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
60 char buf[MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN];
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);
70 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
71 #else
72 mavlink_distance_sensor_t packet;
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;
82 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
83 #endif
85 msg->msgid = MAVLINK_MSG_ID_DISTANCE_SENSOR;
86 #if MAVLINK_CRC_EXTRA
87 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
88 #else
89 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
90 #endif
93 /**
94 * @brief Pack a distance_sensor message on a channel
95 * @param system_id ID of this system
96 * @param component_id ID of this component (e.g. 200 for IMU)
97 * @param chan The MAVLink channel this message will be sent over
98 * @param msg The MAVLink message to compress the data into
99 * @param time_boot_ms Time since system boot
100 * @param min_distance Minimum distance the sensor can measure in centimeters
101 * @param max_distance Maximum distance the sensor can measure in centimeters
102 * @param current_distance Current distance reading
103 * @param type Type from MAV_DISTANCE_SENSOR enum.
104 * @param id Onboard ID of the sensor
105 * @param orientation Direction the sensor faces from FIXME enum.
106 * @param covariance Measurement covariance in centimeters, 0 for unknown / invalid readings
107 * @return length of the message in bytes (excluding serial stream start sign)
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)
113 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
114 char buf[MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN];
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);
124 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
125 #else
126 mavlink_distance_sensor_t packet;
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;
136 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
137 #endif
139 msg->msgid = MAVLINK_MSG_ID_DISTANCE_SENSOR;
140 #if MAVLINK_CRC_EXTRA
141 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
142 #else
143 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
144 #endif
148 * @brief Encode a distance_sensor struct
150 * @param system_id ID of this system
151 * @param component_id ID of this component (e.g. 200 for IMU)
152 * @param msg The MAVLink message to compress the data into
153 * @param distance_sensor C-struct to read the message contents from
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)
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);
161 * @brief Encode a distance_sensor struct on a channel
163 * @param system_id ID of this system
164 * @param component_id ID of this component (e.g. 200 for IMU)
165 * @param chan The MAVLink channel this message will be sent over
166 * @param msg The MAVLink message to compress the data into
167 * @param distance_sensor C-struct to read the message contents from
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)
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);
175 * @brief Send a distance_sensor message
176 * @param chan MAVLink channel to send the message
178 * @param time_boot_ms Time since system boot
179 * @param min_distance Minimum distance the sensor can measure in centimeters
180 * @param max_distance Maximum distance the sensor can measure in centimeters
181 * @param current_distance Current distance reading
182 * @param type Type from MAV_DISTANCE_SENSOR enum.
183 * @param id Onboard ID of the sensor
184 * @param orientation Direction the sensor faces from FIXME enum.
185 * @param covariance Measurement covariance in centimeters, 0 for unknown / invalid readings
187 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
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)
191 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
192 char buf[MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN];
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);
202 #if MAVLINK_CRC_EXTRA
203 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
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
208 mavlink_distance_sensor_t packet;
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;
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
226 #if MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN <= MAVLINK_MAX_PAYLOAD_LEN
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.
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)
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);
247 #if MAVLINK_CRC_EXTRA
248 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
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
253 mavlink_distance_sensor_t *packet = (mavlink_distance_sensor_t *)msgbuf;
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;
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
270 #endif
272 #endif
274 // MESSAGE DISTANCE_SENSOR UNPACKING
278 * @brief Get field time_boot_ms from distance_sensor message
280 * @return Time since system boot
282 static inline uint32_t mavlink_msg_distance_sensor_get_time_boot_ms(const mavlink_message_t* msg)
284 return _MAV_RETURN_uint32_t(msg, 0);
288 * @brief Get field min_distance from distance_sensor message
290 * @return Minimum distance the sensor can measure in centimeters
292 static inline uint16_t mavlink_msg_distance_sensor_get_min_distance(const mavlink_message_t* msg)
294 return _MAV_RETURN_uint16_t(msg, 4);
298 * @brief Get field max_distance from distance_sensor message
300 * @return Maximum distance the sensor can measure in centimeters
302 static inline uint16_t mavlink_msg_distance_sensor_get_max_distance(const mavlink_message_t* msg)
304 return _MAV_RETURN_uint16_t(msg, 6);
308 * @brief Get field current_distance from distance_sensor message
310 * @return Current distance reading
312 static inline uint16_t mavlink_msg_distance_sensor_get_current_distance(const mavlink_message_t* msg)
314 return _MAV_RETURN_uint16_t(msg, 8);
318 * @brief Get field type from distance_sensor message
320 * @return Type from MAV_DISTANCE_SENSOR enum.
322 static inline uint8_t mavlink_msg_distance_sensor_get_type(const mavlink_message_t* msg)
324 return _MAV_RETURN_uint8_t(msg, 10);
328 * @brief Get field id from distance_sensor message
330 * @return Onboard ID of the sensor
332 static inline uint8_t mavlink_msg_distance_sensor_get_id(const mavlink_message_t* msg)
334 return _MAV_RETURN_uint8_t(msg, 11);
338 * @brief Get field orientation from distance_sensor message
340 * @return Direction the sensor faces from FIXME enum.
342 static inline uint8_t mavlink_msg_distance_sensor_get_orientation(const mavlink_message_t* msg)
344 return _MAV_RETURN_uint8_t(msg, 12);
348 * @brief Get field covariance from distance_sensor message
350 * @return Measurement covariance in centimeters, 0 for unknown / invalid readings
352 static inline uint8_t mavlink_msg_distance_sensor_get_covariance(const mavlink_message_t* msg)
354 return _MAV_RETURN_uint8_t(msg, 13);
358 * @brief Decode a distance_sensor message into a struct
360 * @param msg The message to decode
361 * @param distance_sensor C-struct to decode the message contents into
363 static inline void mavlink_msg_distance_sensor_decode(const mavlink_message_t* msg, mavlink_distance_sensor_t* distance_sensor)
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