Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_memory_vect.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE MEMORY_VECT PACKING
3
4#define MAVLINK_MSG_ID_MEMORY_VECT 249
5
6
7typedef struct __mavlink_memory_vect_t {
8 uint16_t address; /*< Starting address of the debug variables*/
9 uint8_t ver; /*< Version code of the type variable. 0=unknown, type ignored and assumed int16_t. 1=as below*/
10 uint8_t type; /*< Type code of the memory variables. for ver = 1: 0=16 x int16_t, 1=16 x uint16_t, 2=16 x Q15, 3=16 x 1Q14*/
11 int8_t value[32]; /*< Memory contents at specified address*/
12} mavlink_memory_vect_t;
13
14#define MAVLINK_MSG_ID_MEMORY_VECT_LEN 36
15#define MAVLINK_MSG_ID_MEMORY_VECT_MIN_LEN 36
16#define MAVLINK_MSG_ID_249_LEN 36
17#define MAVLINK_MSG_ID_249_MIN_LEN 36
18
19#define MAVLINK_MSG_ID_MEMORY_VECT_CRC 204
20#define MAVLINK_MSG_ID_249_CRC 204
21
22#define MAVLINK_MSG_MEMORY_VECT_FIELD_VALUE_LEN 32
23
24#if MAVLINK_COMMAND_24BIT
25#define MAVLINK_MESSAGE_INFO_MEMORY_VECT {
26 249,
27 "MEMORY_VECT",
28 4,
29 { { "address", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_memory_vect_t, address) },
30 { "ver", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_memory_vect_t, ver) },
31 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_memory_vect_t, type) },
32 { "value", NULL, MAVLINK_TYPE_INT8_T, 32, 4, offsetof(mavlink_memory_vect_t, value) },
33 } \
34}
35#else
36#define MAVLINK_MESSAGE_INFO_MEMORY_VECT {
37 "MEMORY_VECT",
38 4,
39 { { "address", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_memory_vect_t, address) },
40 { "ver", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_memory_vect_t, ver) },
41 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_memory_vect_t, type) },
42 { "value", NULL, MAVLINK_TYPE_INT8_T, 32, 4, offsetof(mavlink_memory_vect_t, value) },
43 } \
44}
45#endif
46
47/**
48 * @brief Pack a memory_vect message
49 * @param system_id ID of this system
50 * @param component_id ID of this component (e.g. 200 for IMU)
51 * @param msg The MAVLink message to compress the data into
52 *
53 * @param address Starting address of the debug variables
54 * @param ver Version code of the type variable. 0=unknown, type ignored and assumed int16_t. 1=as below
55 * @param type Type code of the memory variables. for ver = 1: 0=16 x int16_t, 1=16 x uint16_t, 2=16 x Q15, 3=16 x 1Q14
56 * @param value Memory contents at specified address
57 * @return length of the message in bytes (excluding serial stream start sign)
58 */
59static inline uint16_t mavlink_msg_memory_vect_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
60 uint16_t address, uint8_t ver, uint8_t type, const int8_t *value)
61{
62#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
64 _mav_put_uint16_t(buf, 0, address);
65 _mav_put_uint8_t(buf, 2, ver);
66 _mav_put_uint8_t(buf, 3, type);
67 _mav_put_int8_t_array(buf, 4, value, 32);
68 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MEMORY_VECT_LEN);
69#else
70 mavlink_memory_vect_t packet;
71 packet.address = address;
72 packet.ver = ver;
73 packet.type = type;
74 mav_array_memcpy(packet.value, value, sizeof(int8_t)*32);
75 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MEMORY_VECT_LEN);
76#endif
77
78 msg->msgid = MAVLINK_MSG_ID_MEMORY_VECT;
79 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MEMORY_VECT_MIN_LEN, MAVLINK_MSG_ID_MEMORY_VECT_LEN, MAVLINK_MSG_ID_MEMORY_VECT_CRC);
80}
81
82/**
83 * @brief Pack a memory_vect message
84 * @param system_id ID of this system
85 * @param component_id ID of this component (e.g. 200 for IMU)
86 * @param status MAVLink status structure
87 * @param msg The MAVLink message to compress the data into
88 *
89 * @param address Starting address of the debug variables
90 * @param ver Version code of the type variable. 0=unknown, type ignored and assumed int16_t. 1=as below
91 * @param type Type code of the memory variables. for ver = 1: 0=16 x int16_t, 1=16 x uint16_t, 2=16 x Q15, 3=16 x 1Q14
92 * @param value Memory contents at specified address
93 * @return length of the message in bytes (excluding serial stream start sign)
94 */
95static inline uint16_t mavlink_msg_memory_vect_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
96 uint16_t address, uint8_t ver, uint8_t type, const int8_t *value)
97{
98#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
100 _mav_put_uint16_t(buf, 0, address);
101 _mav_put_uint8_t(buf, 2, ver);
102 _mav_put_uint8_t(buf, 3, type);
103 _mav_put_int8_t_array(buf, 4, value, 32);
104 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MEMORY_VECT_LEN);
105#else
106 mavlink_memory_vect_t packet;
107 packet.address = address;
108 packet.ver = ver;
109 packet.type = type;
110 mav_array_memcpy(packet.value, value, sizeof(int8_t)*32);
111 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MEMORY_VECT_LEN);
112#endif
113
114 msg->msgid = MAVLINK_MSG_ID_MEMORY_VECT;
115#if MAVLINK_CRC_EXTRA
116 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MEMORY_VECT_MIN_LEN, MAVLINK_MSG_ID_MEMORY_VECT_LEN, MAVLINK_MSG_ID_MEMORY_VECT_CRC);
117#else
118 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MEMORY_VECT_MIN_LEN, MAVLINK_MSG_ID_MEMORY_VECT_LEN);
119#endif
120}
121
122/**
123 * @brief Pack a memory_vect message on a channel
124 * @param system_id ID of this system
125 * @param component_id ID of this component (e.g. 200 for IMU)
126 * @param chan The MAVLink channel this message will be sent over
127 * @param msg The MAVLink message to compress the data into
128 * @param address Starting address of the debug variables
129 * @param ver Version code of the type variable. 0=unknown, type ignored and assumed int16_t. 1=as below
130 * @param type Type code of the memory variables. for ver = 1: 0=16 x int16_t, 1=16 x uint16_t, 2=16 x Q15, 3=16 x 1Q14
131 * @param value Memory contents at specified address
132 * @return length of the message in bytes (excluding serial stream start sign)
133 */
134static inline uint16_t mavlink_msg_memory_vect_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
135 mavlink_message_t* msg,
136 uint16_t address,uint8_t ver,uint8_t type,const int8_t *value)
137{
138#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
140 _mav_put_uint16_t(buf, 0, address);
141 _mav_put_uint8_t(buf, 2, ver);
142 _mav_put_uint8_t(buf, 3, type);
143 _mav_put_int8_t_array(buf, 4, value, 32);
144 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MEMORY_VECT_LEN);
145#else
146 mavlink_memory_vect_t packet;
147 packet.address = address;
148 packet.ver = ver;
149 packet.type = type;
150 mav_array_memcpy(packet.value, value, sizeof(int8_t)*32);
151 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MEMORY_VECT_LEN);
152#endif
153
154 msg->msgid = MAVLINK_MSG_ID_MEMORY_VECT;
155 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MEMORY_VECT_MIN_LEN, MAVLINK_MSG_ID_MEMORY_VECT_LEN, MAVLINK_MSG_ID_MEMORY_VECT_CRC);
156}
157
158/**
159 * @brief Encode a memory_vect struct
160 *
161 * @param system_id ID of this system
162 * @param component_id ID of this component (e.g. 200 for IMU)
163 * @param msg The MAVLink message to compress the data into
164 * @param memory_vect C-struct to read the message contents from
165 */
166static inline uint16_t mavlink_msg_memory_vect_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_memory_vect_t* memory_vect)
167{
168 return mavlink_msg_memory_vect_pack(system_id, component_id, msg, memory_vect->address, memory_vect->ver, memory_vect->type, memory_vect->value);
169}
170
171/**
172 * @brief Encode a memory_vect struct on a channel
173 *
174 * @param system_id ID of this system
175 * @param component_id ID of this component (e.g. 200 for IMU)
176 * @param chan The MAVLink channel this message will be sent over
177 * @param msg The MAVLink message to compress the data into
178 * @param memory_vect C-struct to read the message contents from
179 */
180static inline uint16_t mavlink_msg_memory_vect_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_memory_vect_t* memory_vect)
181{
182 return mavlink_msg_memory_vect_pack_chan(system_id, component_id, chan, msg, memory_vect->address, memory_vect->ver, memory_vect->type, memory_vect->value);
183}
184
185/**
186 * @brief Encode a memory_vect struct with provided status structure
187 *
188 * @param system_id ID of this system
189 * @param component_id ID of this component (e.g. 200 for IMU)
190 * @param status MAVLink status structure
191 * @param msg The MAVLink message to compress the data into
192 * @param memory_vect C-struct to read the message contents from
193 */
194static inline uint16_t mavlink_msg_memory_vect_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_memory_vect_t* memory_vect)
195{
196 return mavlink_msg_memory_vect_pack_status(system_id, component_id, _status, msg, memory_vect->address, memory_vect->ver, memory_vect->type, memory_vect->value);
197}
198
199/**
200 * @brief Send a memory_vect message
201 * @param chan MAVLink channel to send the message
202 *
203 * @param address Starting address of the debug variables
204 * @param ver Version code of the type variable. 0=unknown, type ignored and assumed int16_t. 1=as below
205 * @param type Type code of the memory variables. for ver = 1: 0=16 x int16_t, 1=16 x uint16_t, 2=16 x Q15, 3=16 x 1Q14
206 * @param value Memory contents at specified address
207 */
208#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
209
210static inline void mavlink_msg_memory_vect_send(mavlink_channel_t chan, uint16_t address, uint8_t ver, uint8_t type, const int8_t *value)
211{
212#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
213 char buf[MAVLINK_MSG_ID_MEMORY_VECT_LEN];
214 _mav_put_uint16_t(buf, 0, address);
215 _mav_put_uint8_t(buf, 2, ver);
216 _mav_put_uint8_t(buf, 3, type);
217 _mav_put_int8_t_array(buf, 4, value, 32);
218 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MEMORY_VECT, buf, MAVLINK_MSG_ID_MEMORY_VECT_MIN_LEN, MAVLINK_MSG_ID_MEMORY_VECT_LEN, MAVLINK_MSG_ID_MEMORY_VECT_CRC);
219#else
220 mavlink_memory_vect_t packet;
221 packet.address = address;
222 packet.ver = ver;
223 packet.type = type;
224 mav_array_memcpy(packet.value, value, sizeof(int8_t)*32);
225 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MEMORY_VECT, (const char *)&packet, MAVLINK_MSG_ID_MEMORY_VECT_MIN_LEN, MAVLINK_MSG_ID_MEMORY_VECT_LEN, MAVLINK_MSG_ID_MEMORY_VECT_CRC);
226#endif
227}
228
229/**
230 * @brief Send a memory_vect message
231 * @param chan MAVLink channel to send the message
232 * @param struct The MAVLink struct to serialize
233 */
234static inline void mavlink_msg_memory_vect_send_struct(mavlink_channel_t chan, const mavlink_memory_vect_t* memory_vect)
235{
236#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
237 mavlink_msg_memory_vect_send(chan, memory_vect->address, memory_vect->ver, memory_vect->type, memory_vect->value);
238#else
239 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MEMORY_VECT, (const char *)memory_vect, MAVLINK_MSG_ID_MEMORY_VECT_MIN_LEN, MAVLINK_MSG_ID_MEMORY_VECT_LEN, MAVLINK_MSG_ID_MEMORY_VECT_CRC);
240#endif
241}
242
243#if MAVLINK_MSG_ID_MEMORY_VECT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
244/*
245 This variant of _send() can be used to save stack space by reusing
246 memory from the receive buffer. The caller provides a
247 mavlink_message_t which is the size of a full mavlink message. This
248 is usually the receive buffer for the channel, and allows a reply to an
249 incoming message with minimum stack space usage.
250 */
251static inline void mavlink_msg_memory_vect_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t address, uint8_t ver, uint8_t type, const int8_t *value)
252{
253#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
254 char *buf = (char *)msgbuf;
255 _mav_put_uint16_t(buf, 0, address);
256 _mav_put_uint8_t(buf, 2, ver);
257 _mav_put_uint8_t(buf, 3, type);
258 _mav_put_int8_t_array(buf, 4, value, 32);
259 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MEMORY_VECT, buf, MAVLINK_MSG_ID_MEMORY_VECT_MIN_LEN, MAVLINK_MSG_ID_MEMORY_VECT_LEN, MAVLINK_MSG_ID_MEMORY_VECT_CRC);
260#else
261 mavlink_memory_vect_t *packet = (mavlink_memory_vect_t *)msgbuf;
262 packet->address = address;
263 packet->ver = ver;
264 packet->type = type;
265 mav_array_memcpy(packet->value, value, sizeof(int8_t)*32);
266 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MEMORY_VECT, (const char *)packet, MAVLINK_MSG_ID_MEMORY_VECT_MIN_LEN, MAVLINK_MSG_ID_MEMORY_VECT_LEN, MAVLINK_MSG_ID_MEMORY_VECT_CRC);
267#endif
268}
269#endif
270
271#endif
272
273// MESSAGE MEMORY_VECT UNPACKING
274
275
276/**
277 * @brief Get field address from memory_vect message
278 *
279 * @return Starting address of the debug variables
280 */
281static inline uint16_t mavlink_msg_memory_vect_get_address(const mavlink_message_t* msg)
282{
283 return _MAV_RETURN_uint16_t(msg, 0);
284}
285
286/**
287 * @brief Get field ver from memory_vect message
288 *
289 * @return Version code of the type variable. 0=unknown, type ignored and assumed int16_t. 1=as below
290 */
291static inline uint8_t mavlink_msg_memory_vect_get_ver(const mavlink_message_t* msg)
292{
293 return _MAV_RETURN_uint8_t(msg, 2);
294}
295
296/**
297 * @brief Get field type from memory_vect message
298 *
299 * @return Type code of the memory variables. for ver = 1: 0=16 x int16_t, 1=16 x uint16_t, 2=16 x Q15, 3=16 x 1Q14
300 */
301static inline uint8_t mavlink_msg_memory_vect_get_type(const mavlink_message_t* msg)
302{
303 return _MAV_RETURN_uint8_t(msg, 3);
304}
305
306/**
307 * @brief Get field value from memory_vect message
308 *
309 * @return Memory contents at specified address
310 */
311static inline uint16_t mavlink_msg_memory_vect_get_value(const mavlink_message_t* msg, int8_t *value)
312{
313 return _MAV_RETURN_int8_t_array(msg, value, 32, 4);
314}
315
316/**
317 * @brief Decode a memory_vect message into a struct
318 *
319 * @param msg The message to decode
320 * @param memory_vect C-struct to decode the message contents into
321 */
322static inline void mavlink_msg_memory_vect_decode(const mavlink_message_t* msg, mavlink_memory_vect_t* memory_vect)
323{
324#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
325 memory_vect->address = mavlink_msg_memory_vect_get_address(msg);
326 memory_vect->ver = mavlink_msg_memory_vect_get_ver(msg);
327 memory_vect->type = mavlink_msg_memory_vect_get_type(msg);
328 mavlink_msg_memory_vect_get_value(msg, memory_vect->value);
329#else
330 uint8_t len = msg->len < MAVLINK_MSG_ID_MEMORY_VECT_LEN? msg->len : MAVLINK_MSG_ID_MEMORY_VECT_LEN;
331 memset(memory_vect, 0, MAVLINK_MSG_ID_MEMORY_VECT_LEN);
332 memcpy(memory_vect, _MAV_PAYLOAD(msg), len);
333#endif
334}