RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_device_op_write.h
1#pragma once
2// MESSAGE DEVICE_OP_WRITE PACKING
3
4#define MAVLINK_MSG_ID_DEVICE_OP_WRITE 11002
5
6MAVPACKED(
7typedef struct __mavlink_device_op_write_t {
8 uint32_t request_id; /*< request ID - copied to reply*/
9 uint8_t target_system; /*< System ID*/
10 uint8_t target_component; /*< Component ID*/
11 uint8_t bustype; /*< The bus type*/
12 uint8_t bus; /*< Bus number*/
13 uint8_t address; /*< Bus address*/
14 char busname[40]; /*< Name of device on bus (for SPI)*/
15 uint8_t regstart; /*< First register to write*/
16 uint8_t count; /*< count of registers to write*/
17 uint8_t data[128]; /*< write data*/
18}) mavlink_device_op_write_t;
19
20#define MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN 179
21#define MAVLINK_MSG_ID_DEVICE_OP_WRITE_MIN_LEN 179
22#define MAVLINK_MSG_ID_11002_LEN 179
23#define MAVLINK_MSG_ID_11002_MIN_LEN 179
24
25#define MAVLINK_MSG_ID_DEVICE_OP_WRITE_CRC 234
26#define MAVLINK_MSG_ID_11002_CRC 234
27
28#define MAVLINK_MSG_DEVICE_OP_WRITE_FIELD_BUSNAME_LEN 40
29#define MAVLINK_MSG_DEVICE_OP_WRITE_FIELD_DATA_LEN 128
30
31#if MAVLINK_COMMAND_24BIT
32#define MAVLINK_MESSAGE_INFO_DEVICE_OP_WRITE { \
33 11002, \
34 "DEVICE_OP_WRITE", \
35 10, \
36 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_device_op_write_t, target_system) }, \
37 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_device_op_write_t, target_component) }, \
38 { "request_id", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_device_op_write_t, request_id) }, \
39 { "bustype", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_device_op_write_t, bustype) }, \
40 { "bus", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_device_op_write_t, bus) }, \
41 { "address", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_device_op_write_t, address) }, \
42 { "busname", NULL, MAVLINK_TYPE_CHAR, 40, 9, offsetof(mavlink_device_op_write_t, busname) }, \
43 { "regstart", NULL, MAVLINK_TYPE_UINT8_T, 0, 49, offsetof(mavlink_device_op_write_t, regstart) }, \
44 { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 50, offsetof(mavlink_device_op_write_t, count) }, \
45 { "data", NULL, MAVLINK_TYPE_UINT8_T, 128, 51, offsetof(mavlink_device_op_write_t, data) }, \
46 } \
47}
48#else
49#define MAVLINK_MESSAGE_INFO_DEVICE_OP_WRITE { \
50 "DEVICE_OP_WRITE", \
51 10, \
52 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_device_op_write_t, target_system) }, \
53 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_device_op_write_t, target_component) }, \
54 { "request_id", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_device_op_write_t, request_id) }, \
55 { "bustype", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_device_op_write_t, bustype) }, \
56 { "bus", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_device_op_write_t, bus) }, \
57 { "address", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_device_op_write_t, address) }, \
58 { "busname", NULL, MAVLINK_TYPE_CHAR, 40, 9, offsetof(mavlink_device_op_write_t, busname) }, \
59 { "regstart", NULL, MAVLINK_TYPE_UINT8_T, 0, 49, offsetof(mavlink_device_op_write_t, regstart) }, \
60 { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 50, offsetof(mavlink_device_op_write_t, count) }, \
61 { "data", NULL, MAVLINK_TYPE_UINT8_T, 128, 51, offsetof(mavlink_device_op_write_t, data) }, \
62 } \
63}
64#endif
65
84static inline uint16_t mavlink_msg_device_op_write_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
85 uint8_t target_system, uint8_t target_component, uint32_t request_id, uint8_t bustype, uint8_t bus, uint8_t address, const char *busname, uint8_t regstart, uint8_t count, const uint8_t *data)
86{
87#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
88 char buf[MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN];
89 _mav_put_uint32_t(buf, 0, request_id);
90 _mav_put_uint8_t(buf, 4, target_system);
91 _mav_put_uint8_t(buf, 5, target_component);
92 _mav_put_uint8_t(buf, 6, bustype);
93 _mav_put_uint8_t(buf, 7, bus);
94 _mav_put_uint8_t(buf, 8, address);
95 _mav_put_uint8_t(buf, 49, regstart);
96 _mav_put_uint8_t(buf, 50, count);
97 _mav_put_char_array(buf, 9, busname, 40);
98 _mav_put_uint8_t_array(buf, 51, data, 128);
99 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN);
100#else
101 mavlink_device_op_write_t packet;
102 packet.request_id = request_id;
103 packet.target_system = target_system;
104 packet.target_component = target_component;
105 packet.bustype = bustype;
106 packet.bus = bus;
107 packet.address = address;
108 packet.regstart = regstart;
109 packet.count = count;
110 mav_array_memcpy(packet.busname, busname, sizeof(char)*40);
111 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*128);
112 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN);
113#endif
114
115 msg->msgid = MAVLINK_MSG_ID_DEVICE_OP_WRITE;
116 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DEVICE_OP_WRITE_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_CRC);
117}
118
137static inline uint16_t mavlink_msg_device_op_write_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
138 mavlink_message_t* msg,
139 uint8_t target_system,uint8_t target_component,uint32_t request_id,uint8_t bustype,uint8_t bus,uint8_t address,const char *busname,uint8_t regstart,uint8_t count,const uint8_t *data)
140{
141#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
142 char buf[MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN];
143 _mav_put_uint32_t(buf, 0, request_id);
144 _mav_put_uint8_t(buf, 4, target_system);
145 _mav_put_uint8_t(buf, 5, target_component);
146 _mav_put_uint8_t(buf, 6, bustype);
147 _mav_put_uint8_t(buf, 7, bus);
148 _mav_put_uint8_t(buf, 8, address);
149 _mav_put_uint8_t(buf, 49, regstart);
150 _mav_put_uint8_t(buf, 50, count);
151 _mav_put_char_array(buf, 9, busname, 40);
152 _mav_put_uint8_t_array(buf, 51, data, 128);
153 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN);
154#else
155 mavlink_device_op_write_t packet;
156 packet.request_id = request_id;
157 packet.target_system = target_system;
158 packet.target_component = target_component;
159 packet.bustype = bustype;
160 packet.bus = bus;
161 packet.address = address;
162 packet.regstart = regstart;
163 packet.count = count;
164 mav_array_memcpy(packet.busname, busname, sizeof(char)*40);
165 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*128);
166 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN);
167#endif
168
169 msg->msgid = MAVLINK_MSG_ID_DEVICE_OP_WRITE;
170 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DEVICE_OP_WRITE_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_CRC);
171}
172
181static inline uint16_t mavlink_msg_device_op_write_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_device_op_write_t* device_op_write)
182{
183 return mavlink_msg_device_op_write_pack(system_id, component_id, msg, device_op_write->target_system, device_op_write->target_component, device_op_write->request_id, device_op_write->bustype, device_op_write->bus, device_op_write->address, device_op_write->busname, device_op_write->regstart, device_op_write->count, device_op_write->data);
184}
185
195static inline uint16_t mavlink_msg_device_op_write_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_device_op_write_t* device_op_write)
196{
197 return mavlink_msg_device_op_write_pack_chan(system_id, component_id, chan, msg, device_op_write->target_system, device_op_write->target_component, device_op_write->request_id, device_op_write->bustype, device_op_write->bus, device_op_write->address, device_op_write->busname, device_op_write->regstart, device_op_write->count, device_op_write->data);
198}
199
215#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
216
217static inline void mavlink_msg_device_op_write_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint32_t request_id, uint8_t bustype, uint8_t bus, uint8_t address, const char *busname, uint8_t regstart, uint8_t count, const uint8_t *data)
218{
219#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
220 char buf[MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN];
221 _mav_put_uint32_t(buf, 0, request_id);
222 _mav_put_uint8_t(buf, 4, target_system);
223 _mav_put_uint8_t(buf, 5, target_component);
224 _mav_put_uint8_t(buf, 6, bustype);
225 _mav_put_uint8_t(buf, 7, bus);
226 _mav_put_uint8_t(buf, 8, address);
227 _mav_put_uint8_t(buf, 49, regstart);
228 _mav_put_uint8_t(buf, 50, count);
229 _mav_put_char_array(buf, 9, busname, 40);
230 _mav_put_uint8_t_array(buf, 51, data, 128);
231 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEVICE_OP_WRITE, buf, MAVLINK_MSG_ID_DEVICE_OP_WRITE_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_CRC);
232#else
233 mavlink_device_op_write_t packet;
234 packet.request_id = request_id;
235 packet.target_system = target_system;
236 packet.target_component = target_component;
237 packet.bustype = bustype;
238 packet.bus = bus;
239 packet.address = address;
240 packet.regstart = regstart;
241 packet.count = count;
242 mav_array_memcpy(packet.busname, busname, sizeof(char)*40);
243 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*128);
244 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEVICE_OP_WRITE, (const char *)&packet, MAVLINK_MSG_ID_DEVICE_OP_WRITE_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_CRC);
245#endif
246}
247
253static inline void mavlink_msg_device_op_write_send_struct(mavlink_channel_t chan, const mavlink_device_op_write_t* device_op_write)
254{
255#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
256 mavlink_msg_device_op_write_send(chan, device_op_write->target_system, device_op_write->target_component, device_op_write->request_id, device_op_write->bustype, device_op_write->bus, device_op_write->address, device_op_write->busname, device_op_write->regstart, device_op_write->count, device_op_write->data);
257#else
258 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEVICE_OP_WRITE, (const char *)device_op_write, MAVLINK_MSG_ID_DEVICE_OP_WRITE_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_CRC);
259#endif
260}
261
262#if MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
263/*
264 This varient of _send() can be used to save stack space by re-using
265 memory from the receive buffer. The caller provides a
266 mavlink_message_t which is the size of a full mavlink message. This
267 is usually the receive buffer for the channel, and allows a reply to an
268 incoming message with minimum stack space usage.
269 */
270static inline void mavlink_msg_device_op_write_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint32_t request_id, uint8_t bustype, uint8_t bus, uint8_t address, const char *busname, uint8_t regstart, uint8_t count, const uint8_t *data)
271{
272#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
273 char *buf = (char *)msgbuf;
274 _mav_put_uint32_t(buf, 0, request_id);
275 _mav_put_uint8_t(buf, 4, target_system);
276 _mav_put_uint8_t(buf, 5, target_component);
277 _mav_put_uint8_t(buf, 6, bustype);
278 _mav_put_uint8_t(buf, 7, bus);
279 _mav_put_uint8_t(buf, 8, address);
280 _mav_put_uint8_t(buf, 49, regstart);
281 _mav_put_uint8_t(buf, 50, count);
282 _mav_put_char_array(buf, 9, busname, 40);
283 _mav_put_uint8_t_array(buf, 51, data, 128);
284 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEVICE_OP_WRITE, buf, MAVLINK_MSG_ID_DEVICE_OP_WRITE_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_CRC);
285#else
286 mavlink_device_op_write_t *packet = (mavlink_device_op_write_t *)msgbuf;
287 packet->request_id = request_id;
288 packet->target_system = target_system;
289 packet->target_component = target_component;
290 packet->bustype = bustype;
291 packet->bus = bus;
292 packet->address = address;
293 packet->regstart = regstart;
294 packet->count = count;
295 mav_array_memcpy(packet->busname, busname, sizeof(char)*40);
296 mav_array_memcpy(packet->data, data, sizeof(uint8_t)*128);
297 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEVICE_OP_WRITE, (const char *)packet, MAVLINK_MSG_ID_DEVICE_OP_WRITE_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_CRC);
298#endif
299}
300#endif
301
302#endif
303
304// MESSAGE DEVICE_OP_WRITE UNPACKING
305
306
312static inline uint8_t mavlink_msg_device_op_write_get_target_system(const mavlink_message_t* msg)
313{
314 return _MAV_RETURN_uint8_t(msg, 4);
315}
316
322static inline uint8_t mavlink_msg_device_op_write_get_target_component(const mavlink_message_t* msg)
323{
324 return _MAV_RETURN_uint8_t(msg, 5);
325}
326
332static inline uint32_t mavlink_msg_device_op_write_get_request_id(const mavlink_message_t* msg)
333{
334 return _MAV_RETURN_uint32_t(msg, 0);
335}
336
342static inline uint8_t mavlink_msg_device_op_write_get_bustype(const mavlink_message_t* msg)
343{
344 return _MAV_RETURN_uint8_t(msg, 6);
345}
346
352static inline uint8_t mavlink_msg_device_op_write_get_bus(const mavlink_message_t* msg)
353{
354 return _MAV_RETURN_uint8_t(msg, 7);
355}
356
362static inline uint8_t mavlink_msg_device_op_write_get_address(const mavlink_message_t* msg)
363{
364 return _MAV_RETURN_uint8_t(msg, 8);
365}
366
372static inline uint16_t mavlink_msg_device_op_write_get_busname(const mavlink_message_t* msg, char *busname)
373{
374 return _MAV_RETURN_char_array(msg, busname, 40, 9);
375}
376
382static inline uint8_t mavlink_msg_device_op_write_get_regstart(const mavlink_message_t* msg)
383{
384 return _MAV_RETURN_uint8_t(msg, 49);
385}
386
392static inline uint8_t mavlink_msg_device_op_write_get_count(const mavlink_message_t* msg)
393{
394 return _MAV_RETURN_uint8_t(msg, 50);
395}
396
402static inline uint16_t mavlink_msg_device_op_write_get_data(const mavlink_message_t* msg, uint8_t *data)
403{
404 return _MAV_RETURN_uint8_t_array(msg, data, 128, 51);
405}
406
413static inline void mavlink_msg_device_op_write_decode(const mavlink_message_t* msg, mavlink_device_op_write_t* device_op_write)
414{
415#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
416 device_op_write->request_id = mavlink_msg_device_op_write_get_request_id(msg);
417 device_op_write->target_system = mavlink_msg_device_op_write_get_target_system(msg);
418 device_op_write->target_component = mavlink_msg_device_op_write_get_target_component(msg);
419 device_op_write->bustype = mavlink_msg_device_op_write_get_bustype(msg);
420 device_op_write->bus = mavlink_msg_device_op_write_get_bus(msg);
421 device_op_write->address = mavlink_msg_device_op_write_get_address(msg);
422 mavlink_msg_device_op_write_get_busname(msg, device_op_write->busname);
423 device_op_write->regstart = mavlink_msg_device_op_write_get_regstart(msg);
424 device_op_write->count = mavlink_msg_device_op_write_get_count(msg);
425 mavlink_msg_device_op_write_get_data(msg, device_op_write->data);
426#else
427 uint8_t len = msg->len < MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN? msg->len : MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN;
428 memset(device_op_write, 0, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN);
429 memcpy(device_op_write, _MAV_PAYLOAD(msg), len);
430#endif
431}