2 // MESSAGE TERRAIN_REPORT PACKING
4 #define MAVLINK_MSG_ID_TERRAIN_REPORT 136
7 typedef struct __mavlink_terrain_report_t
{
8 int32_t lat
; /*< Latitude (degrees *10^7)*/
9 int32_t lon
; /*< Longitude (degrees *10^7)*/
10 float terrain_height
; /*< Terrain height in meters AMSL*/
11 float current_height
; /*< Current vehicle height above lat/lon terrain height (meters)*/
12 uint16_t spacing
; /*< grid spacing (zero if terrain at this location unavailable)*/
13 uint16_t pending
; /*< Number of 4x4 terrain blocks waiting to be received or read from disk*/
14 uint16_t loaded
; /*< Number of 4x4 terrain blocks in memory*/
15 }) mavlink_terrain_report_t
;
17 #define MAVLINK_MSG_ID_TERRAIN_REPORT_LEN 22
18 #define MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN 22
19 #define MAVLINK_MSG_ID_136_LEN 22
20 #define MAVLINK_MSG_ID_136_MIN_LEN 22
22 #define MAVLINK_MSG_ID_TERRAIN_REPORT_CRC 1
23 #define MAVLINK_MSG_ID_136_CRC 1
27 #if MAVLINK_COMMAND_24BIT
28 #define MAVLINK_MESSAGE_INFO_TERRAIN_REPORT { \
32 { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_report_t, lat) }, \
33 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_report_t, lon) }, \
34 { "terrain_height", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_terrain_report_t, terrain_height) }, \
35 { "current_height", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_terrain_report_t, current_height) }, \
36 { "spacing", NULL, MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_terrain_report_t, spacing) }, \
37 { "pending", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_terrain_report_t, pending) }, \
38 { "loaded", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_terrain_report_t, loaded) }, \
42 #define MAVLINK_MESSAGE_INFO_TERRAIN_REPORT { \
45 { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_report_t, lat) }, \
46 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_report_t, lon) }, \
47 { "terrain_height", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_terrain_report_t, terrain_height) }, \
48 { "current_height", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_terrain_report_t, current_height) }, \
49 { "spacing", NULL, MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_terrain_report_t, spacing) }, \
50 { "pending", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_terrain_report_t, pending) }, \
51 { "loaded", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_terrain_report_t, loaded) }, \
57 * @brief Pack a terrain_report message
58 * @param system_id ID of this system
59 * @param component_id ID of this component (e.g. 200 for IMU)
60 * @param msg The MAVLink message to compress the data into
62 * @param lat Latitude (degrees *10^7)
63 * @param lon Longitude (degrees *10^7)
64 * @param spacing grid spacing (zero if terrain at this location unavailable)
65 * @param terrain_height Terrain height in meters AMSL
66 * @param current_height Current vehicle height above lat/lon terrain height (meters)
67 * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk
68 * @param loaded Number of 4x4 terrain blocks in memory
69 * @return length of the message in bytes (excluding serial stream start sign)
71 static inline uint16_t mavlink_msg_terrain_report_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
,
72 int32_t lat
, int32_t lon
, uint16_t spacing
, float terrain_height
, float current_height
, uint16_t pending
, uint16_t loaded
)
74 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
75 char buf
[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
];
76 _mav_put_int32_t(buf
, 0, lat
);
77 _mav_put_int32_t(buf
, 4, lon
);
78 _mav_put_float(buf
, 8, terrain_height
);
79 _mav_put_float(buf
, 12, current_height
);
80 _mav_put_uint16_t(buf
, 16, spacing
);
81 _mav_put_uint16_t(buf
, 18, pending
);
82 _mav_put_uint16_t(buf
, 20, loaded
);
84 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
);
86 mavlink_terrain_report_t packet
;
89 packet
.terrain_height
= terrain_height
;
90 packet
.current_height
= current_height
;
91 packet
.spacing
= spacing
;
92 packet
.pending
= pending
;
93 packet
.loaded
= loaded
;
95 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
);
98 msg
->msgid
= MAVLINK_MSG_ID_TERRAIN_REPORT
;
99 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC
);
103 * @brief Pack a terrain_report message on a channel
104 * @param system_id ID of this system
105 * @param component_id ID of this component (e.g. 200 for IMU)
106 * @param chan The MAVLink channel this message will be sent over
107 * @param msg The MAVLink message to compress the data into
108 * @param lat Latitude (degrees *10^7)
109 * @param lon Longitude (degrees *10^7)
110 * @param spacing grid spacing (zero if terrain at this location unavailable)
111 * @param terrain_height Terrain height in meters AMSL
112 * @param current_height Current vehicle height above lat/lon terrain height (meters)
113 * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk
114 * @param loaded Number of 4x4 terrain blocks in memory
115 * @return length of the message in bytes (excluding serial stream start sign)
117 static inline uint16_t mavlink_msg_terrain_report_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
118 mavlink_message_t
* msg
,
119 int32_t lat
,int32_t lon
,uint16_t spacing
,float terrain_height
,float current_height
,uint16_t pending
,uint16_t loaded
)
121 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
122 char buf
[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
];
123 _mav_put_int32_t(buf
, 0, lat
);
124 _mav_put_int32_t(buf
, 4, lon
);
125 _mav_put_float(buf
, 8, terrain_height
);
126 _mav_put_float(buf
, 12, current_height
);
127 _mav_put_uint16_t(buf
, 16, spacing
);
128 _mav_put_uint16_t(buf
, 18, pending
);
129 _mav_put_uint16_t(buf
, 20, loaded
);
131 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
);
133 mavlink_terrain_report_t packet
;
136 packet
.terrain_height
= terrain_height
;
137 packet
.current_height
= current_height
;
138 packet
.spacing
= spacing
;
139 packet
.pending
= pending
;
140 packet
.loaded
= loaded
;
142 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
);
145 msg
->msgid
= MAVLINK_MSG_ID_TERRAIN_REPORT
;
146 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC
);
150 * @brief Encode a terrain_report struct
152 * @param system_id ID of this system
153 * @param component_id ID of this component (e.g. 200 for IMU)
154 * @param msg The MAVLink message to compress the data into
155 * @param terrain_report C-struct to read the message contents from
157 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
)
159 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
);
163 * @brief Encode a terrain_report struct on a channel
165 * @param system_id ID of this system
166 * @param component_id ID of this component (e.g. 200 for IMU)
167 * @param chan The MAVLink channel this message will be sent over
168 * @param msg The MAVLink message to compress the data into
169 * @param terrain_report C-struct to read the message contents from
171 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
)
173 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
);
177 * @brief Send a terrain_report message
178 * @param chan MAVLink channel to send the message
180 * @param lat Latitude (degrees *10^7)
181 * @param lon Longitude (degrees *10^7)
182 * @param spacing grid spacing (zero if terrain at this location unavailable)
183 * @param terrain_height Terrain height in meters AMSL
184 * @param current_height Current vehicle height above lat/lon terrain height (meters)
185 * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk
186 * @param loaded Number of 4x4 terrain blocks in memory
188 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
190 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
)
192 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193 char buf
[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
];
194 _mav_put_int32_t(buf
, 0, lat
);
195 _mav_put_int32_t(buf
, 4, lon
);
196 _mav_put_float(buf
, 8, terrain_height
);
197 _mav_put_float(buf
, 12, current_height
);
198 _mav_put_uint16_t(buf
, 16, spacing
);
199 _mav_put_uint16_t(buf
, 18, pending
);
200 _mav_put_uint16_t(buf
, 20, loaded
);
202 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_TERRAIN_REPORT
, buf
, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC
);
204 mavlink_terrain_report_t packet
;
207 packet
.terrain_height
= terrain_height
;
208 packet
.current_height
= current_height
;
209 packet
.spacing
= spacing
;
210 packet
.pending
= pending
;
211 packet
.loaded
= loaded
;
213 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_TERRAIN_REPORT
, (const char *)&packet
, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC
);
218 * @brief Send a terrain_report message
219 * @param chan MAVLink channel to send the message
220 * @param struct The MAVLink struct to serialize
222 static inline void mavlink_msg_terrain_report_send_struct(mavlink_channel_t chan
, const mavlink_terrain_report_t
* terrain_report
)
224 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
225 mavlink_msg_terrain_report_send(chan
, terrain_report
->lat
, terrain_report
->lon
, terrain_report
->spacing
, terrain_report
->terrain_height
, terrain_report
->current_height
, terrain_report
->pending
, terrain_report
->loaded
);
227 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_TERRAIN_REPORT
, (const char *)terrain_report
, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC
);
231 #if MAVLINK_MSG_ID_TERRAIN_REPORT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
233 This varient of _send() can be used to save stack space by re-using
234 memory from the receive buffer. The caller provides a
235 mavlink_message_t which is the size of a full mavlink message. This
236 is usually the receive buffer for the channel, and allows a reply to an
237 incoming message with minimum stack space usage.
239 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
)
241 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
242 char *buf
= (char *)msgbuf
;
243 _mav_put_int32_t(buf
, 0, lat
);
244 _mav_put_int32_t(buf
, 4, lon
);
245 _mav_put_float(buf
, 8, terrain_height
);
246 _mav_put_float(buf
, 12, current_height
);
247 _mav_put_uint16_t(buf
, 16, spacing
);
248 _mav_put_uint16_t(buf
, 18, pending
);
249 _mav_put_uint16_t(buf
, 20, loaded
);
251 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_TERRAIN_REPORT
, buf
, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC
);
253 mavlink_terrain_report_t
*packet
= (mavlink_terrain_report_t
*)msgbuf
;
256 packet
->terrain_height
= terrain_height
;
257 packet
->current_height
= current_height
;
258 packet
->spacing
= spacing
;
259 packet
->pending
= pending
;
260 packet
->loaded
= loaded
;
262 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_TERRAIN_REPORT
, (const char *)packet
, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC
);
269 // MESSAGE TERRAIN_REPORT UNPACKING
273 * @brief Get field lat from terrain_report message
275 * @return Latitude (degrees *10^7)
277 static inline int32_t mavlink_msg_terrain_report_get_lat(const mavlink_message_t
* msg
)
279 return _MAV_RETURN_int32_t(msg
, 0);
283 * @brief Get field lon from terrain_report message
285 * @return Longitude (degrees *10^7)
287 static inline int32_t mavlink_msg_terrain_report_get_lon(const mavlink_message_t
* msg
)
289 return _MAV_RETURN_int32_t(msg
, 4);
293 * @brief Get field spacing from terrain_report message
295 * @return grid spacing (zero if terrain at this location unavailable)
297 static inline uint16_t mavlink_msg_terrain_report_get_spacing(const mavlink_message_t
* msg
)
299 return _MAV_RETURN_uint16_t(msg
, 16);
303 * @brief Get field terrain_height from terrain_report message
305 * @return Terrain height in meters AMSL
307 static inline float mavlink_msg_terrain_report_get_terrain_height(const mavlink_message_t
* msg
)
309 return _MAV_RETURN_float(msg
, 8);
313 * @brief Get field current_height from terrain_report message
315 * @return Current vehicle height above lat/lon terrain height (meters)
317 static inline float mavlink_msg_terrain_report_get_current_height(const mavlink_message_t
* msg
)
319 return _MAV_RETURN_float(msg
, 12);
323 * @brief Get field pending from terrain_report message
325 * @return Number of 4x4 terrain blocks waiting to be received or read from disk
327 static inline uint16_t mavlink_msg_terrain_report_get_pending(const mavlink_message_t
* msg
)
329 return _MAV_RETURN_uint16_t(msg
, 18);
333 * @brief Get field loaded from terrain_report message
335 * @return Number of 4x4 terrain blocks in memory
337 static inline uint16_t mavlink_msg_terrain_report_get_loaded(const mavlink_message_t
* msg
)
339 return _MAV_RETURN_uint16_t(msg
, 20);
343 * @brief Decode a terrain_report message into a struct
345 * @param msg The message to decode
346 * @param terrain_report C-struct to decode the message contents into
348 static inline void mavlink_msg_terrain_report_decode(const mavlink_message_t
* msg
, mavlink_terrain_report_t
* terrain_report
)
350 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
351 terrain_report
->lat
= mavlink_msg_terrain_report_get_lat(msg
);
352 terrain_report
->lon
= mavlink_msg_terrain_report_get_lon(msg
);
353 terrain_report
->terrain_height
= mavlink_msg_terrain_report_get_terrain_height(msg
);
354 terrain_report
->current_height
= mavlink_msg_terrain_report_get_current_height(msg
);
355 terrain_report
->spacing
= mavlink_msg_terrain_report_get_spacing(msg
);
356 terrain_report
->pending
= mavlink_msg_terrain_report_get_pending(msg
);
357 terrain_report
->loaded
= mavlink_msg_terrain_report_get_loaded(msg
);
359 uint8_t len
= msg
->len
< MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
? msg
->len
: MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
;
360 memset(terrain_report
, 0, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN
);
361 memcpy(terrain_report
, _MAV_PAYLOAD(msg
), len
);