2 // MESSAGE DATA_STREAM PACKING
4 #define MAVLINK_MSG_ID_DATA_STREAM 67
7 typedef struct __mavlink_data_stream_t
{
8 uint16_t message_rate
; /*< The message rate*/
9 uint8_t stream_id
; /*< The ID of the requested data stream*/
10 uint8_t on_off
; /*< 1 stream is enabled, 0 stream is stopped.*/
11 }) mavlink_data_stream_t
;
13 #define MAVLINK_MSG_ID_DATA_STREAM_LEN 4
14 #define MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN 4
15 #define MAVLINK_MSG_ID_67_LEN 4
16 #define MAVLINK_MSG_ID_67_MIN_LEN 4
18 #define MAVLINK_MSG_ID_DATA_STREAM_CRC 21
19 #define MAVLINK_MSG_ID_67_CRC 21
23 #if MAVLINK_COMMAND_24BIT
24 #define MAVLINK_MESSAGE_INFO_DATA_STREAM { \
28 { { "message_rate", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_data_stream_t, message_rate) }, \
29 { "stream_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_data_stream_t, stream_id) }, \
30 { "on_off", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_data_stream_t, on_off) }, \
34 #define MAVLINK_MESSAGE_INFO_DATA_STREAM { \
37 { { "message_rate", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_data_stream_t, message_rate) }, \
38 { "stream_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_data_stream_t, stream_id) }, \
39 { "on_off", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_data_stream_t, on_off) }, \
45 * @brief Pack a data_stream message
46 * @param system_id ID of this system
47 * @param component_id ID of this component (e.g. 200 for IMU)
48 * @param msg The MAVLink message to compress the data into
50 * @param stream_id The ID of the requested data stream
51 * @param message_rate The message rate
52 * @param on_off 1 stream is enabled, 0 stream is stopped.
53 * @return length of the message in bytes (excluding serial stream start sign)
55 static inline uint16_t mavlink_msg_data_stream_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
,
56 uint8_t stream_id
, uint16_t message_rate
, uint8_t on_off
)
58 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
59 char buf
[MAVLINK_MSG_ID_DATA_STREAM_LEN
];
60 _mav_put_uint16_t(buf
, 0, message_rate
);
61 _mav_put_uint8_t(buf
, 2, stream_id
);
62 _mav_put_uint8_t(buf
, 3, on_off
);
64 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_DATA_STREAM_LEN
);
66 mavlink_data_stream_t packet
;
67 packet
.message_rate
= message_rate
;
68 packet
.stream_id
= stream_id
;
69 packet
.on_off
= on_off
;
71 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_DATA_STREAM_LEN
);
74 msg
->msgid
= MAVLINK_MSG_ID_DATA_STREAM
;
75 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN
, MAVLINK_MSG_ID_DATA_STREAM_LEN
, MAVLINK_MSG_ID_DATA_STREAM_CRC
);
79 * @brief Pack a data_stream message on a channel
80 * @param system_id ID of this system
81 * @param component_id ID of this component (e.g. 200 for IMU)
82 * @param chan The MAVLink channel this message will be sent over
83 * @param msg The MAVLink message to compress the data into
84 * @param stream_id The ID of the requested data stream
85 * @param message_rate The message rate
86 * @param on_off 1 stream is enabled, 0 stream is stopped.
87 * @return length of the message in bytes (excluding serial stream start sign)
89 static inline uint16_t mavlink_msg_data_stream_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
90 mavlink_message_t
* msg
,
91 uint8_t stream_id
,uint16_t message_rate
,uint8_t on_off
)
93 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
94 char buf
[MAVLINK_MSG_ID_DATA_STREAM_LEN
];
95 _mav_put_uint16_t(buf
, 0, message_rate
);
96 _mav_put_uint8_t(buf
, 2, stream_id
);
97 _mav_put_uint8_t(buf
, 3, on_off
);
99 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_DATA_STREAM_LEN
);
101 mavlink_data_stream_t packet
;
102 packet
.message_rate
= message_rate
;
103 packet
.stream_id
= stream_id
;
104 packet
.on_off
= on_off
;
106 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_DATA_STREAM_LEN
);
109 msg
->msgid
= MAVLINK_MSG_ID_DATA_STREAM
;
110 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN
, MAVLINK_MSG_ID_DATA_STREAM_LEN
, MAVLINK_MSG_ID_DATA_STREAM_CRC
);
114 * @brief Encode a data_stream struct
116 * @param system_id ID of this system
117 * @param component_id ID of this component (e.g. 200 for IMU)
118 * @param msg The MAVLink message to compress the data into
119 * @param data_stream C-struct to read the message contents from
121 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
)
123 return mavlink_msg_data_stream_pack(system_id
, component_id
, msg
, data_stream
->stream_id
, data_stream
->message_rate
, data_stream
->on_off
);
127 * @brief Encode a data_stream struct on a channel
129 * @param system_id ID of this system
130 * @param component_id ID of this component (e.g. 200 for IMU)
131 * @param chan The MAVLink channel this message will be sent over
132 * @param msg The MAVLink message to compress the data into
133 * @param data_stream C-struct to read the message contents from
135 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
)
137 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
);
141 * @brief Send a data_stream message
142 * @param chan MAVLink channel to send the message
144 * @param stream_id The ID of the requested data stream
145 * @param message_rate The message rate
146 * @param on_off 1 stream is enabled, 0 stream is stopped.
148 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
150 static inline void mavlink_msg_data_stream_send(mavlink_channel_t chan
, uint8_t stream_id
, uint16_t message_rate
, uint8_t on_off
)
152 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
153 char buf
[MAVLINK_MSG_ID_DATA_STREAM_LEN
];
154 _mav_put_uint16_t(buf
, 0, message_rate
);
155 _mav_put_uint8_t(buf
, 2, stream_id
);
156 _mav_put_uint8_t(buf
, 3, on_off
);
158 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_DATA_STREAM
, buf
, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN
, MAVLINK_MSG_ID_DATA_STREAM_LEN
, MAVLINK_MSG_ID_DATA_STREAM_CRC
);
160 mavlink_data_stream_t packet
;
161 packet
.message_rate
= message_rate
;
162 packet
.stream_id
= stream_id
;
163 packet
.on_off
= on_off
;
165 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_DATA_STREAM
, (const char *)&packet
, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN
, MAVLINK_MSG_ID_DATA_STREAM_LEN
, MAVLINK_MSG_ID_DATA_STREAM_CRC
);
170 * @brief Send a data_stream message
171 * @param chan MAVLink channel to send the message
172 * @param struct The MAVLink struct to serialize
174 static inline void mavlink_msg_data_stream_send_struct(mavlink_channel_t chan
, const mavlink_data_stream_t
* data_stream
)
176 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
177 mavlink_msg_data_stream_send(chan
, data_stream
->stream_id
, data_stream
->message_rate
, data_stream
->on_off
);
179 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_DATA_STREAM
, (const char *)data_stream
, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN
, MAVLINK_MSG_ID_DATA_STREAM_LEN
, MAVLINK_MSG_ID_DATA_STREAM_CRC
);
183 #if MAVLINK_MSG_ID_DATA_STREAM_LEN <= MAVLINK_MAX_PAYLOAD_LEN
185 This varient of _send() can be used to save stack space by re-using
186 memory from the receive buffer. The caller provides a
187 mavlink_message_t which is the size of a full mavlink message. This
188 is usually the receive buffer for the channel, and allows a reply to an
189 incoming message with minimum stack space usage.
191 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
)
193 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
194 char *buf
= (char *)msgbuf
;
195 _mav_put_uint16_t(buf
, 0, message_rate
);
196 _mav_put_uint8_t(buf
, 2, stream_id
);
197 _mav_put_uint8_t(buf
, 3, on_off
);
199 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_DATA_STREAM
, buf
, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN
, MAVLINK_MSG_ID_DATA_STREAM_LEN
, MAVLINK_MSG_ID_DATA_STREAM_CRC
);
201 mavlink_data_stream_t
*packet
= (mavlink_data_stream_t
*)msgbuf
;
202 packet
->message_rate
= message_rate
;
203 packet
->stream_id
= stream_id
;
204 packet
->on_off
= on_off
;
206 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_DATA_STREAM
, (const char *)packet
, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN
, MAVLINK_MSG_ID_DATA_STREAM_LEN
, MAVLINK_MSG_ID_DATA_STREAM_CRC
);
213 // MESSAGE DATA_STREAM UNPACKING
217 * @brief Get field stream_id from data_stream message
219 * @return The ID of the requested data stream
221 static inline uint8_t mavlink_msg_data_stream_get_stream_id(const mavlink_message_t
* msg
)
223 return _MAV_RETURN_uint8_t(msg
, 2);
227 * @brief Get field message_rate from data_stream message
229 * @return The message rate
231 static inline uint16_t mavlink_msg_data_stream_get_message_rate(const mavlink_message_t
* msg
)
233 return _MAV_RETURN_uint16_t(msg
, 0);
237 * @brief Get field on_off from data_stream message
239 * @return 1 stream is enabled, 0 stream is stopped.
241 static inline uint8_t mavlink_msg_data_stream_get_on_off(const mavlink_message_t
* msg
)
243 return _MAV_RETURN_uint8_t(msg
, 3);
247 * @brief Decode a data_stream message into a struct
249 * @param msg The message to decode
250 * @param data_stream C-struct to decode the message contents into
252 static inline void mavlink_msg_data_stream_decode(const mavlink_message_t
* msg
, mavlink_data_stream_t
* data_stream
)
254 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
255 data_stream
->message_rate
= mavlink_msg_data_stream_get_message_rate(msg
);
256 data_stream
->stream_id
= mavlink_msg_data_stream_get_stream_id(msg
);
257 data_stream
->on_off
= mavlink_msg_data_stream_get_on_off(msg
);
259 uint8_t len
= msg
->len
< MAVLINK_MSG_ID_DATA_STREAM_LEN
? msg
->len
: MAVLINK_MSG_ID_DATA_STREAM_LEN
;
260 memset(data_stream
, 0, MAVLINK_MSG_ID_DATA_STREAM_LEN
);
261 memcpy(data_stream
, _MAV_PAYLOAD(msg
), len
);