RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_device_op_read_reply.h
1#pragma once
2// MESSAGE DEVICE_OP_READ_REPLY PACKING
3
4#define MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY 11001
5
6MAVPACKED(
7typedef struct __mavlink_device_op_read_reply_t {
8 uint32_t request_id; /*< request ID - copied from request*/
9 uint8_t result; /*< 0 for success, anything else is failure code*/
10 uint8_t regstart; /*< starting register*/
11 uint8_t count; /*< count of bytes read*/
12 uint8_t data[128]; /*< reply data*/
13}) mavlink_device_op_read_reply_t;
14
15#define MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN 135
16#define MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_MIN_LEN 135
17#define MAVLINK_MSG_ID_11001_LEN 135
18#define MAVLINK_MSG_ID_11001_MIN_LEN 135
19
20#define MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_CRC 15
21#define MAVLINK_MSG_ID_11001_CRC 15
22
23#define MAVLINK_MSG_DEVICE_OP_READ_REPLY_FIELD_DATA_LEN 128
24
25#if MAVLINK_COMMAND_24BIT
26#define MAVLINK_MESSAGE_INFO_DEVICE_OP_READ_REPLY { \
27 11001, \
28 "DEVICE_OP_READ_REPLY", \
29 5, \
30 { { "request_id", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_device_op_read_reply_t, request_id) }, \
31 { "result", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_device_op_read_reply_t, result) }, \
32 { "regstart", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_device_op_read_reply_t, regstart) }, \
33 { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_device_op_read_reply_t, count) }, \
34 { "data", NULL, MAVLINK_TYPE_UINT8_T, 128, 7, offsetof(mavlink_device_op_read_reply_t, data) }, \
35 } \
36}
37#else
38#define MAVLINK_MESSAGE_INFO_DEVICE_OP_READ_REPLY { \
39 "DEVICE_OP_READ_REPLY", \
40 5, \
41 { { "request_id", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_device_op_read_reply_t, request_id) }, \
42 { "result", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_device_op_read_reply_t, result) }, \
43 { "regstart", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_device_op_read_reply_t, regstart) }, \
44 { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_device_op_read_reply_t, count) }, \
45 { "data", NULL, MAVLINK_TYPE_UINT8_T, 128, 7, offsetof(mavlink_device_op_read_reply_t, data) }, \
46 } \
47}
48#endif
49
50/**
51 * @brief Pack a device_op_read_reply 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
55 *
56 * @param request_id request ID - copied from request
57 * @param result 0 for success, anything else is failure code
58 * @param regstart starting register
59 * @param count count of bytes read
60 * @param data reply data
61 * @return length of the message in bytes (excluding serial stream start sign)
62 */
63static inline uint16_t mavlink_msg_device_op_read_reply_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
64 uint32_t request_id, uint8_t result, uint8_t regstart, uint8_t count, const uint8_t *data)
65{
66#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
67 char buf[MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN];
68 _mav_put_uint32_t(buf, 0, request_id);
69 _mav_put_uint8_t(buf, 4, result);
70 _mav_put_uint8_t(buf, 5, regstart);
71 _mav_put_uint8_t(buf, 6, count);
72 _mav_put_uint8_t_array(buf, 7, data, 128);
73 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN);
74#else
75 mavlink_device_op_read_reply_t packet;
76 packet.request_id = request_id;
77 packet.result = result;
78 packet.regstart = regstart;
79 packet.count = count;
80 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*128);
81 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN);
82#endif
83
84 msg->msgid = MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY;
85 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_CRC);
86}
87
88/**
89 * @brief Pack a device_op_read_reply message on a channel
90 * @param system_id ID of this system
91 * @param component_id ID of this component (e.g. 200 for IMU)
92 * @param chan The MAVLink channel this message will be sent over
93 * @param msg The MAVLink message to compress the data into
94 * @param request_id request ID - copied from request
95 * @param result 0 for success, anything else is failure code
96 * @param regstart starting register
97 * @param count count of bytes read
98 * @param data reply data
99 * @return length of the message in bytes (excluding serial stream start sign)
100 */
101static inline uint16_t mavlink_msg_device_op_read_reply_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
102 mavlink_message_t* msg,
103 uint32_t request_id,uint8_t result,uint8_t regstart,uint8_t count,const uint8_t *data)
104{
105#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
106 char buf[MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN];
107 _mav_put_uint32_t(buf, 0, request_id);
108 _mav_put_uint8_t(buf, 4, result);
109 _mav_put_uint8_t(buf, 5, regstart);
110 _mav_put_uint8_t(buf, 6, count);
111 _mav_put_uint8_t_array(buf, 7, data, 128);
112 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN);
113#else
114 mavlink_device_op_read_reply_t packet;
115 packet.request_id = request_id;
116 packet.result = result;
117 packet.regstart = regstart;
118 packet.count = count;
119 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*128);
120 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN);
121#endif
122
123 msg->msgid = MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY;
124 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_CRC);
125}
126
127/**
128 * @brief Encode a device_op_read_reply struct
129 *
130 * @param system_id ID of this system
131 * @param component_id ID of this component (e.g. 200 for IMU)
132 * @param msg The MAVLink message to compress the data into
133 * @param device_op_read_reply C-struct to read the message contents from
134 */
135static inline uint16_t mavlink_msg_device_op_read_reply_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_device_op_read_reply_t* device_op_read_reply)
136{
137 return mavlink_msg_device_op_read_reply_pack(system_id, component_id, msg, device_op_read_reply->request_id, device_op_read_reply->result, device_op_read_reply->regstart, device_op_read_reply->count, device_op_read_reply->data);
138}
139
140/**
141 * @brief Encode a device_op_read_reply struct on a channel
142 *
143 * @param system_id ID of this system
144 * @param component_id ID of this component (e.g. 200 for IMU)
145 * @param chan The MAVLink channel this message will be sent over
146 * @param msg The MAVLink message to compress the data into
147 * @param device_op_read_reply C-struct to read the message contents from
148 */
149static inline uint16_t mavlink_msg_device_op_read_reply_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_device_op_read_reply_t* device_op_read_reply)
150{
151 return mavlink_msg_device_op_read_reply_pack_chan(system_id, component_id, chan, msg, device_op_read_reply->request_id, device_op_read_reply->result, device_op_read_reply->regstart, device_op_read_reply->count, device_op_read_reply->data);
152}
153
154/**
155 * @brief Send a device_op_read_reply message
156 * @param chan MAVLink channel to send the message
157 *
158 * @param request_id request ID - copied from request
159 * @param result 0 for success, anything else is failure code
160 * @param regstart starting register
161 * @param count count of bytes read
162 * @param data reply data
163 */
164#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
165
166static inline void mavlink_msg_device_op_read_reply_send(mavlink_channel_t chan, uint32_t request_id, uint8_t result, uint8_t regstart, uint8_t count, const uint8_t *data)
167{
168#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
169 char buf[MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN];
170 _mav_put_uint32_t(buf, 0, request_id);
171 _mav_put_uint8_t(buf, 4, result);
172 _mav_put_uint8_t(buf, 5, regstart);
173 _mav_put_uint8_t(buf, 6, count);
174 _mav_put_uint8_t_array(buf, 7, data, 128);
175 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY, buf, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_CRC);
176#else
177 mavlink_device_op_read_reply_t packet;
178 packet.request_id = request_id;
179 packet.result = result;
180 packet.regstart = regstart;
181 packet.count = count;
182 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*128);
183 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY, (const char *)&packet, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_CRC);
184#endif
185}
186
187/**
188 * @brief Send a device_op_read_reply message
189 * @param chan MAVLink channel to send the message
190 * @param struct The MAVLink struct to serialize
191 */
192static inline void mavlink_msg_device_op_read_reply_send_struct(mavlink_channel_t chan, const mavlink_device_op_read_reply_t* device_op_read_reply)
193{
194#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
195 mavlink_msg_device_op_read_reply_send(chan, device_op_read_reply->request_id, device_op_read_reply->result, device_op_read_reply->regstart, device_op_read_reply->count, device_op_read_reply->data);
196#else
197 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY, (const char *)device_op_read_reply, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_CRC);
198#endif
199}
200
201#if MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN <= MAVLINK_MAX_PAYLOAD_LEN
202/*
203 This varient of _send() can be used to save stack space by re-using
204 memory from the receive buffer. The caller provides a
205 mavlink_message_t which is the size of a full mavlink message. This
206 is usually the receive buffer for the channel, and allows a reply to an
207 incoming message with minimum stack space usage.
208 */
209static inline void mavlink_msg_device_op_read_reply_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t request_id, uint8_t result, uint8_t regstart, uint8_t count, const uint8_t *data)
210{
211#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
212 char *buf = (char *)msgbuf;
213 _mav_put_uint32_t(buf, 0, request_id);
214 _mav_put_uint8_t(buf, 4, result);
215 _mav_put_uint8_t(buf, 5, regstart);
216 _mav_put_uint8_t(buf, 6, count);
217 _mav_put_uint8_t_array(buf, 7, data, 128);
218 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY, buf, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_CRC);
219#else
220 mavlink_device_op_read_reply_t *packet = (mavlink_device_op_read_reply_t *)msgbuf;
221 packet->request_id = request_id;
222 packet->result = result;
223 packet->regstart = regstart;
224 packet->count = count;
225 mav_array_memcpy(packet->data, data, sizeof(uint8_t)*128);
226 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY, (const char *)packet, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_CRC);
227#endif
228}
229#endif
230
231#endif
232
233// MESSAGE DEVICE_OP_READ_REPLY UNPACKING
234
235
236/**
237 * @brief Get field request_id from device_op_read_reply message
238 *
239 * @return request ID - copied from request
240 */
241static inline uint32_t mavlink_msg_device_op_read_reply_get_request_id(const mavlink_message_t* msg)
242{
243 return _MAV_RETURN_uint32_t(msg, 0);
244}
245
246/**
247 * @brief Get field result from device_op_read_reply message
248 *
249 * @return 0 for success, anything else is failure code
250 */
251static inline uint8_t mavlink_msg_device_op_read_reply_get_result(const mavlink_message_t* msg)
252{
253 return _MAV_RETURN_uint8_t(msg, 4);
254}
255
256/**
257 * @brief Get field regstart from device_op_read_reply message
258 *
259 * @return starting register
260 */
261static inline uint8_t mavlink_msg_device_op_read_reply_get_regstart(const mavlink_message_t* msg)
262{
263 return _MAV_RETURN_uint8_t(msg, 5);
264}
265
266/**
267 * @brief Get field count from device_op_read_reply message
268 *
269 * @return count of bytes read
270 */
271static inline uint8_t mavlink_msg_device_op_read_reply_get_count(const mavlink_message_t* msg)
272{
273 return _MAV_RETURN_uint8_t(msg, 6);
274}
275
276/**
277 * @brief Get field data from device_op_read_reply message
278 *
279 * @return reply data
280 */
281static inline uint16_t mavlink_msg_device_op_read_reply_get_data(const mavlink_message_t* msg, uint8_t *data)
282{
283 return _MAV_RETURN_uint8_t_array(msg, data, 128, 7);
284}
285
286/**
287 * @brief Decode a device_op_read_reply message into a struct
288 *
289 * @param msg The message to decode
290 * @param device_op_read_reply C-struct to decode the message contents into
291 */
292static inline void mavlink_msg_device_op_read_reply_decode(const mavlink_message_t* msg, mavlink_device_op_read_reply_t* device_op_read_reply)
293{
294#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
295 device_op_read_reply->request_id = mavlink_msg_device_op_read_reply_get_request_id(msg);
296 device_op_read_reply->result = mavlink_msg_device_op_read_reply_get_result(msg);
297 device_op_read_reply->regstart = mavlink_msg_device_op_read_reply_get_regstart(msg);
298 device_op_read_reply->count = mavlink_msg_device_op_read_reply_get_count(msg);
299 mavlink_msg_device_op_read_reply_get_data(msg, device_op_read_reply->data);
300#else
301 uint8_t len = msg->len < MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN? msg->len : MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN;
302 memset(device_op_read_reply, 0, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN);
303 memcpy(device_op_read_reply, _MAV_PAYLOAD(msg), len);
304#endif
305}