1 // MESSAGE VFR_HUD PACKING
3 #define MAVLINK_MSG_ID_VFR_HUD 74
5 typedef struct __mavlink_vfr_hud_t
7 float airspeed
; ///< Current airspeed in m/s
8 float groundspeed
; ///< Current ground speed in m/s
9 float alt
; ///< Current altitude (MSL), in meters
10 float climb
; ///< Current climb rate in meters/second
11 int16_t heading
; ///< Current heading in degrees, in compass units (0..360, 0=north)
12 uint16_t throttle
; ///< Current throttle setting in integer percent, 0 to 100
15 #define MAVLINK_MSG_ID_VFR_HUD_LEN 20
16 #define MAVLINK_MSG_ID_74_LEN 20
18 #define MAVLINK_MSG_ID_VFR_HUD_CRC 20
19 #define MAVLINK_MSG_ID_74_CRC 20
23 #define MAVLINK_MESSAGE_INFO_VFR_HUD { \
26 { { "airspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_vfr_hud_t, airspeed) }, \
27 { "groundspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_vfr_hud_t, groundspeed) }, \
28 { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_vfr_hud_t, alt) }, \
29 { "climb", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_vfr_hud_t, climb) }, \
30 { "heading", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_vfr_hud_t, heading) }, \
31 { "throttle", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_vfr_hud_t, throttle) }, \
37 * @brief Pack a vfr_hud message
38 * @param system_id ID of this system
39 * @param component_id ID of this component (e.g. 200 for IMU)
40 * @param msg The MAVLink message to compress the data into
42 * @param airspeed Current airspeed in m/s
43 * @param groundspeed Current ground speed in m/s
44 * @param heading Current heading in degrees, in compass units (0..360, 0=north)
45 * @param throttle Current throttle setting in integer percent, 0 to 100
46 * @param alt Current altitude (MSL), in meters
47 * @param climb Current climb rate in meters/second
48 * @return length of the message in bytes (excluding serial stream start sign)
50 static inline uint16_t mavlink_msg_vfr_hud_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
,
51 float airspeed
, float groundspeed
, int16_t heading
, uint16_t throttle
, float alt
, float climb
)
53 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
54 char buf
[MAVLINK_MSG_ID_VFR_HUD_LEN
];
55 _mav_put_float(buf
, 0, airspeed
);
56 _mav_put_float(buf
, 4, groundspeed
);
57 _mav_put_float(buf
, 8, alt
);
58 _mav_put_float(buf
, 12, climb
);
59 _mav_put_int16_t(buf
, 16, heading
);
60 _mav_put_uint16_t(buf
, 18, throttle
);
62 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_VFR_HUD_LEN
);
64 mavlink_vfr_hud_t packet
;
65 packet
.airspeed
= airspeed
;
66 packet
.groundspeed
= groundspeed
;
69 packet
.heading
= heading
;
70 packet
.throttle
= throttle
;
72 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_VFR_HUD_LEN
);
75 msg
->msgid
= MAVLINK_MSG_ID_VFR_HUD
;
77 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_VFR_HUD_LEN
, MAVLINK_MSG_ID_VFR_HUD_CRC
);
79 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_VFR_HUD_LEN
);
84 * @brief Pack a vfr_hud message on a channel
85 * @param system_id ID of this system
86 * @param component_id ID of this component (e.g. 200 for IMU)
87 * @param chan The MAVLink channel this message will be sent over
88 * @param msg The MAVLink message to compress the data into
89 * @param airspeed Current airspeed in m/s
90 * @param groundspeed Current ground speed in m/s
91 * @param heading Current heading in degrees, in compass units (0..360, 0=north)
92 * @param throttle Current throttle setting in integer percent, 0 to 100
93 * @param alt Current altitude (MSL), in meters
94 * @param climb Current climb rate in meters/second
95 * @return length of the message in bytes (excluding serial stream start sign)
97 static inline uint16_t mavlink_msg_vfr_hud_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
98 mavlink_message_t
* msg
,
99 float airspeed
,float groundspeed
,int16_t heading
,uint16_t throttle
,float alt
,float climb
)
101 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
102 char buf
[MAVLINK_MSG_ID_VFR_HUD_LEN
];
103 _mav_put_float(buf
, 0, airspeed
);
104 _mav_put_float(buf
, 4, groundspeed
);
105 _mav_put_float(buf
, 8, alt
);
106 _mav_put_float(buf
, 12, climb
);
107 _mav_put_int16_t(buf
, 16, heading
);
108 _mav_put_uint16_t(buf
, 18, throttle
);
110 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_VFR_HUD_LEN
);
112 mavlink_vfr_hud_t packet
;
113 packet
.airspeed
= airspeed
;
114 packet
.groundspeed
= groundspeed
;
116 packet
.climb
= climb
;
117 packet
.heading
= heading
;
118 packet
.throttle
= throttle
;
120 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_VFR_HUD_LEN
);
123 msg
->msgid
= MAVLINK_MSG_ID_VFR_HUD
;
124 #if MAVLINK_CRC_EXTRA
125 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_VFR_HUD_LEN
, MAVLINK_MSG_ID_VFR_HUD_CRC
);
127 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_VFR_HUD_LEN
);
132 * @brief Encode a vfr_hud struct
134 * @param system_id ID of this system
135 * @param component_id ID of this component (e.g. 200 for IMU)
136 * @param msg The MAVLink message to compress the data into
137 * @param vfr_hud C-struct to read the message contents from
139 static inline uint16_t mavlink_msg_vfr_hud_encode(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
, const mavlink_vfr_hud_t
* vfr_hud
)
141 return mavlink_msg_vfr_hud_pack(system_id
, component_id
, msg
, vfr_hud
->airspeed
, vfr_hud
->groundspeed
, vfr_hud
->heading
, vfr_hud
->throttle
, vfr_hud
->alt
, vfr_hud
->climb
);
145 * @brief Encode a vfr_hud struct on a channel
147 * @param system_id ID of this system
148 * @param component_id ID of this component (e.g. 200 for IMU)
149 * @param chan The MAVLink channel this message will be sent over
150 * @param msg The MAVLink message to compress the data into
151 * @param vfr_hud C-struct to read the message contents from
153 static inline uint16_t mavlink_msg_vfr_hud_encode_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
, mavlink_message_t
* msg
, const mavlink_vfr_hud_t
* vfr_hud
)
155 return mavlink_msg_vfr_hud_pack_chan(system_id
, component_id
, chan
, msg
, vfr_hud
->airspeed
, vfr_hud
->groundspeed
, vfr_hud
->heading
, vfr_hud
->throttle
, vfr_hud
->alt
, vfr_hud
->climb
);
159 * @brief Send a vfr_hud message
160 * @param chan MAVLink channel to send the message
162 * @param airspeed Current airspeed in m/s
163 * @param groundspeed Current ground speed in m/s
164 * @param heading Current heading in degrees, in compass units (0..360, 0=north)
165 * @param throttle Current throttle setting in integer percent, 0 to 100
166 * @param alt Current altitude (MSL), in meters
167 * @param climb Current climb rate in meters/second
169 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
171 static inline void mavlink_msg_vfr_hud_send(mavlink_channel_t chan
, float airspeed
, float groundspeed
, int16_t heading
, uint16_t throttle
, float alt
, float climb
)
173 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
174 char buf
[MAVLINK_MSG_ID_VFR_HUD_LEN
];
175 _mav_put_float(buf
, 0, airspeed
);
176 _mav_put_float(buf
, 4, groundspeed
);
177 _mav_put_float(buf
, 8, alt
);
178 _mav_put_float(buf
, 12, climb
);
179 _mav_put_int16_t(buf
, 16, heading
);
180 _mav_put_uint16_t(buf
, 18, throttle
);
182 #if MAVLINK_CRC_EXTRA
183 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_VFR_HUD
, buf
, MAVLINK_MSG_ID_VFR_HUD_LEN
, MAVLINK_MSG_ID_VFR_HUD_CRC
);
185 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_VFR_HUD
, buf
, MAVLINK_MSG_ID_VFR_HUD_LEN
);
188 mavlink_vfr_hud_t packet
;
189 packet
.airspeed
= airspeed
;
190 packet
.groundspeed
= groundspeed
;
192 packet
.climb
= climb
;
193 packet
.heading
= heading
;
194 packet
.throttle
= throttle
;
196 #if MAVLINK_CRC_EXTRA
197 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_VFR_HUD
, (const char *)&packet
, MAVLINK_MSG_ID_VFR_HUD_LEN
, MAVLINK_MSG_ID_VFR_HUD_CRC
);
199 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_VFR_HUD
, (const char *)&packet
, MAVLINK_MSG_ID_VFR_HUD_LEN
);
204 #if MAVLINK_MSG_ID_VFR_HUD_LEN <= MAVLINK_MAX_PAYLOAD_LEN
206 This varient of _send() can be used to save stack space by re-using
207 memory from the receive buffer. The caller provides a
208 mavlink_message_t which is the size of a full mavlink message. This
209 is usually the receive buffer for the channel, and allows a reply to an
210 incoming message with minimum stack space usage.
212 static inline void mavlink_msg_vfr_hud_send_buf(mavlink_message_t
*msgbuf
, mavlink_channel_t chan
, float airspeed
, float groundspeed
, int16_t heading
, uint16_t throttle
, float alt
, float climb
)
214 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
215 char *buf
= (char *)msgbuf
;
216 _mav_put_float(buf
, 0, airspeed
);
217 _mav_put_float(buf
, 4, groundspeed
);
218 _mav_put_float(buf
, 8, alt
);
219 _mav_put_float(buf
, 12, climb
);
220 _mav_put_int16_t(buf
, 16, heading
);
221 _mav_put_uint16_t(buf
, 18, throttle
);
223 #if MAVLINK_CRC_EXTRA
224 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_VFR_HUD
, buf
, MAVLINK_MSG_ID_VFR_HUD_LEN
, MAVLINK_MSG_ID_VFR_HUD_CRC
);
226 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_VFR_HUD
, buf
, MAVLINK_MSG_ID_VFR_HUD_LEN
);
229 mavlink_vfr_hud_t
*packet
= (mavlink_vfr_hud_t
*)msgbuf
;
230 packet
->airspeed
= airspeed
;
231 packet
->groundspeed
= groundspeed
;
233 packet
->climb
= climb
;
234 packet
->heading
= heading
;
235 packet
->throttle
= throttle
;
237 #if MAVLINK_CRC_EXTRA
238 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_VFR_HUD
, (const char *)packet
, MAVLINK_MSG_ID_VFR_HUD_LEN
, MAVLINK_MSG_ID_VFR_HUD_CRC
);
240 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_VFR_HUD
, (const char *)packet
, MAVLINK_MSG_ID_VFR_HUD_LEN
);
248 // MESSAGE VFR_HUD UNPACKING
252 * @brief Get field airspeed from vfr_hud message
254 * @return Current airspeed in m/s
256 static inline float mavlink_msg_vfr_hud_get_airspeed(const mavlink_message_t
* msg
)
258 return _MAV_RETURN_float(msg
, 0);
262 * @brief Get field groundspeed from vfr_hud message
264 * @return Current ground speed in m/s
266 static inline float mavlink_msg_vfr_hud_get_groundspeed(const mavlink_message_t
* msg
)
268 return _MAV_RETURN_float(msg
, 4);
272 * @brief Get field heading from vfr_hud message
274 * @return Current heading in degrees, in compass units (0..360, 0=north)
276 static inline int16_t mavlink_msg_vfr_hud_get_heading(const mavlink_message_t
* msg
)
278 return _MAV_RETURN_int16_t(msg
, 16);
282 * @brief Get field throttle from vfr_hud message
284 * @return Current throttle setting in integer percent, 0 to 100
286 static inline uint16_t mavlink_msg_vfr_hud_get_throttle(const mavlink_message_t
* msg
)
288 return _MAV_RETURN_uint16_t(msg
, 18);
292 * @brief Get field alt from vfr_hud message
294 * @return Current altitude (MSL), in meters
296 static inline float mavlink_msg_vfr_hud_get_alt(const mavlink_message_t
* msg
)
298 return _MAV_RETURN_float(msg
, 8);
302 * @brief Get field climb from vfr_hud message
304 * @return Current climb rate in meters/second
306 static inline float mavlink_msg_vfr_hud_get_climb(const mavlink_message_t
* msg
)
308 return _MAV_RETURN_float(msg
, 12);
312 * @brief Decode a vfr_hud message into a struct
314 * @param msg The message to decode
315 * @param vfr_hud C-struct to decode the message contents into
317 static inline void mavlink_msg_vfr_hud_decode(const mavlink_message_t
* msg
, mavlink_vfr_hud_t
* vfr_hud
)
319 #if MAVLINK_NEED_BYTE_SWAP
320 vfr_hud
->airspeed
= mavlink_msg_vfr_hud_get_airspeed(msg
);
321 vfr_hud
->groundspeed
= mavlink_msg_vfr_hud_get_groundspeed(msg
);
322 vfr_hud
->alt
= mavlink_msg_vfr_hud_get_alt(msg
);
323 vfr_hud
->climb
= mavlink_msg_vfr_hud_get_climb(msg
);
324 vfr_hud
->heading
= mavlink_msg_vfr_hud_get_heading(msg
);
325 vfr_hud
->throttle
= mavlink_msg_vfr_hud_get_throttle(msg
);
327 memcpy(vfr_hud
, _MAV_PAYLOAD(msg
), MAVLINK_MSG_ID_VFR_HUD_LEN
);