Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_message_interval.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE MESSAGE_INTERVAL PACKING
3
4#define MAVLINK_MSG_ID_MESSAGE_INTERVAL 244
5
6
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;
11
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
16
17#define MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC 95
18#define MAVLINK_MSG_ID_244_CRC 95
19
20
21
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 } \
30}
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 } \
38}
39#endif
40
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
46 *
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)
50 */
51static 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)
53{
54#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
56 _mav_put_int32_t(buf, 0, interval_us);
57 _mav_put_uint16_t(buf, 4, message_id);
58
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;
64
65 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
66#endif
67
70}
71
72/**
73 * @brief Pack a message_interval message
74 * @param system_id ID of this system
75 * @param component_id ID of this component (e.g. 200 for IMU)
76 * @param status MAVLink status structure
77 * @param msg The MAVLink message to compress the data into
78 *
79 * @param message_id The ID of the requested MAVLink message. v1.0 is limited to 254 messages.
80 * @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.
81 * @return length of the message in bytes (excluding serial stream start sign)
82 */
83static inline uint16_t mavlink_msg_message_interval_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
84 uint16_t message_id, int32_t interval_us)
85{
86#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
88 _mav_put_int32_t(buf, 0, interval_us);
89 _mav_put_uint16_t(buf, 4, message_id);
90
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;
96
97 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
98#endif
99
101#if MAVLINK_CRC_EXTRA
102 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
103#else
104 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
105#endif
106}
107
108/**
109 * @brief Pack a message_interval message on a channel
110 * @param system_id ID of this system
111 * @param component_id ID of this component (e.g. 200 for IMU)
112 * @param chan The MAVLink channel this message will be sent over
113 * @param msg The MAVLink message to compress the data into
114 * @param message_id The ID of the requested MAVLink message. v1.0 is limited to 254 messages.
115 * @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.
116 * @return length of the message in bytes (excluding serial stream start sign)
117 */
118static inline uint16_t mavlink_msg_message_interval_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
119 mavlink_message_t* msg,
120 uint16_t message_id,int32_t interval_us)
121{
122#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
124 _mav_put_int32_t(buf, 0, interval_us);
125 _mav_put_uint16_t(buf, 4, message_id);
126
127 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
128#else
129 mavlink_message_interval_t packet;
130 packet.interval_us = interval_us;
131 packet.message_id = message_id;
132
133 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
134#endif
135
137 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);
138}
139
140/**
141 * @brief Encode a message_interval struct
142 *
143 * @param system_id ID of this system
144 * @param component_id ID of this component (e.g. 200 for IMU)
145 * @param msg The MAVLink message to compress the data into
146 * @param message_interval C-struct to read the message contents from
147 */
148static 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)
149{
150 return mavlink_msg_message_interval_pack(system_id, component_id, msg, message_interval->message_id, message_interval->interval_us);
151}
152
153/**
154 * @brief Encode a message_interval struct on a channel
155 *
156 * @param system_id ID of this system
157 * @param component_id ID of this component (e.g. 200 for IMU)
158 * @param chan The MAVLink channel this message will be sent over
159 * @param msg The MAVLink message to compress the data into
160 * @param message_interval C-struct to read the message contents from
161 */
162static 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)
163{
164 return mavlink_msg_message_interval_pack_chan(system_id, component_id, chan, msg, message_interval->message_id, message_interval->interval_us);
165}
166
167/**
168 * @brief Encode a message_interval struct with provided status structure
169 *
170 * @param system_id ID of this system
171 * @param component_id ID of this component (e.g. 200 for IMU)
172 * @param status MAVLink status structure
173 * @param msg The MAVLink message to compress the data into
174 * @param message_interval C-struct to read the message contents from
175 */
176static inline uint16_t mavlink_msg_message_interval_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_message_interval_t* message_interval)
177{
178 return mavlink_msg_message_interval_pack_status(system_id, component_id, _status, msg, message_interval->message_id, message_interval->interval_us);
179}
180
181/**
182 * @brief Send a message_interval message
183 * @param chan MAVLink channel to send the message
184 *
185 * @param message_id The ID of the requested MAVLink message. v1.0 is limited to 254 messages.
186 * @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.
187 */
188#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
189
190static inline void mavlink_msg_message_interval_send(mavlink_channel_t chan, uint16_t message_id, int32_t interval_us)
191{
192#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193 char buf[MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN];
194 _mav_put_int32_t(buf, 0, interval_us);
195 _mav_put_uint16_t(buf, 4, message_id);
196
197 _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);
198#else
199 mavlink_message_interval_t packet;
200 packet.interval_us = interval_us;
201 packet.message_id = message_id;
202
203 _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);
204#endif
205}
206
207/**
208 * @brief Send a message_interval message
209 * @param chan MAVLink channel to send the message
210 * @param struct The MAVLink struct to serialize
211 */
212static inline void mavlink_msg_message_interval_send_struct(mavlink_channel_t chan, const mavlink_message_interval_t* message_interval)
213{
214#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
215 mavlink_msg_message_interval_send(chan, message_interval->message_id, message_interval->interval_us);
216#else
217 _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);
218#endif
219}
220
221#if MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
222/*
223 This variant of _send() can be used to save stack space by reusing
224 memory from the receive buffer. The caller provides a
225 mavlink_message_t which is the size of a full mavlink message. This
226 is usually the receive buffer for the channel, and allows a reply to an
227 incoming message with minimum stack space usage.
228 */
229static inline void mavlink_msg_message_interval_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t message_id, int32_t interval_us)
230{
231#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
232 char *buf = (char *)msgbuf;
233 _mav_put_int32_t(buf, 0, interval_us);
234 _mav_put_uint16_t(buf, 4, message_id);
235
236 _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);
237#else
238 mavlink_message_interval_t *packet = (mavlink_message_interval_t *)msgbuf;
239 packet->interval_us = interval_us;
240 packet->message_id = message_id;
241
242 _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);
243#endif
244}
245#endif
246
247#endif
248
249// MESSAGE MESSAGE_INTERVAL UNPACKING
250
251
252/**
253 * @brief Get field message_id from message_interval message
254 *
255 * @return The ID of the requested MAVLink message. v1.0 is limited to 254 messages.
256 */
257static inline uint16_t mavlink_msg_message_interval_get_message_id(const mavlink_message_t* msg)
258{
259 return _MAV_RETURN_uint16_t(msg, 4);
260}
261
262/**
263 * @brief Get field interval_us from message_interval message
264 *
265 * @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.
266 */
267static inline int32_t mavlink_msg_message_interval_get_interval_us(const mavlink_message_t* msg)
268{
269 return _MAV_RETURN_int32_t(msg, 0);
270}
271
272/**
273 * @brief Decode a message_interval message into a struct
274 *
275 * @param msg The message to decode
276 * @param message_interval C-struct to decode the message contents into
277 */
278static inline void mavlink_msg_message_interval_decode(const mavlink_message_t* msg, mavlink_message_interval_t* message_interval)
279{
280#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
281 message_interval->interval_us = mavlink_msg_message_interval_get_interval_us(msg);
282 message_interval->message_id = mavlink_msg_message_interval_get_message_id(msg);
283#else
284 uint8_t len = msg->len < MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN? msg->len : MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN;
285 memset(message_interval, 0, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
286 memcpy(message_interval, _MAV_PAYLOAD(msg), len);
287#endif
288}