Move telemetry displayport init and cms device registering
[betaflight.git] / lib / main / MAVLink / common / mavlink_msg_terrain_report.h
blob1b61dd4bf9a2da3112a068ba755364d8542abb90
1 // MESSAGE TERRAIN_REPORT PACKING
3 #define MAVLINK_MSG_ID_TERRAIN_REPORT 136
5 typedef struct __mavlink_terrain_report_t
7 int32_t lat; ///< Latitude (degrees *10^7)
8 int32_t lon; ///< Longitude (degrees *10^7)
9 float terrain_height; ///< Terrain height in meters AMSL
10 float current_height; ///< Current vehicle height above lat/lon terrain height (meters)
11 uint16_t spacing; ///< grid spacing (zero if terrain at this location unavailable)
12 uint16_t pending; ///< Number of 4x4 terrain blocks waiting to be received or read from disk
13 uint16_t loaded; ///< Number of 4x4 terrain blocks in memory
14 } mavlink_terrain_report_t;
16 #define MAVLINK_MSG_ID_TERRAIN_REPORT_LEN 22
17 #define MAVLINK_MSG_ID_136_LEN 22
19 #define MAVLINK_MSG_ID_TERRAIN_REPORT_CRC 1
20 #define MAVLINK_MSG_ID_136_CRC 1
24 #define MAVLINK_MESSAGE_INFO_TERRAIN_REPORT { \
25 "TERRAIN_REPORT", \
26 7, \
27 { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_report_t, lat) }, \
28 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_report_t, lon) }, \
29 { "terrain_height", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_terrain_report_t, terrain_height) }, \
30 { "current_height", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_terrain_report_t, current_height) }, \
31 { "spacing", NULL, MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_terrain_report_t, spacing) }, \
32 { "pending", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_terrain_report_t, pending) }, \
33 { "loaded", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_terrain_report_t, loaded) }, \
34 } \
38 /**
39 * @brief Pack a terrain_report message
40 * @param system_id ID of this system
41 * @param component_id ID of this component (e.g. 200 for IMU)
42 * @param msg The MAVLink message to compress the data into
44 * @param lat Latitude (degrees *10^7)
45 * @param lon Longitude (degrees *10^7)
46 * @param spacing grid spacing (zero if terrain at this location unavailable)
47 * @param terrain_height Terrain height in meters AMSL
48 * @param current_height Current vehicle height above lat/lon terrain height (meters)
49 * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk
50 * @param loaded Number of 4x4 terrain blocks in memory
51 * @return length of the message in bytes (excluding serial stream start sign)
53 static inline uint16_t mavlink_msg_terrain_report_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
54 int32_t lat, int32_t lon, uint16_t spacing, float terrain_height, float current_height, uint16_t pending, uint16_t loaded)
56 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
57 char buf[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN];
58 _mav_put_int32_t(buf, 0, lat);
59 _mav_put_int32_t(buf, 4, lon);
60 _mav_put_float(buf, 8, terrain_height);
61 _mav_put_float(buf, 12, current_height);
62 _mav_put_uint16_t(buf, 16, spacing);
63 _mav_put_uint16_t(buf, 18, pending);
64 _mav_put_uint16_t(buf, 20, loaded);
66 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
67 #else
68 mavlink_terrain_report_t packet;
69 packet.lat = lat;
70 packet.lon = lon;
71 packet.terrain_height = terrain_height;
72 packet.current_height = current_height;
73 packet.spacing = spacing;
74 packet.pending = pending;
75 packet.loaded = loaded;
77 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
78 #endif
80 msg->msgid = MAVLINK_MSG_ID_TERRAIN_REPORT;
81 #if MAVLINK_CRC_EXTRA
82 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
83 #else
84 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
85 #endif
88 /**
89 * @brief Pack a terrain_report message on a channel
90 * @param system_id ID of this system
91 * @param component_id ID of this component (e.g. 200 for IMU)
92 * @param chan The MAVLink channel this message will be sent over
93 * @param msg The MAVLink message to compress the data into
94 * @param lat Latitude (degrees *10^7)
95 * @param lon Longitude (degrees *10^7)
96 * @param spacing grid spacing (zero if terrain at this location unavailable)
97 * @param terrain_height Terrain height in meters AMSL
98 * @param current_height Current vehicle height above lat/lon terrain height (meters)
99 * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk
100 * @param loaded Number of 4x4 terrain blocks in memory
101 * @return length of the message in bytes (excluding serial stream start sign)
103 static inline uint16_t mavlink_msg_terrain_report_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
104 mavlink_message_t* msg,
105 int32_t lat,int32_t lon,uint16_t spacing,float terrain_height,float current_height,uint16_t pending,uint16_t loaded)
107 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
108 char buf[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN];
109 _mav_put_int32_t(buf, 0, lat);
110 _mav_put_int32_t(buf, 4, lon);
111 _mav_put_float(buf, 8, terrain_height);
112 _mav_put_float(buf, 12, current_height);
113 _mav_put_uint16_t(buf, 16, spacing);
114 _mav_put_uint16_t(buf, 18, pending);
115 _mav_put_uint16_t(buf, 20, loaded);
117 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
118 #else
119 mavlink_terrain_report_t packet;
120 packet.lat = lat;
121 packet.lon = lon;
122 packet.terrain_height = terrain_height;
123 packet.current_height = current_height;
124 packet.spacing = spacing;
125 packet.pending = pending;
126 packet.loaded = loaded;
128 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
129 #endif
131 msg->msgid = MAVLINK_MSG_ID_TERRAIN_REPORT;
132 #if MAVLINK_CRC_EXTRA
133 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
134 #else
135 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
136 #endif
140 * @brief Encode a terrain_report struct
142 * @param system_id ID of this system
143 * @param component_id ID of this component (e.g. 200 for IMU)
144 * @param msg The MAVLink message to compress the data into
145 * @param terrain_report C-struct to read the message contents from
147 static inline uint16_t mavlink_msg_terrain_report_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_terrain_report_t* terrain_report)
149 return mavlink_msg_terrain_report_pack(system_id, component_id, msg, terrain_report->lat, terrain_report->lon, terrain_report->spacing, terrain_report->terrain_height, terrain_report->current_height, terrain_report->pending, terrain_report->loaded);
153 * @brief Encode a terrain_report struct on a channel
155 * @param system_id ID of this system
156 * @param component_id ID of this component (e.g. 200 for IMU)
157 * @param chan The MAVLink channel this message will be sent over
158 * @param msg The MAVLink message to compress the data into
159 * @param terrain_report C-struct to read the message contents from
161 static inline uint16_t mavlink_msg_terrain_report_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_terrain_report_t* terrain_report)
163 return mavlink_msg_terrain_report_pack_chan(system_id, component_id, chan, msg, terrain_report->lat, terrain_report->lon, terrain_report->spacing, terrain_report->terrain_height, terrain_report->current_height, terrain_report->pending, terrain_report->loaded);
167 * @brief Send a terrain_report message
168 * @param chan MAVLink channel to send the message
170 * @param lat Latitude (degrees *10^7)
171 * @param lon Longitude (degrees *10^7)
172 * @param spacing grid spacing (zero if terrain at this location unavailable)
173 * @param terrain_height Terrain height in meters AMSL
174 * @param current_height Current vehicle height above lat/lon terrain height (meters)
175 * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk
176 * @param loaded Number of 4x4 terrain blocks in memory
178 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
180 static inline void mavlink_msg_terrain_report_send(mavlink_channel_t chan, int32_t lat, int32_t lon, uint16_t spacing, float terrain_height, float current_height, uint16_t pending, uint16_t loaded)
182 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
183 char buf[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN];
184 _mav_put_int32_t(buf, 0, lat);
185 _mav_put_int32_t(buf, 4, lon);
186 _mav_put_float(buf, 8, terrain_height);
187 _mav_put_float(buf, 12, current_height);
188 _mav_put_uint16_t(buf, 16, spacing);
189 _mav_put_uint16_t(buf, 18, pending);
190 _mav_put_uint16_t(buf, 20, loaded);
192 #if MAVLINK_CRC_EXTRA
193 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
194 #else
195 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
196 #endif
197 #else
198 mavlink_terrain_report_t packet;
199 packet.lat = lat;
200 packet.lon = lon;
201 packet.terrain_height = terrain_height;
202 packet.current_height = current_height;
203 packet.spacing = spacing;
204 packet.pending = pending;
205 packet.loaded = loaded;
207 #if MAVLINK_CRC_EXTRA
208 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, (const char *)&packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
209 #else
210 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, (const char *)&packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
211 #endif
212 #endif
215 #if MAVLINK_MSG_ID_TERRAIN_REPORT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
217 This varient of _send() can be used to save stack space by re-using
218 memory from the receive buffer. The caller provides a
219 mavlink_message_t which is the size of a full mavlink message. This
220 is usually the receive buffer for the channel, and allows a reply to an
221 incoming message with minimum stack space usage.
223 static inline void mavlink_msg_terrain_report_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, int32_t lat, int32_t lon, uint16_t spacing, float terrain_height, float current_height, uint16_t pending, uint16_t loaded)
225 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
226 char *buf = (char *)msgbuf;
227 _mav_put_int32_t(buf, 0, lat);
228 _mav_put_int32_t(buf, 4, lon);
229 _mav_put_float(buf, 8, terrain_height);
230 _mav_put_float(buf, 12, current_height);
231 _mav_put_uint16_t(buf, 16, spacing);
232 _mav_put_uint16_t(buf, 18, pending);
233 _mav_put_uint16_t(buf, 20, loaded);
235 #if MAVLINK_CRC_EXTRA
236 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
237 #else
238 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
239 #endif
240 #else
241 mavlink_terrain_report_t *packet = (mavlink_terrain_report_t *)msgbuf;
242 packet->lat = lat;
243 packet->lon = lon;
244 packet->terrain_height = terrain_height;
245 packet->current_height = current_height;
246 packet->spacing = spacing;
247 packet->pending = pending;
248 packet->loaded = loaded;
250 #if MAVLINK_CRC_EXTRA
251 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, (const char *)packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
252 #else
253 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, (const char *)packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
254 #endif
255 #endif
257 #endif
259 #endif
261 // MESSAGE TERRAIN_REPORT UNPACKING
265 * @brief Get field lat from terrain_report message
267 * @return Latitude (degrees *10^7)
269 static inline int32_t mavlink_msg_terrain_report_get_lat(const mavlink_message_t* msg)
271 return _MAV_RETURN_int32_t(msg, 0);
275 * @brief Get field lon from terrain_report message
277 * @return Longitude (degrees *10^7)
279 static inline int32_t mavlink_msg_terrain_report_get_lon(const mavlink_message_t* msg)
281 return _MAV_RETURN_int32_t(msg, 4);
285 * @brief Get field spacing from terrain_report message
287 * @return grid spacing (zero if terrain at this location unavailable)
289 static inline uint16_t mavlink_msg_terrain_report_get_spacing(const mavlink_message_t* msg)
291 return _MAV_RETURN_uint16_t(msg, 16);
295 * @brief Get field terrain_height from terrain_report message
297 * @return Terrain height in meters AMSL
299 static inline float mavlink_msg_terrain_report_get_terrain_height(const mavlink_message_t* msg)
301 return _MAV_RETURN_float(msg, 8);
305 * @brief Get field current_height from terrain_report message
307 * @return Current vehicle height above lat/lon terrain height (meters)
309 static inline float mavlink_msg_terrain_report_get_current_height(const mavlink_message_t* msg)
311 return _MAV_RETURN_float(msg, 12);
315 * @brief Get field pending from terrain_report message
317 * @return Number of 4x4 terrain blocks waiting to be received or read from disk
319 static inline uint16_t mavlink_msg_terrain_report_get_pending(const mavlink_message_t* msg)
321 return _MAV_RETURN_uint16_t(msg, 18);
325 * @brief Get field loaded from terrain_report message
327 * @return Number of 4x4 terrain blocks in memory
329 static inline uint16_t mavlink_msg_terrain_report_get_loaded(const mavlink_message_t* msg)
331 return _MAV_RETURN_uint16_t(msg, 20);
335 * @brief Decode a terrain_report message into a struct
337 * @param msg The message to decode
338 * @param terrain_report C-struct to decode the message contents into
340 static inline void mavlink_msg_terrain_report_decode(const mavlink_message_t* msg, mavlink_terrain_report_t* terrain_report)
342 #if MAVLINK_NEED_BYTE_SWAP
343 terrain_report->lat = mavlink_msg_terrain_report_get_lat(msg);
344 terrain_report->lon = mavlink_msg_terrain_report_get_lon(msg);
345 terrain_report->terrain_height = mavlink_msg_terrain_report_get_terrain_height(msg);
346 terrain_report->current_height = mavlink_msg_terrain_report_get_current_height(msg);
347 terrain_report->spacing = mavlink_msg_terrain_report_get_spacing(msg);
348 terrain_report->pending = mavlink_msg_terrain_report_get_pending(msg);
349 terrain_report->loaded = mavlink_msg_terrain_report_get_loaded(msg);
350 #else
351 memcpy(terrain_report, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
352 #endif