Move telemetry displayport init and cms device registering
[betaflight.git] / lib / main / MAVLink / common / mavlink_msg_data_stream.h
blob640ffebf4424ce0a342c54be0996867a59e461da
1 // MESSAGE DATA_STREAM PACKING
3 #define MAVLINK_MSG_ID_DATA_STREAM 67
5 typedef struct __mavlink_data_stream_t
7 uint16_t message_rate; ///< The requested interval between two messages of this type
8 uint8_t stream_id; ///< The ID of the requested data stream
9 uint8_t on_off; ///< 1 stream is enabled, 0 stream is stopped.
10 } mavlink_data_stream_t;
12 #define MAVLINK_MSG_ID_DATA_STREAM_LEN 4
13 #define MAVLINK_MSG_ID_67_LEN 4
15 #define MAVLINK_MSG_ID_DATA_STREAM_CRC 21
16 #define MAVLINK_MSG_ID_67_CRC 21
20 #define MAVLINK_MESSAGE_INFO_DATA_STREAM { \
21 "DATA_STREAM", \
22 3, \
23 { { "message_rate", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_data_stream_t, message_rate) }, \
24 { "stream_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_data_stream_t, stream_id) }, \
25 { "on_off", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_data_stream_t, on_off) }, \
26 } \
30 /**
31 * @brief Pack a data_stream message
32 * @param system_id ID of this system
33 * @param component_id ID of this component (e.g. 200 for IMU)
34 * @param msg The MAVLink message to compress the data into
36 * @param stream_id The ID of the requested data stream
37 * @param message_rate The requested interval between two messages of this type
38 * @param on_off 1 stream is enabled, 0 stream is stopped.
39 * @return length of the message in bytes (excluding serial stream start sign)
41 static inline uint16_t mavlink_msg_data_stream_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
42 uint8_t stream_id, uint16_t message_rate, uint8_t on_off)
44 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
45 char buf[MAVLINK_MSG_ID_DATA_STREAM_LEN];
46 _mav_put_uint16_t(buf, 0, message_rate);
47 _mav_put_uint8_t(buf, 2, stream_id);
48 _mav_put_uint8_t(buf, 3, on_off);
50 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DATA_STREAM_LEN);
51 #else
52 mavlink_data_stream_t packet;
53 packet.message_rate = message_rate;
54 packet.stream_id = stream_id;
55 packet.on_off = on_off;
57 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DATA_STREAM_LEN);
58 #endif
60 msg->msgid = MAVLINK_MSG_ID_DATA_STREAM;
61 #if MAVLINK_CRC_EXTRA
62 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC);
63 #else
64 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DATA_STREAM_LEN);
65 #endif
68 /**
69 * @brief Pack a data_stream message on a channel
70 * @param system_id ID of this system
71 * @param component_id ID of this component (e.g. 200 for IMU)
72 * @param chan The MAVLink channel this message will be sent over
73 * @param msg The MAVLink message to compress the data into
74 * @param stream_id The ID of the requested data stream
75 * @param message_rate The requested interval between two messages of this type
76 * @param on_off 1 stream is enabled, 0 stream is stopped.
77 * @return length of the message in bytes (excluding serial stream start sign)
79 static inline uint16_t mavlink_msg_data_stream_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
80 mavlink_message_t* msg,
81 uint8_t stream_id,uint16_t message_rate,uint8_t on_off)
83 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
84 char buf[MAVLINK_MSG_ID_DATA_STREAM_LEN];
85 _mav_put_uint16_t(buf, 0, message_rate);
86 _mav_put_uint8_t(buf, 2, stream_id);
87 _mav_put_uint8_t(buf, 3, on_off);
89 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DATA_STREAM_LEN);
90 #else
91 mavlink_data_stream_t packet;
92 packet.message_rate = message_rate;
93 packet.stream_id = stream_id;
94 packet.on_off = on_off;
96 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DATA_STREAM_LEN);
97 #endif
99 msg->msgid = MAVLINK_MSG_ID_DATA_STREAM;
100 #if MAVLINK_CRC_EXTRA
101 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC);
102 #else
103 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DATA_STREAM_LEN);
104 #endif
108 * @brief Encode a data_stream struct
110 * @param system_id ID of this system
111 * @param component_id ID of this component (e.g. 200 for IMU)
112 * @param msg The MAVLink message to compress the data into
113 * @param data_stream C-struct to read the message contents from
115 static inline uint16_t mavlink_msg_data_stream_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_data_stream_t* data_stream)
117 return mavlink_msg_data_stream_pack(system_id, component_id, msg, data_stream->stream_id, data_stream->message_rate, data_stream->on_off);
121 * @brief Encode a data_stream struct on a channel
123 * @param system_id ID of this system
124 * @param component_id ID of this component (e.g. 200 for IMU)
125 * @param chan The MAVLink channel this message will be sent over
126 * @param msg The MAVLink message to compress the data into
127 * @param data_stream C-struct to read the message contents from
129 static inline uint16_t mavlink_msg_data_stream_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_data_stream_t* data_stream)
131 return mavlink_msg_data_stream_pack_chan(system_id, component_id, chan, msg, data_stream->stream_id, data_stream->message_rate, data_stream->on_off);
135 * @brief Send a data_stream message
136 * @param chan MAVLink channel to send the message
138 * @param stream_id The ID of the requested data stream
139 * @param message_rate The requested interval between two messages of this type
140 * @param on_off 1 stream is enabled, 0 stream is stopped.
142 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
144 static inline void mavlink_msg_data_stream_send(mavlink_channel_t chan, uint8_t stream_id, uint16_t message_rate, uint8_t on_off)
146 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
147 char buf[MAVLINK_MSG_ID_DATA_STREAM_LEN];
148 _mav_put_uint16_t(buf, 0, message_rate);
149 _mav_put_uint8_t(buf, 2, stream_id);
150 _mav_put_uint8_t(buf, 3, on_off);
152 #if MAVLINK_CRC_EXTRA
153 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_STREAM, buf, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC);
154 #else
155 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_STREAM, buf, MAVLINK_MSG_ID_DATA_STREAM_LEN);
156 #endif
157 #else
158 mavlink_data_stream_t packet;
159 packet.message_rate = message_rate;
160 packet.stream_id = stream_id;
161 packet.on_off = on_off;
163 #if MAVLINK_CRC_EXTRA
164 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_STREAM, (const char *)&packet, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC);
165 #else
166 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_STREAM, (const char *)&packet, MAVLINK_MSG_ID_DATA_STREAM_LEN);
167 #endif
168 #endif
171 #if MAVLINK_MSG_ID_DATA_STREAM_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_data_stream_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t stream_id, uint16_t message_rate, uint8_t on_off)
181 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
182 char *buf = (char *)msgbuf;
183 _mav_put_uint16_t(buf, 0, message_rate);
184 _mav_put_uint8_t(buf, 2, stream_id);
185 _mav_put_uint8_t(buf, 3, on_off);
187 #if MAVLINK_CRC_EXTRA
188 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_STREAM, buf, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC);
189 #else
190 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_STREAM, buf, MAVLINK_MSG_ID_DATA_STREAM_LEN);
191 #endif
192 #else
193 mavlink_data_stream_t *packet = (mavlink_data_stream_t *)msgbuf;
194 packet->message_rate = message_rate;
195 packet->stream_id = stream_id;
196 packet->on_off = on_off;
198 #if MAVLINK_CRC_EXTRA
199 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_STREAM, (const char *)packet, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC);
200 #else
201 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_STREAM, (const char *)packet, MAVLINK_MSG_ID_DATA_STREAM_LEN);
202 #endif
203 #endif
205 #endif
207 #endif
209 // MESSAGE DATA_STREAM UNPACKING
213 * @brief Get field stream_id from data_stream message
215 * @return The ID of the requested data stream
217 static inline uint8_t mavlink_msg_data_stream_get_stream_id(const mavlink_message_t* msg)
219 return _MAV_RETURN_uint8_t(msg, 2);
223 * @brief Get field message_rate from data_stream message
225 * @return The requested interval between two messages of this type
227 static inline uint16_t mavlink_msg_data_stream_get_message_rate(const mavlink_message_t* msg)
229 return _MAV_RETURN_uint16_t(msg, 0);
233 * @brief Get field on_off from data_stream message
235 * @return 1 stream is enabled, 0 stream is stopped.
237 static inline uint8_t mavlink_msg_data_stream_get_on_off(const mavlink_message_t* msg)
239 return _MAV_RETURN_uint8_t(msg, 3);
243 * @brief Decode a data_stream message into a struct
245 * @param msg The message to decode
246 * @param data_stream C-struct to decode the message contents into
248 static inline void mavlink_msg_data_stream_decode(const mavlink_message_t* msg, mavlink_data_stream_t* data_stream)
250 #if MAVLINK_NEED_BYTE_SWAP
251 data_stream->message_rate = mavlink_msg_data_stream_get_message_rate(msg);
252 data_stream->stream_id = mavlink_msg_data_stream_get_stream_id(msg);
253 data_stream->on_off = mavlink_msg_data_stream_get_on_off(msg);
254 #else
255 memcpy(data_stream, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_DATA_STREAM_LEN);
256 #endif