Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / libraries / mavlink / v1.0 / common / mavlink_msg_debug.h
blobb46cf8423fcd3d468b77df8664b0aff2202e92e5
1 // MESSAGE DEBUG PACKING
3 #define MAVLINK_MSG_ID_DEBUG 254
5 typedef struct __mavlink_debug_t {
6 uint32_t time_boot_ms; ///< Timestamp (milliseconds since system boot)
7 float value; ///< DEBUG value
8 uint8_t ind; ///< index of debug variable
9 } mavlink_debug_t;
11 #define MAVLINK_MSG_ID_DEBUG_LEN 9
12 #define MAVLINK_MSG_ID_254_LEN 9
15 #define MAVLINK_MESSAGE_INFO_DEBUG \
16 { \
17 "DEBUG", \
18 3, \
19 { \
20 { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_debug_t, time_boot_ms) }, \
21 { "value", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_debug_t, value) }, \
22 { "ind", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_debug_t, ind) }, \
23 } \
27 /**
28 * @brief Pack a debug message
29 * @param system_id ID of this system
30 * @param component_id ID of this component (e.g. 200 for IMU)
31 * @param msg The MAVLink message to compress the data into
33 * @param time_boot_ms Timestamp (milliseconds since system boot)
34 * @param ind index of debug variable
35 * @param value DEBUG value
36 * @return length of the message in bytes (excluding serial stream start sign)
38 static inline uint16_t mavlink_msg_debug_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg,
39 uint32_t time_boot_ms, uint8_t ind, float value)
41 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
42 char buf[9];
43 _mav_put_uint32_t(buf, 0, time_boot_ms);
44 _mav_put_float(buf, 4, value);
45 _mav_put_uint8_t(buf, 8, ind);
47 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 9);
48 #else
49 mavlink_debug_t packet;
50 packet.time_boot_ms = time_boot_ms;
51 packet.value = value;
52 packet.ind = ind;
54 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 9);
55 #endif
57 msg->msgid = MAVLINK_MSG_ID_DEBUG;
58 return mavlink_finalize_message(msg, system_id, component_id, 9, 46);
61 /**
62 * @brief Pack a debug message on a channel
63 * @param system_id ID of this system
64 * @param component_id ID of this component (e.g. 200 for IMU)
65 * @param chan The MAVLink channel this message was sent over
66 * @param msg The MAVLink message to compress the data into
67 * @param time_boot_ms Timestamp (milliseconds since system boot)
68 * @param ind index of debug variable
69 * @param value DEBUG value
70 * @return length of the message in bytes (excluding serial stream start sign)
72 static inline uint16_t mavlink_msg_debug_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
73 mavlink_message_t *msg,
74 uint32_t time_boot_ms, uint8_t ind, float value)
76 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
77 char buf[9];
78 _mav_put_uint32_t(buf, 0, time_boot_ms);
79 _mav_put_float(buf, 4, value);
80 _mav_put_uint8_t(buf, 8, ind);
82 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 9);
83 #else
84 mavlink_debug_t packet;
85 packet.time_boot_ms = time_boot_ms;
86 packet.value = value;
87 packet.ind = ind;
89 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 9);
90 #endif
92 msg->msgid = MAVLINK_MSG_ID_DEBUG;
93 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 9, 46);
96 /**
97 * @brief Encode a debug struct into a message
99 * @param system_id ID of this system
100 * @param component_id ID of this component (e.g. 200 for IMU)
101 * @param msg The MAVLink message to compress the data into
102 * @param debug C-struct to read the message contents from
104 static inline uint16_t mavlink_msg_debug_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg, const mavlink_debug_t *debug)
106 return mavlink_msg_debug_pack(system_id, component_id, msg, debug->time_boot_ms, debug->ind, debug->value);
110 * @brief Send a debug message
111 * @param chan MAVLink channel to send the message
113 * @param time_boot_ms Timestamp (milliseconds since system boot)
114 * @param ind index of debug variable
115 * @param value DEBUG value
117 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
119 static inline void mavlink_msg_debug_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t ind, float value)
121 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
122 char buf[9];
123 _mav_put_uint32_t(buf, 0, time_boot_ms);
124 _mav_put_float(buf, 4, value);
125 _mav_put_uint8_t(buf, 8, ind);
127 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, buf, 9, 46);
128 #else
129 mavlink_debug_t packet;
130 packet.time_boot_ms = time_boot_ms;
131 packet.value = value;
132 packet.ind = ind;
134 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, (const char *)&packet, 9, 46);
135 #endif
138 #endif // ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
140 // MESSAGE DEBUG UNPACKING
144 * @brief Get field time_boot_ms from debug message
146 * @return Timestamp (milliseconds since system boot)
148 static inline uint32_t mavlink_msg_debug_get_time_boot_ms(const mavlink_message_t *msg)
150 return _MAV_RETURN_uint32_t(msg, 0);
154 * @brief Get field ind from debug message
156 * @return index of debug variable
158 static inline uint8_t mavlink_msg_debug_get_ind(const mavlink_message_t *msg)
160 return _MAV_RETURN_uint8_t(msg, 8);
164 * @brief Get field value from debug message
166 * @return DEBUG value
168 static inline float mavlink_msg_debug_get_value(const mavlink_message_t *msg)
170 return _MAV_RETURN_float(msg, 4);
174 * @brief Decode a debug message into a struct
176 * @param msg The message to decode
177 * @param debug C-struct to decode the message contents into
179 static inline void mavlink_msg_debug_decode(const mavlink_message_t *msg, mavlink_debug_t *debug)
181 #if MAVLINK_NEED_BYTE_SWAP
182 debug->time_boot_ms = mavlink_msg_debug_get_time_boot_ms(msg);
183 debug->value = mavlink_msg_debug_get_value(msg);
184 debug->ind = mavlink_msg_debug_get_ind(msg);
185 #else
186 memcpy(debug, _MAV_PAYLOAD(msg), 9);
187 #endif