Merge remote-tracking branch 'upstream/master' into abo_fw_alt_vel_control
[inav.git] / lib / main / MAVLink / common / mavlink_msg_message_interval.h
bloba6a52b1fdc80c9c7844a26ecabb46678b2c7a689
1 #pragma once
2 // MESSAGE MESSAGE_INTERVAL PACKING
4 #define MAVLINK_MSG_ID_MESSAGE_INTERVAL 244
7 typedef struct __mavlink_message_interval_t {
8 int32_t interval_us; /*< [us] The interval between two messages. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent.*/
9 uint16_t message_id; /*< The ID of the requested MAVLink message. v1.0 is limited to 254 messages.*/
10 } mavlink_message_interval_t;
12 #define MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN 6
13 #define MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN 6
14 #define MAVLINK_MSG_ID_244_LEN 6
15 #define MAVLINK_MSG_ID_244_MIN_LEN 6
17 #define MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC 95
18 #define MAVLINK_MSG_ID_244_CRC 95
22 #if MAVLINK_COMMAND_24BIT
23 #define MAVLINK_MESSAGE_INFO_MESSAGE_INTERVAL { \
24 244, \
25 "MESSAGE_INTERVAL", \
26 2, \
27 { { "message_id", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_message_interval_t, message_id) }, \
28 { "interval_us", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_message_interval_t, interval_us) }, \
29 } \
31 #else
32 #define MAVLINK_MESSAGE_INFO_MESSAGE_INTERVAL { \
33 "MESSAGE_INTERVAL", \
34 2, \
35 { { "message_id", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_message_interval_t, message_id) }, \
36 { "interval_us", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_message_interval_t, interval_us) }, \
37 } \
39 #endif
41 /**
42 * @brief Pack a message_interval message
43 * @param system_id ID of this system
44 * @param component_id ID of this component (e.g. 200 for IMU)
45 * @param msg The MAVLink message to compress the data into
47 * @param message_id The ID of the requested MAVLink message. v1.0 is limited to 254 messages.
48 * @param interval_us [us] The interval between two messages. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent.
49 * @return length of the message in bytes (excluding serial stream start sign)
51 static inline uint16_t mavlink_msg_message_interval_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
52 uint16_t message_id, int32_t interval_us)
54 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
55 char buf[MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN];
56 _mav_put_int32_t(buf, 0, interval_us);
57 _mav_put_uint16_t(buf, 4, message_id);
59 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
60 #else
61 mavlink_message_interval_t packet;
62 packet.interval_us = interval_us;
63 packet.message_id = message_id;
65 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
66 #endif
68 msg->msgid = MAVLINK_MSG_ID_MESSAGE_INTERVAL;
69 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
72 /**
73 * @brief Pack a message_interval message on a channel
74 * @param system_id ID of this system
75 * @param component_id ID of this component (e.g. 200 for IMU)
76 * @param chan The MAVLink channel this message will be sent over
77 * @param msg The MAVLink message to compress the data into
78 * @param message_id The ID of the requested MAVLink message. v1.0 is limited to 254 messages.
79 * @param interval_us [us] The interval between two messages. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent.
80 * @return length of the message in bytes (excluding serial stream start sign)
82 static inline uint16_t mavlink_msg_message_interval_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
83 mavlink_message_t* msg,
84 uint16_t message_id,int32_t interval_us)
86 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
87 char buf[MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN];
88 _mav_put_int32_t(buf, 0, interval_us);
89 _mav_put_uint16_t(buf, 4, message_id);
91 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
92 #else
93 mavlink_message_interval_t packet;
94 packet.interval_us = interval_us;
95 packet.message_id = message_id;
97 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
98 #endif
100 msg->msgid = MAVLINK_MSG_ID_MESSAGE_INTERVAL;
101 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
105 * @brief Encode a message_interval struct
107 * @param system_id ID of this system
108 * @param component_id ID of this component (e.g. 200 for IMU)
109 * @param msg The MAVLink message to compress the data into
110 * @param message_interval C-struct to read the message contents from
112 static inline uint16_t mavlink_msg_message_interval_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_message_interval_t* message_interval)
114 return mavlink_msg_message_interval_pack(system_id, component_id, msg, message_interval->message_id, message_interval->interval_us);
118 * @brief Encode a message_interval struct on a channel
120 * @param system_id ID of this system
121 * @param component_id ID of this component (e.g. 200 for IMU)
122 * @param chan The MAVLink channel this message will be sent over
123 * @param msg The MAVLink message to compress the data into
124 * @param message_interval C-struct to read the message contents from
126 static inline uint16_t mavlink_msg_message_interval_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_message_interval_t* message_interval)
128 return mavlink_msg_message_interval_pack_chan(system_id, component_id, chan, msg, message_interval->message_id, message_interval->interval_us);
132 * @brief Send a message_interval message
133 * @param chan MAVLink channel to send the message
135 * @param message_id The ID of the requested MAVLink message. v1.0 is limited to 254 messages.
136 * @param interval_us [us] The interval between two messages. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent.
138 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
140 static inline void mavlink_msg_message_interval_send(mavlink_channel_t chan, uint16_t message_id, int32_t interval_us)
142 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
143 char buf[MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN];
144 _mav_put_int32_t(buf, 0, interval_us);
145 _mav_put_uint16_t(buf, 4, message_id);
147 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MESSAGE_INTERVAL, buf, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
148 #else
149 mavlink_message_interval_t packet;
150 packet.interval_us = interval_us;
151 packet.message_id = message_id;
153 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MESSAGE_INTERVAL, (const char *)&packet, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
154 #endif
158 * @brief Send a message_interval message
159 * @param chan MAVLink channel to send the message
160 * @param struct The MAVLink struct to serialize
162 static inline void mavlink_msg_message_interval_send_struct(mavlink_channel_t chan, const mavlink_message_interval_t* message_interval)
164 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
165 mavlink_msg_message_interval_send(chan, message_interval->message_id, message_interval->interval_us);
166 #else
167 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MESSAGE_INTERVAL, (const char *)message_interval, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
168 #endif
171 #if MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
173 This varient of _send() can be used to save stack space by re-using
174 memory from the receive buffer. The caller provides a
175 mavlink_message_t which is the size of a full mavlink message. This
176 is usually the receive buffer for the channel, and allows a reply to an
177 incoming message with minimum stack space usage.
179 static inline void mavlink_msg_message_interval_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t message_id, int32_t interval_us)
181 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
182 char *buf = (char *)msgbuf;
183 _mav_put_int32_t(buf, 0, interval_us);
184 _mav_put_uint16_t(buf, 4, message_id);
186 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MESSAGE_INTERVAL, buf, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
187 #else
188 mavlink_message_interval_t *packet = (mavlink_message_interval_t *)msgbuf;
189 packet->interval_us = interval_us;
190 packet->message_id = message_id;
192 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MESSAGE_INTERVAL, (const char *)packet, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
193 #endif
195 #endif
197 #endif
199 // MESSAGE MESSAGE_INTERVAL UNPACKING
203 * @brief Get field message_id from message_interval message
205 * @return The ID of the requested MAVLink message. v1.0 is limited to 254 messages.
207 static inline uint16_t mavlink_msg_message_interval_get_message_id(const mavlink_message_t* msg)
209 return _MAV_RETURN_uint16_t(msg, 4);
213 * @brief Get field interval_us from message_interval message
215 * @return [us] The interval between two messages. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent.
217 static inline int32_t mavlink_msg_message_interval_get_interval_us(const mavlink_message_t* msg)
219 return _MAV_RETURN_int32_t(msg, 0);
223 * @brief Decode a message_interval message into a struct
225 * @param msg The message to decode
226 * @param message_interval C-struct to decode the message contents into
228 static inline void mavlink_msg_message_interval_decode(const mavlink_message_t* msg, mavlink_message_interval_t* message_interval)
230 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
231 message_interval->interval_us = mavlink_msg_message_interval_get_interval_us(msg);
232 message_interval->message_id = mavlink_msg_message_interval_get_message_id(msg);
233 #else
234 uint8_t len = msg->len < MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN? msg->len : MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN;
235 memset(message_interval, 0, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
236 memcpy(message_interval, _MAV_PAYLOAD(msg), len);
237 #endif