2 // MESSAGE SERIAL_CONTROL PACKING
4 #define MAVLINK_MSG_ID_SERIAL_CONTROL 126
7 typedef struct __mavlink_serial_control_t
{
8 uint32_t baudrate
; /*< [bits/s] Baudrate of transfer. Zero means no change.*/
9 uint16_t timeout
; /*< [ms] Timeout for reply data*/
10 uint8_t device
; /*< Serial control device type.*/
11 uint8_t flags
; /*< Bitmap of serial control flags.*/
12 uint8_t count
; /*< [bytes] how many bytes in this transfer*/
13 uint8_t data
[70]; /*< serial data*/
14 } mavlink_serial_control_t
;
16 #define MAVLINK_MSG_ID_SERIAL_CONTROL_LEN 79
17 #define MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN 79
18 #define MAVLINK_MSG_ID_126_LEN 79
19 #define MAVLINK_MSG_ID_126_MIN_LEN 79
21 #define MAVLINK_MSG_ID_SERIAL_CONTROL_CRC 220
22 #define MAVLINK_MSG_ID_126_CRC 220
24 #define MAVLINK_MSG_SERIAL_CONTROL_FIELD_DATA_LEN 70
26 #if MAVLINK_COMMAND_24BIT
27 #define MAVLINK_MESSAGE_INFO_SERIAL_CONTROL { \
31 { { "device", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_serial_control_t, device) }, \
32 { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_serial_control_t, flags) }, \
33 { "timeout", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_serial_control_t, timeout) }, \
34 { "baudrate", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_serial_control_t, baudrate) }, \
35 { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_serial_control_t, count) }, \
36 { "data", NULL, MAVLINK_TYPE_UINT8_T, 70, 9, offsetof(mavlink_serial_control_t, data) }, \
40 #define MAVLINK_MESSAGE_INFO_SERIAL_CONTROL { \
43 { { "device", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_serial_control_t, device) }, \
44 { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_serial_control_t, flags) }, \
45 { "timeout", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_serial_control_t, timeout) }, \
46 { "baudrate", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_serial_control_t, baudrate) }, \
47 { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_serial_control_t, count) }, \
48 { "data", NULL, MAVLINK_TYPE_UINT8_T, 70, 9, offsetof(mavlink_serial_control_t, data) }, \
54 * @brief Pack a serial_control message
55 * @param system_id ID of this system
56 * @param component_id ID of this component (e.g. 200 for IMU)
57 * @param msg The MAVLink message to compress the data into
59 * @param device Serial control device type.
60 * @param flags Bitmap of serial control flags.
61 * @param timeout [ms] Timeout for reply data
62 * @param baudrate [bits/s] Baudrate of transfer. Zero means no change.
63 * @param count [bytes] how many bytes in this transfer
64 * @param data serial data
65 * @return length of the message in bytes (excluding serial stream start sign)
67 static inline uint16_t mavlink_msg_serial_control_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
,
68 uint8_t device
, uint8_t flags
, uint16_t timeout
, uint32_t baudrate
, uint8_t count
, const uint8_t *data
)
70 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 char buf
[MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
];
72 _mav_put_uint32_t(buf
, 0, baudrate
);
73 _mav_put_uint16_t(buf
, 4, timeout
);
74 _mav_put_uint8_t(buf
, 6, device
);
75 _mav_put_uint8_t(buf
, 7, flags
);
76 _mav_put_uint8_t(buf
, 8, count
);
77 _mav_put_uint8_t_array(buf
, 9, data
, 70);
78 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
);
80 mavlink_serial_control_t packet
;
81 packet
.baudrate
= baudrate
;
82 packet
.timeout
= timeout
;
83 packet
.device
= device
;
86 mav_array_memcpy(packet
.data
, data
, sizeof(uint8_t)*70);
87 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
);
90 msg
->msgid
= MAVLINK_MSG_ID_SERIAL_CONTROL
;
91 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC
);
95 * @brief Pack a serial_control message on a channel
96 * @param system_id ID of this system
97 * @param component_id ID of this component (e.g. 200 for IMU)
98 * @param chan The MAVLink channel this message will be sent over
99 * @param msg The MAVLink message to compress the data into
100 * @param device Serial control device type.
101 * @param flags Bitmap of serial control flags.
102 * @param timeout [ms] Timeout for reply data
103 * @param baudrate [bits/s] Baudrate of transfer. Zero means no change.
104 * @param count [bytes] how many bytes in this transfer
105 * @param data serial data
106 * @return length of the message in bytes (excluding serial stream start sign)
108 static inline uint16_t mavlink_msg_serial_control_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
109 mavlink_message_t
* msg
,
110 uint8_t device
,uint8_t flags
,uint16_t timeout
,uint32_t baudrate
,uint8_t count
,const uint8_t *data
)
112 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 char buf
[MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
];
114 _mav_put_uint32_t(buf
, 0, baudrate
);
115 _mav_put_uint16_t(buf
, 4, timeout
);
116 _mav_put_uint8_t(buf
, 6, device
);
117 _mav_put_uint8_t(buf
, 7, flags
);
118 _mav_put_uint8_t(buf
, 8, count
);
119 _mav_put_uint8_t_array(buf
, 9, data
, 70);
120 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
);
122 mavlink_serial_control_t packet
;
123 packet
.baudrate
= baudrate
;
124 packet
.timeout
= timeout
;
125 packet
.device
= device
;
126 packet
.flags
= flags
;
127 packet
.count
= count
;
128 mav_array_memcpy(packet
.data
, data
, sizeof(uint8_t)*70);
129 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
);
132 msg
->msgid
= MAVLINK_MSG_ID_SERIAL_CONTROL
;
133 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC
);
137 * @brief Encode a serial_control struct
139 * @param system_id ID of this system
140 * @param component_id ID of this component (e.g. 200 for IMU)
141 * @param msg The MAVLink message to compress the data into
142 * @param serial_control C-struct to read the message contents from
144 static inline uint16_t mavlink_msg_serial_control_encode(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
, const mavlink_serial_control_t
* serial_control
)
146 return mavlink_msg_serial_control_pack(system_id
, component_id
, msg
, serial_control
->device
, serial_control
->flags
, serial_control
->timeout
, serial_control
->baudrate
, serial_control
->count
, serial_control
->data
);
150 * @brief Encode a serial_control struct on a channel
152 * @param system_id ID of this system
153 * @param component_id ID of this component (e.g. 200 for IMU)
154 * @param chan The MAVLink channel this message will be sent over
155 * @param msg The MAVLink message to compress the data into
156 * @param serial_control C-struct to read the message contents from
158 static inline uint16_t mavlink_msg_serial_control_encode_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
, mavlink_message_t
* msg
, const mavlink_serial_control_t
* serial_control
)
160 return mavlink_msg_serial_control_pack_chan(system_id
, component_id
, chan
, msg
, serial_control
->device
, serial_control
->flags
, serial_control
->timeout
, serial_control
->baudrate
, serial_control
->count
, serial_control
->data
);
164 * @brief Send a serial_control message
165 * @param chan MAVLink channel to send the message
167 * @param device Serial control device type.
168 * @param flags Bitmap of serial control flags.
169 * @param timeout [ms] Timeout for reply data
170 * @param baudrate [bits/s] Baudrate of transfer. Zero means no change.
171 * @param count [bytes] how many bytes in this transfer
172 * @param data serial data
174 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
176 static inline void mavlink_msg_serial_control_send(mavlink_channel_t chan
, uint8_t device
, uint8_t flags
, uint16_t timeout
, uint32_t baudrate
, uint8_t count
, const uint8_t *data
)
178 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
179 char buf
[MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
];
180 _mav_put_uint32_t(buf
, 0, baudrate
);
181 _mav_put_uint16_t(buf
, 4, timeout
);
182 _mav_put_uint8_t(buf
, 6, device
);
183 _mav_put_uint8_t(buf
, 7, flags
);
184 _mav_put_uint8_t(buf
, 8, count
);
185 _mav_put_uint8_t_array(buf
, 9, data
, 70);
186 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SERIAL_CONTROL
, buf
, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC
);
188 mavlink_serial_control_t packet
;
189 packet
.baudrate
= baudrate
;
190 packet
.timeout
= timeout
;
191 packet
.device
= device
;
192 packet
.flags
= flags
;
193 packet
.count
= count
;
194 mav_array_memcpy(packet
.data
, data
, sizeof(uint8_t)*70);
195 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SERIAL_CONTROL
, (const char *)&packet
, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC
);
200 * @brief Send a serial_control message
201 * @param chan MAVLink channel to send the message
202 * @param struct The MAVLink struct to serialize
204 static inline void mavlink_msg_serial_control_send_struct(mavlink_channel_t chan
, const mavlink_serial_control_t
* serial_control
)
206 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
207 mavlink_msg_serial_control_send(chan
, serial_control
->device
, serial_control
->flags
, serial_control
->timeout
, serial_control
->baudrate
, serial_control
->count
, serial_control
->data
);
209 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SERIAL_CONTROL
, (const char *)serial_control
, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC
);
213 #if MAVLINK_MSG_ID_SERIAL_CONTROL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
215 This varient of _send() can be used to save stack space by re-using
216 memory from the receive buffer. The caller provides a
217 mavlink_message_t which is the size of a full mavlink message. This
218 is usually the receive buffer for the channel, and allows a reply to an
219 incoming message with minimum stack space usage.
221 static inline void mavlink_msg_serial_control_send_buf(mavlink_message_t
*msgbuf
, mavlink_channel_t chan
, uint8_t device
, uint8_t flags
, uint16_t timeout
, uint32_t baudrate
, uint8_t count
, const uint8_t *data
)
223 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
224 char *buf
= (char *)msgbuf
;
225 _mav_put_uint32_t(buf
, 0, baudrate
);
226 _mav_put_uint16_t(buf
, 4, timeout
);
227 _mav_put_uint8_t(buf
, 6, device
);
228 _mav_put_uint8_t(buf
, 7, flags
);
229 _mav_put_uint8_t(buf
, 8, count
);
230 _mav_put_uint8_t_array(buf
, 9, data
, 70);
231 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SERIAL_CONTROL
, buf
, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC
);
233 mavlink_serial_control_t
*packet
= (mavlink_serial_control_t
*)msgbuf
;
234 packet
->baudrate
= baudrate
;
235 packet
->timeout
= timeout
;
236 packet
->device
= device
;
237 packet
->flags
= flags
;
238 packet
->count
= count
;
239 mav_array_memcpy(packet
->data
, data
, sizeof(uint8_t)*70);
240 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SERIAL_CONTROL
, (const char *)packet
, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC
);
247 // MESSAGE SERIAL_CONTROL UNPACKING
251 * @brief Get field device from serial_control message
253 * @return Serial control device type.
255 static inline uint8_t mavlink_msg_serial_control_get_device(const mavlink_message_t
* msg
)
257 return _MAV_RETURN_uint8_t(msg
, 6);
261 * @brief Get field flags from serial_control message
263 * @return Bitmap of serial control flags.
265 static inline uint8_t mavlink_msg_serial_control_get_flags(const mavlink_message_t
* msg
)
267 return _MAV_RETURN_uint8_t(msg
, 7);
271 * @brief Get field timeout from serial_control message
273 * @return [ms] Timeout for reply data
275 static inline uint16_t mavlink_msg_serial_control_get_timeout(const mavlink_message_t
* msg
)
277 return _MAV_RETURN_uint16_t(msg
, 4);
281 * @brief Get field baudrate from serial_control message
283 * @return [bits/s] Baudrate of transfer. Zero means no change.
285 static inline uint32_t mavlink_msg_serial_control_get_baudrate(const mavlink_message_t
* msg
)
287 return _MAV_RETURN_uint32_t(msg
, 0);
291 * @brief Get field count from serial_control message
293 * @return [bytes] how many bytes in this transfer
295 static inline uint8_t mavlink_msg_serial_control_get_count(const mavlink_message_t
* msg
)
297 return _MAV_RETURN_uint8_t(msg
, 8);
301 * @brief Get field data from serial_control message
303 * @return serial data
305 static inline uint16_t mavlink_msg_serial_control_get_data(const mavlink_message_t
* msg
, uint8_t *data
)
307 return _MAV_RETURN_uint8_t_array(msg
, data
, 70, 9);
311 * @brief Decode a serial_control message into a struct
313 * @param msg The message to decode
314 * @param serial_control C-struct to decode the message contents into
316 static inline void mavlink_msg_serial_control_decode(const mavlink_message_t
* msg
, mavlink_serial_control_t
* serial_control
)
318 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
319 serial_control
->baudrate
= mavlink_msg_serial_control_get_baudrate(msg
);
320 serial_control
->timeout
= mavlink_msg_serial_control_get_timeout(msg
);
321 serial_control
->device
= mavlink_msg_serial_control_get_device(msg
);
322 serial_control
->flags
= mavlink_msg_serial_control_get_flags(msg
);
323 serial_control
->count
= mavlink_msg_serial_control_get_count(msg
);
324 mavlink_msg_serial_control_get_data(msg
, serial_control
->data
);
326 uint8_t len
= msg
->len
< MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
? msg
->len
: MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
;
327 memset(serial_control
, 0, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN
);
328 memcpy(serial_control
, _MAV_PAYLOAD(msg
), len
);