Merge remote-tracking branch 'upstream/master' into abo_fw_alt_vel_control
[inav.git] / lib / main / MAVLink / common / mavlink_msg_request_data_stream.h
blobf1d739588e8afb4ea593b0e649d3d30cb7014c5a
1 #pragma once
2 // MESSAGE REQUEST_DATA_STREAM PACKING
4 #define MAVLINK_MSG_ID_REQUEST_DATA_STREAM 66
7 typedef struct __mavlink_request_data_stream_t {
8 uint16_t req_message_rate; /*< [Hz] The requested message rate*/
9 uint8_t target_system; /*< The target requested to send the message stream.*/
10 uint8_t target_component; /*< The target requested to send the message stream.*/
11 uint8_t req_stream_id; /*< The ID of the requested data stream*/
12 uint8_t start_stop; /*< 1 to start sending, 0 to stop sending.*/
13 } mavlink_request_data_stream_t;
15 #define MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN 6
16 #define MAVLINK_MSG_ID_REQUEST_DATA_STREAM_MIN_LEN 6
17 #define MAVLINK_MSG_ID_66_LEN 6
18 #define MAVLINK_MSG_ID_66_MIN_LEN 6
20 #define MAVLINK_MSG_ID_REQUEST_DATA_STREAM_CRC 148
21 #define MAVLINK_MSG_ID_66_CRC 148
25 #if MAVLINK_COMMAND_24BIT
26 #define MAVLINK_MESSAGE_INFO_REQUEST_DATA_STREAM { \
27 66, \
28 "REQUEST_DATA_STREAM", \
29 5, \
30 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_request_data_stream_t, target_system) }, \
31 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_request_data_stream_t, target_component) }, \
32 { "req_stream_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_request_data_stream_t, req_stream_id) }, \
33 { "req_message_rate", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_request_data_stream_t, req_message_rate) }, \
34 { "start_stop", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_request_data_stream_t, start_stop) }, \
35 } \
37 #else
38 #define MAVLINK_MESSAGE_INFO_REQUEST_DATA_STREAM { \
39 "REQUEST_DATA_STREAM", \
40 5, \
41 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_request_data_stream_t, target_system) }, \
42 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_request_data_stream_t, target_component) }, \
43 { "req_stream_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_request_data_stream_t, req_stream_id) }, \
44 { "req_message_rate", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_request_data_stream_t, req_message_rate) }, \
45 { "start_stop", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_request_data_stream_t, start_stop) }, \
46 } \
48 #endif
50 /**
51 * @brief Pack a request_data_stream message
52 * @param system_id ID of this system
53 * @param component_id ID of this component (e.g. 200 for IMU)
54 * @param msg The MAVLink message to compress the data into
56 * @param target_system The target requested to send the message stream.
57 * @param target_component The target requested to send the message stream.
58 * @param req_stream_id The ID of the requested data stream
59 * @param req_message_rate [Hz] The requested message rate
60 * @param start_stop 1 to start sending, 0 to stop sending.
61 * @return length of the message in bytes (excluding serial stream start sign)
63 static inline uint16_t mavlink_msg_request_data_stream_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
64 uint8_t target_system, uint8_t target_component, uint8_t req_stream_id, uint16_t req_message_rate, uint8_t start_stop)
66 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
67 char buf[MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN];
68 _mav_put_uint16_t(buf, 0, req_message_rate);
69 _mav_put_uint8_t(buf, 2, target_system);
70 _mav_put_uint8_t(buf, 3, target_component);
71 _mav_put_uint8_t(buf, 4, req_stream_id);
72 _mav_put_uint8_t(buf, 5, start_stop);
74 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN);
75 #else
76 mavlink_request_data_stream_t packet;
77 packet.req_message_rate = req_message_rate;
78 packet.target_system = target_system;
79 packet.target_component = target_component;
80 packet.req_stream_id = req_stream_id;
81 packet.start_stop = start_stop;
83 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN);
84 #endif
86 msg->msgid = MAVLINK_MSG_ID_REQUEST_DATA_STREAM;
87 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_CRC);
90 /**
91 * @brief Pack a request_data_stream message on a channel
92 * @param system_id ID of this system
93 * @param component_id ID of this component (e.g. 200 for IMU)
94 * @param chan The MAVLink channel this message will be sent over
95 * @param msg The MAVLink message to compress the data into
96 * @param target_system The target requested to send the message stream.
97 * @param target_component The target requested to send the message stream.
98 * @param req_stream_id The ID of the requested data stream
99 * @param req_message_rate [Hz] The requested message rate
100 * @param start_stop 1 to start sending, 0 to stop sending.
101 * @return length of the message in bytes (excluding serial stream start sign)
103 static inline uint16_t mavlink_msg_request_data_stream_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
104 mavlink_message_t* msg,
105 uint8_t target_system,uint8_t target_component,uint8_t req_stream_id,uint16_t req_message_rate,uint8_t start_stop)
107 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
108 char buf[MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN];
109 _mav_put_uint16_t(buf, 0, req_message_rate);
110 _mav_put_uint8_t(buf, 2, target_system);
111 _mav_put_uint8_t(buf, 3, target_component);
112 _mav_put_uint8_t(buf, 4, req_stream_id);
113 _mav_put_uint8_t(buf, 5, start_stop);
115 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN);
116 #else
117 mavlink_request_data_stream_t packet;
118 packet.req_message_rate = req_message_rate;
119 packet.target_system = target_system;
120 packet.target_component = target_component;
121 packet.req_stream_id = req_stream_id;
122 packet.start_stop = start_stop;
124 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN);
125 #endif
127 msg->msgid = MAVLINK_MSG_ID_REQUEST_DATA_STREAM;
128 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_CRC);
132 * @brief Encode a request_data_stream 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 request_data_stream C-struct to read the message contents from
139 static inline uint16_t mavlink_msg_request_data_stream_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_request_data_stream_t* request_data_stream)
141 return mavlink_msg_request_data_stream_pack(system_id, component_id, msg, request_data_stream->target_system, request_data_stream->target_component, request_data_stream->req_stream_id, request_data_stream->req_message_rate, request_data_stream->start_stop);
145 * @brief Encode a request_data_stream 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 request_data_stream C-struct to read the message contents from
153 static inline uint16_t mavlink_msg_request_data_stream_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_request_data_stream_t* request_data_stream)
155 return mavlink_msg_request_data_stream_pack_chan(system_id, component_id, chan, msg, request_data_stream->target_system, request_data_stream->target_component, request_data_stream->req_stream_id, request_data_stream->req_message_rate, request_data_stream->start_stop);
159 * @brief Send a request_data_stream message
160 * @param chan MAVLink channel to send the message
162 * @param target_system The target requested to send the message stream.
163 * @param target_component The target requested to send the message stream.
164 * @param req_stream_id The ID of the requested data stream
165 * @param req_message_rate [Hz] The requested message rate
166 * @param start_stop 1 to start sending, 0 to stop sending.
168 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
170 static inline void mavlink_msg_request_data_stream_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t req_stream_id, uint16_t req_message_rate, uint8_t start_stop)
172 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
173 char buf[MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN];
174 _mav_put_uint16_t(buf, 0, req_message_rate);
175 _mav_put_uint8_t(buf, 2, target_system);
176 _mav_put_uint8_t(buf, 3, target_component);
177 _mav_put_uint8_t(buf, 4, req_stream_id);
178 _mav_put_uint8_t(buf, 5, start_stop);
180 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_REQUEST_DATA_STREAM, buf, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_CRC);
181 #else
182 mavlink_request_data_stream_t packet;
183 packet.req_message_rate = req_message_rate;
184 packet.target_system = target_system;
185 packet.target_component = target_component;
186 packet.req_stream_id = req_stream_id;
187 packet.start_stop = start_stop;
189 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_REQUEST_DATA_STREAM, (const char *)&packet, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_CRC);
190 #endif
194 * @brief Send a request_data_stream message
195 * @param chan MAVLink channel to send the message
196 * @param struct The MAVLink struct to serialize
198 static inline void mavlink_msg_request_data_stream_send_struct(mavlink_channel_t chan, const mavlink_request_data_stream_t* request_data_stream)
200 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
201 mavlink_msg_request_data_stream_send(chan, request_data_stream->target_system, request_data_stream->target_component, request_data_stream->req_stream_id, request_data_stream->req_message_rate, request_data_stream->start_stop);
202 #else
203 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_REQUEST_DATA_STREAM, (const char *)request_data_stream, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_CRC);
204 #endif
207 #if MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN <= MAVLINK_MAX_PAYLOAD_LEN
209 This varient of _send() can be used to save stack space by re-using
210 memory from the receive buffer. The caller provides a
211 mavlink_message_t which is the size of a full mavlink message. This
212 is usually the receive buffer for the channel, and allows a reply to an
213 incoming message with minimum stack space usage.
215 static inline void mavlink_msg_request_data_stream_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t req_stream_id, uint16_t req_message_rate, uint8_t start_stop)
217 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
218 char *buf = (char *)msgbuf;
219 _mav_put_uint16_t(buf, 0, req_message_rate);
220 _mav_put_uint8_t(buf, 2, target_system);
221 _mav_put_uint8_t(buf, 3, target_component);
222 _mav_put_uint8_t(buf, 4, req_stream_id);
223 _mav_put_uint8_t(buf, 5, start_stop);
225 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_REQUEST_DATA_STREAM, buf, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_CRC);
226 #else
227 mavlink_request_data_stream_t *packet = (mavlink_request_data_stream_t *)msgbuf;
228 packet->req_message_rate = req_message_rate;
229 packet->target_system = target_system;
230 packet->target_component = target_component;
231 packet->req_stream_id = req_stream_id;
232 packet->start_stop = start_stop;
234 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_REQUEST_DATA_STREAM, (const char *)packet, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_CRC);
235 #endif
237 #endif
239 #endif
241 // MESSAGE REQUEST_DATA_STREAM UNPACKING
245 * @brief Get field target_system from request_data_stream message
247 * @return The target requested to send the message stream.
249 static inline uint8_t mavlink_msg_request_data_stream_get_target_system(const mavlink_message_t* msg)
251 return _MAV_RETURN_uint8_t(msg, 2);
255 * @brief Get field target_component from request_data_stream message
257 * @return The target requested to send the message stream.
259 static inline uint8_t mavlink_msg_request_data_stream_get_target_component(const mavlink_message_t* msg)
261 return _MAV_RETURN_uint8_t(msg, 3);
265 * @brief Get field req_stream_id from request_data_stream message
267 * @return The ID of the requested data stream
269 static inline uint8_t mavlink_msg_request_data_stream_get_req_stream_id(const mavlink_message_t* msg)
271 return _MAV_RETURN_uint8_t(msg, 4);
275 * @brief Get field req_message_rate from request_data_stream message
277 * @return [Hz] The requested message rate
279 static inline uint16_t mavlink_msg_request_data_stream_get_req_message_rate(const mavlink_message_t* msg)
281 return _MAV_RETURN_uint16_t(msg, 0);
285 * @brief Get field start_stop from request_data_stream message
287 * @return 1 to start sending, 0 to stop sending.
289 static inline uint8_t mavlink_msg_request_data_stream_get_start_stop(const mavlink_message_t* msg)
291 return _MAV_RETURN_uint8_t(msg, 5);
295 * @brief Decode a request_data_stream message into a struct
297 * @param msg The message to decode
298 * @param request_data_stream C-struct to decode the message contents into
300 static inline void mavlink_msg_request_data_stream_decode(const mavlink_message_t* msg, mavlink_request_data_stream_t* request_data_stream)
302 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
303 request_data_stream->req_message_rate = mavlink_msg_request_data_stream_get_req_message_rate(msg);
304 request_data_stream->target_system = mavlink_msg_request_data_stream_get_target_system(msg);
305 request_data_stream->target_component = mavlink_msg_request_data_stream_get_target_component(msg);
306 request_data_stream->req_stream_id = mavlink_msg_request_data_stream_get_req_stream_id(msg);
307 request_data_stream->start_stop = mavlink_msg_request_data_stream_get_start_stop(msg);
308 #else
309 uint8_t len = msg->len < MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN? msg->len : MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN;
310 memset(request_data_stream, 0, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN);
311 memcpy(request_data_stream, _MAV_PAYLOAD(msg), len);
312 #endif