close Warning: Can't use blame annotator:
svn blame failed on branches/mavlink/tools/Controller/Mavlink/src/include/common/mavlink_msg_heartbeat.h: 200029 - Couldn't perform atomic initialization

source: flair-src/branches/mavlink/tools/Controller/Mavlink/src/include/common/mavlink_msg_heartbeat.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: 13.7 KB
RevLine 
1// MESSAGE HEARTBEAT PACKING
2
3#define MAVLINK_MSG_ID_HEARTBEAT 0
4
5typedef struct MAVLINK_PACKED __mavlink_heartbeat_t
6{
7 uint32_t custom_mode; /*< A bitfield for use for autopilot-specific flags.*/
8 uint8_t type; /*< Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM)*/
9 uint8_t autopilot; /*< Autopilot type / class. defined in MAV_AUTOPILOT ENUM*/
10 uint8_t base_mode; /*< System mode bitfield, see MAV_MODE_FLAG ENUM in mavlink/include/mavlink_types.h*/
11 uint8_t system_status; /*< System status flag, see MAV_STATE ENUM*/
12 uint8_t mavlink_version; /*< MAVLink version, not writable by user, gets added by protocol because of magic data type: uint8_t_mavlink_version*/
13} mavlink_heartbeat_t;
14
15#define MAVLINK_MSG_ID_HEARTBEAT_LEN 9
16#define MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN 9
17#define MAVLINK_MSG_ID_0_LEN 9
18#define MAVLINK_MSG_ID_0_MIN_LEN 9
19
20#define MAVLINK_MSG_ID_HEARTBEAT_CRC 50
21#define MAVLINK_MSG_ID_0_CRC 50
22
23
24
25#if MAVLINK_COMMAND_24BIT
26#define MAVLINK_MESSAGE_INFO_HEARTBEAT { \
27 0, \
28 "HEARTBEAT", \
29 6, \
30 { { "custom_mode", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_heartbeat_t, custom_mode) }, \
31 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_heartbeat_t, type) }, \
32 { "autopilot", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_heartbeat_t, autopilot) }, \
33 { "base_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_heartbeat_t, base_mode) }, \
34 { "system_status", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_heartbeat_t, system_status) }, \
35 { "mavlink_version", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_heartbeat_t, mavlink_version) }, \
36 } \
37}
38#else
39#define MAVLINK_MESSAGE_INFO_HEARTBEAT { \
40 "HEARTBEAT", \
41 6, \
42 { { "custom_mode", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_heartbeat_t, custom_mode) }, \
43 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_heartbeat_t, type) }, \
44 { "autopilot", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_heartbeat_t, autopilot) }, \
45 { "base_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_heartbeat_t, base_mode) }, \
46 { "system_status", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_heartbeat_t, system_status) }, \
47 { "mavlink_version", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_heartbeat_t, mavlink_version) }, \
48 } \
49}
50#endif
51
52/**
53 * @brief Pack a heartbeat message
54 * @param system_id ID of this system
55 * @param component_id ID of this component (e.g. 200 for IMU)
56 * @param msg The MAVLink message to compress the data into
57 *
58 * @param type Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM)
59 * @param autopilot Autopilot type / class. defined in MAV_AUTOPILOT ENUM
60 * @param base_mode System mode bitfield, see MAV_MODE_FLAG ENUM in mavlink/include/mavlink_types.h
61 * @param custom_mode A bitfield for use for autopilot-specific flags.
62 * @param system_status System status flag, see MAV_STATE ENUM
63 * @return length of the message in bytes (excluding serial stream start sign)
64 */
65static inline uint16_t mavlink_msg_heartbeat_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
66 uint8_t type, uint8_t autopilot, uint8_t base_mode, uint32_t custom_mode, uint8_t system_status)
67{
68#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
69 char buf[MAVLINK_MSG_ID_HEARTBEAT_LEN];
70 _mav_put_uint32_t(buf, 0, custom_mode);
71 _mav_put_uint8_t(buf, 4, type);
72 _mav_put_uint8_t(buf, 5, autopilot);
73 _mav_put_uint8_t(buf, 6, base_mode);
74 _mav_put_uint8_t(buf, 7, system_status);
75 _mav_put_uint8_t(buf, 8, 3);
76
77 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HEARTBEAT_LEN);
78#else
79 mavlink_heartbeat_t packet;
80 packet.custom_mode = custom_mode;
81 packet.type = type;
82 packet.autopilot = autopilot;
83 packet.base_mode = base_mode;
84 packet.system_status = system_status;
85 packet.mavlink_version = 3;
86
87 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HEARTBEAT_LEN);
88#endif
89
90 msg->msgid = MAVLINK_MSG_ID_HEARTBEAT;
91 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC);
92}
93
94/**
95 * @brief Pack a heartbeat message on a channel
96 * @param system_id ID of this system
97 * @param component_id ID of this component (e.g. 200 for IMU)
98 * @param chan The MAVLink channel this message will be sent over
99 * @param msg The MAVLink message to compress the data into
100 * @param type Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM)
101 * @param autopilot Autopilot type / class. defined in MAV_AUTOPILOT ENUM
102 * @param base_mode System mode bitfield, see MAV_MODE_FLAG ENUM in mavlink/include/mavlink_types.h
103 * @param custom_mode A bitfield for use for autopilot-specific flags.
104 * @param system_status System status flag, see MAV_STATE ENUM
105 * @return length of the message in bytes (excluding serial stream start sign)
106 */
107static inline uint16_t mavlink_msg_heartbeat_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
108 mavlink_message_t* msg,
109 uint8_t type,uint8_t autopilot,uint8_t base_mode,uint32_t custom_mode,uint8_t system_status)
110{
111#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
112 char buf[MAVLINK_MSG_ID_HEARTBEAT_LEN];
113 _mav_put_uint32_t(buf, 0, custom_mode);
114 _mav_put_uint8_t(buf, 4, type);
115 _mav_put_uint8_t(buf, 5, autopilot);
116 _mav_put_uint8_t(buf, 6, base_mode);
117 _mav_put_uint8_t(buf, 7, system_status);
118 _mav_put_uint8_t(buf, 8, 3);
119
120 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HEARTBEAT_LEN);
121#else
122 mavlink_heartbeat_t packet;
123 packet.custom_mode = custom_mode;
124 packet.type = type;
125 packet.autopilot = autopilot;
126 packet.base_mode = base_mode;
127 packet.system_status = system_status;
128 packet.mavlink_version = 3;
129
130 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HEARTBEAT_LEN);
131#endif
132
133 msg->msgid = MAVLINK_MSG_ID_HEARTBEAT;
134 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC);
135}
136
137/**
138 * @brief Encode a heartbeat struct
139 *
140 * @param system_id ID of this system
141 * @param component_id ID of this component (e.g. 200 for IMU)
142 * @param msg The MAVLink message to compress the data into
143 * @param heartbeat C-struct to read the message contents from
144 */
145static inline uint16_t mavlink_msg_heartbeat_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_heartbeat_t* heartbeat)
146{
147 return mavlink_msg_heartbeat_pack(system_id, component_id, msg, heartbeat->type, heartbeat->autopilot, heartbeat->base_mode, heartbeat->custom_mode, heartbeat->system_status);
148}
149
150/**
151 * @brief Encode a heartbeat struct on a channel
152 *
153 * @param system_id ID of this system
154 * @param component_id ID of this component (e.g. 200 for IMU)
155 * @param chan The MAVLink channel this message will be sent over
156 * @param msg The MAVLink message to compress the data into
157 * @param heartbeat C-struct to read the message contents from
158 */
159static inline uint16_t mavlink_msg_heartbeat_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_heartbeat_t* heartbeat)
160{
161 return mavlink_msg_heartbeat_pack_chan(system_id, component_id, chan, msg, heartbeat->type, heartbeat->autopilot, heartbeat->base_mode, heartbeat->custom_mode, heartbeat->system_status);
162}
163
164/**
165 * @brief Send a heartbeat message
166 * @param chan MAVLink channel to send the message
167 *
168 * @param type Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM)
169 * @param autopilot Autopilot type / class. defined in MAV_AUTOPILOT ENUM
170 * @param base_mode System mode bitfield, see MAV_MODE_FLAG ENUM in mavlink/include/mavlink_types.h
171 * @param custom_mode A bitfield for use for autopilot-specific flags.
172 * @param system_status System status flag, see MAV_STATE ENUM
173 */
174#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
175
176static inline void mavlink_msg_heartbeat_send(mavlink_channel_t chan, uint8_t type, uint8_t autopilot, uint8_t base_mode, uint32_t custom_mode, uint8_t system_status)
177{
178#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
179 char buf[MAVLINK_MSG_ID_HEARTBEAT_LEN];
180 _mav_put_uint32_t(buf, 0, custom_mode);
181 _mav_put_uint8_t(buf, 4, type);
182 _mav_put_uint8_t(buf, 5, autopilot);
183 _mav_put_uint8_t(buf, 6, base_mode);
184 _mav_put_uint8_t(buf, 7, system_status);
185 _mav_put_uint8_t(buf, 8, 3);
186
187 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HEARTBEAT, buf, MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC);
188#else
189 mavlink_heartbeat_t packet;
190 packet.custom_mode = custom_mode;
191 packet.type = type;
192 packet.autopilot = autopilot;
193 packet.base_mode = base_mode;
194 packet.system_status = system_status;
195 packet.mavlink_version = 3;
196
197 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HEARTBEAT, (const char *)&packet, MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC);
198#endif
199}
200
201/**
202 * @brief Send a heartbeat message
203 * @param chan MAVLink channel to send the message
204 * @param struct The MAVLink struct to serialize
205 */
206static inline void mavlink_msg_heartbeat_send_struct(mavlink_channel_t chan, const mavlink_heartbeat_t* heartbeat)
207{
208#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
209 mavlink_msg_heartbeat_send(chan, heartbeat->type, heartbeat->autopilot, heartbeat->base_mode, heartbeat->custom_mode, heartbeat->system_status);
210#else
211 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HEARTBEAT, (const char *)heartbeat, MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC);
212#endif
213}
214
215#if MAVLINK_MSG_ID_HEARTBEAT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
216/*
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.
222 */
223static inline void mavlink_msg_heartbeat_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t type, uint8_t autopilot, uint8_t base_mode, uint32_t custom_mode, uint8_t system_status)
224{
225#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
226 char *buf = (char *)msgbuf;
227 _mav_put_uint32_t(buf, 0, custom_mode);
228 _mav_put_uint8_t(buf, 4, type);
229 _mav_put_uint8_t(buf, 5, autopilot);
230 _mav_put_uint8_t(buf, 6, base_mode);
231 _mav_put_uint8_t(buf, 7, system_status);
232 _mav_put_uint8_t(buf, 8, 3);
233
234 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HEARTBEAT, buf, MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC);
235#else
236 mavlink_heartbeat_t *packet = (mavlink_heartbeat_t *)msgbuf;
237 packet->custom_mode = custom_mode;
238 packet->type = type;
239 packet->autopilot = autopilot;
240 packet->base_mode = base_mode;
241 packet->system_status = system_status;
242 packet->mavlink_version = 3;
243
244 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HEARTBEAT, (const char *)packet, MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC);
245#endif
246}
247#endif
248
249#endif
250
251// MESSAGE HEARTBEAT UNPACKING
252
253
254/**
255 * @brief Get field type from heartbeat message
256 *
257 * @return Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM)
258 */
259static inline uint8_t mavlink_msg_heartbeat_get_type(const mavlink_message_t* msg)
260{
261 return _MAV_RETURN_uint8_t(msg, 4);
262}
263
264/**
265 * @brief Get field autopilot from heartbeat message
266 *
267 * @return Autopilot type / class. defined in MAV_AUTOPILOT ENUM
268 */
269static inline uint8_t mavlink_msg_heartbeat_get_autopilot(const mavlink_message_t* msg)
270{
271 return _MAV_RETURN_uint8_t(msg, 5);
272}
273
274/**
275 * @brief Get field base_mode from heartbeat message
276 *
277 * @return System mode bitfield, see MAV_MODE_FLAG ENUM in mavlink/include/mavlink_types.h
278 */
279static inline uint8_t mavlink_msg_heartbeat_get_base_mode(const mavlink_message_t* msg)
280{
281 return _MAV_RETURN_uint8_t(msg, 6);
282}
283
284/**
285 * @brief Get field custom_mode from heartbeat message
286 *
287 * @return A bitfield for use for autopilot-specific flags.
288 */
289static inline uint32_t mavlink_msg_heartbeat_get_custom_mode(const mavlink_message_t* msg)
290{
291 return _MAV_RETURN_uint32_t(msg, 0);
292}
293
294/**
295 * @brief Get field system_status from heartbeat message
296 *
297 * @return System status flag, see MAV_STATE ENUM
298 */
299static inline uint8_t mavlink_msg_heartbeat_get_system_status(const mavlink_message_t* msg)
300{
301 return _MAV_RETURN_uint8_t(msg, 7);
302}
303
304/**
305 * @brief Get field mavlink_version from heartbeat message
306 *
307 * @return MAVLink version, not writable by user, gets added by protocol because of magic data type: uint8_t_mavlink_version
308 */
309static inline uint8_t mavlink_msg_heartbeat_get_mavlink_version(const mavlink_message_t* msg)
310{
311 return _MAV_RETURN_uint8_t(msg, 8);
312}
313
314/**
315 * @brief Decode a heartbeat message into a struct
316 *
317 * @param msg The message to decode
318 * @param heartbeat C-struct to decode the message contents into
319 */
320static inline void mavlink_msg_heartbeat_decode(const mavlink_message_t* msg, mavlink_heartbeat_t* heartbeat)
321{
322#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
323 heartbeat->custom_mode = mavlink_msg_heartbeat_get_custom_mode(msg);
324 heartbeat->type = mavlink_msg_heartbeat_get_type(msg);
325 heartbeat->autopilot = mavlink_msg_heartbeat_get_autopilot(msg);
326 heartbeat->base_mode = mavlink_msg_heartbeat_get_base_mode(msg);
327 heartbeat->system_status = mavlink_msg_heartbeat_get_system_status(msg);
328 heartbeat->mavlink_version = mavlink_msg_heartbeat_get_mavlink_version(msg);
329#else
330 uint8_t len = msg->len < MAVLINK_MSG_ID_HEARTBEAT_LEN? msg->len : MAVLINK_MSG_ID_HEARTBEAT_LEN;
331 memset(heartbeat, 0, MAVLINK_MSG_ID_HEARTBEAT_LEN);
332 memcpy(heartbeat, _MAV_PAYLOAD(msg), len);
333#endif
334}
Note: See TracBrowser for help on using the repository browser.