source: flair-src/branches/mavlink/tools/Controller/Mavlink/src/include/common/mavlink_msg_named_value_int.h@ 75

Last change on this file since 75 was 75, checked in by Thomas Fuhrmann, 8 years ago

Change the version of mavlink generated messages and rename it to include

File size: 10.4 KB
Line 
1// MESSAGE NAMED_VALUE_INT PACKING
2
3#define MAVLINK_MSG_ID_NAMED_VALUE_INT 252
4
5typedef struct MAVLINK_PACKED __mavlink_named_value_int_t
6{
7 uint32_t time_boot_ms; /*< Timestamp (milliseconds since system boot)*/
8 int32_t value; /*< Signed integer value*/
9 char name[10]; /*< Name of the debug variable*/
10} mavlink_named_value_int_t;
11
12#define MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN 18
13#define MAVLINK_MSG_ID_NAMED_VALUE_INT_MIN_LEN 18
14#define MAVLINK_MSG_ID_252_LEN 18
15#define MAVLINK_MSG_ID_252_MIN_LEN 18
16
17#define MAVLINK_MSG_ID_NAMED_VALUE_INT_CRC 44
18#define MAVLINK_MSG_ID_252_CRC 44
19
20#define MAVLINK_MSG_NAMED_VALUE_INT_FIELD_NAME_LEN 10
21
22#if MAVLINK_COMMAND_24BIT
23#define MAVLINK_MESSAGE_INFO_NAMED_VALUE_INT { \
24 252, \
25 "NAMED_VALUE_INT", \
26 3, \
27 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_named_value_int_t, time_boot_ms) }, \
28 { "value", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_named_value_int_t, value) }, \
29 { "name", NULL, MAVLINK_TYPE_CHAR, 10, 8, offsetof(mavlink_named_value_int_t, name) }, \
30 } \
31}
32#else
33#define MAVLINK_MESSAGE_INFO_NAMED_VALUE_INT { \
34 "NAMED_VALUE_INT", \
35 3, \
36 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_named_value_int_t, time_boot_ms) }, \
37 { "value", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_named_value_int_t, value) }, \
38 { "name", NULL, MAVLINK_TYPE_CHAR, 10, 8, offsetof(mavlink_named_value_int_t, name) }, \
39 } \
40}
41#endif
42
43/**
44 * @brief Pack a named_value_int message
45 * @param system_id ID of this system
46 * @param component_id ID of this component (e.g. 200 for IMU)
47 * @param msg The MAVLink message to compress the data into
48 *
49 * @param time_boot_ms Timestamp (milliseconds since system boot)
50 * @param name Name of the debug variable
51 * @param value Signed integer value
52 * @return length of the message in bytes (excluding serial stream start sign)
53 */
54static inline uint16_t mavlink_msg_named_value_int_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
55 uint32_t time_boot_ms, const char *name, int32_t value)
56{
57#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
58 char buf[MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN];
59 _mav_put_uint32_t(buf, 0, time_boot_ms);
60 _mav_put_int32_t(buf, 4, value);
61 _mav_put_char_array(buf, 8, name, 10);
62 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN);
63#else
64 mavlink_named_value_int_t packet;
65 packet.time_boot_ms = time_boot_ms;
66 packet.value = value;
67 mav_array_memcpy(packet.name, name, sizeof(char)*10);
68 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN);
69#endif
70
71 msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_INT;
72 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_NAMED_VALUE_INT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_CRC);
73}
74
75/**
76 * @brief Pack a named_value_int message on a channel
77 * @param system_id ID of this system
78 * @param component_id ID of this component (e.g. 200 for IMU)
79 * @param chan The MAVLink channel this message will be sent over
80 * @param msg The MAVLink message to compress the data into
81 * @param time_boot_ms Timestamp (milliseconds since system boot)
82 * @param name Name of the debug variable
83 * @param value Signed integer value
84 * @return length of the message in bytes (excluding serial stream start sign)
85 */
86static inline uint16_t mavlink_msg_named_value_int_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
87 mavlink_message_t* msg,
88 uint32_t time_boot_ms,const char *name,int32_t value)
89{
90#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
91 char buf[MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN];
92 _mav_put_uint32_t(buf, 0, time_boot_ms);
93 _mav_put_int32_t(buf, 4, value);
94 _mav_put_char_array(buf, 8, name, 10);
95 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN);
96#else
97 mavlink_named_value_int_t packet;
98 packet.time_boot_ms = time_boot_ms;
99 packet.value = value;
100 mav_array_memcpy(packet.name, name, sizeof(char)*10);
101 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN);
102#endif
103
104 msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_INT;
105 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_NAMED_VALUE_INT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_CRC);
106}
107
108/**
109 * @brief Encode a named_value_int struct
110 *
111 * @param system_id ID of this system
112 * @param component_id ID of this component (e.g. 200 for IMU)
113 * @param msg The MAVLink message to compress the data into
114 * @param named_value_int C-struct to read the message contents from
115 */
116static inline uint16_t mavlink_msg_named_value_int_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_named_value_int_t* named_value_int)
117{
118 return mavlink_msg_named_value_int_pack(system_id, component_id, msg, named_value_int->time_boot_ms, named_value_int->name, named_value_int->value);
119}
120
121/**
122 * @brief Encode a named_value_int struct on a channel
123 *
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 named_value_int C-struct to read the message contents from
129 */
130static inline uint16_t mavlink_msg_named_value_int_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_named_value_int_t* named_value_int)
131{
132 return mavlink_msg_named_value_int_pack_chan(system_id, component_id, chan, msg, named_value_int->time_boot_ms, named_value_int->name, named_value_int->value);
133}
134
135/**
136 * @brief Send a named_value_int message
137 * @param chan MAVLink channel to send the message
138 *
139 * @param time_boot_ms Timestamp (milliseconds since system boot)
140 * @param name Name of the debug variable
141 * @param value Signed integer value
142 */
143#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
144
145static inline void mavlink_msg_named_value_int_send(mavlink_channel_t chan, uint32_t time_boot_ms, const char *name, int32_t value)
146{
147#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
148 char buf[MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN];
149 _mav_put_uint32_t(buf, 0, time_boot_ms);
150 _mav_put_int32_t(buf, 4, value);
151 _mav_put_char_array(buf, 8, name, 10);
152 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAMED_VALUE_INT, buf, MAVLINK_MSG_ID_NAMED_VALUE_INT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_CRC);
153#else
154 mavlink_named_value_int_t packet;
155 packet.time_boot_ms = time_boot_ms;
156 packet.value = value;
157 mav_array_memcpy(packet.name, name, sizeof(char)*10);
158 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAMED_VALUE_INT, (const char *)&packet, MAVLINK_MSG_ID_NAMED_VALUE_INT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_CRC);
159#endif
160}
161
162/**
163 * @brief Send a named_value_int message
164 * @param chan MAVLink channel to send the message
165 * @param struct The MAVLink struct to serialize
166 */
167static inline void mavlink_msg_named_value_int_send_struct(mavlink_channel_t chan, const mavlink_named_value_int_t* named_value_int)
168{
169#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
170 mavlink_msg_named_value_int_send(chan, named_value_int->time_boot_ms, named_value_int->name, named_value_int->value);
171#else
172 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAMED_VALUE_INT, (const char *)named_value_int, MAVLINK_MSG_ID_NAMED_VALUE_INT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_CRC);
173#endif
174}
175
176#if MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
177/*
178 This varient of _send() can be used to save stack space by re-using
179 memory from the receive buffer. The caller provides a
180 mavlink_message_t which is the size of a full mavlink message. This
181 is usually the receive buffer for the channel, and allows a reply to an
182 incoming message with minimum stack space usage.
183 */
184static inline void mavlink_msg_named_value_int_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, const char *name, int32_t value)
185{
186#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
187 char *buf = (char *)msgbuf;
188 _mav_put_uint32_t(buf, 0, time_boot_ms);
189 _mav_put_int32_t(buf, 4, value);
190 _mav_put_char_array(buf, 8, name, 10);
191 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAMED_VALUE_INT, buf, MAVLINK_MSG_ID_NAMED_VALUE_INT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_CRC);
192#else
193 mavlink_named_value_int_t *packet = (mavlink_named_value_int_t *)msgbuf;
194 packet->time_boot_ms = time_boot_ms;
195 packet->value = value;
196 mav_array_memcpy(packet->name, name, sizeof(char)*10);
197 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAMED_VALUE_INT, (const char *)packet, MAVLINK_MSG_ID_NAMED_VALUE_INT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_CRC);
198#endif
199}
200#endif
201
202#endif
203
204// MESSAGE NAMED_VALUE_INT UNPACKING
205
206
207/**
208 * @brief Get field time_boot_ms from named_value_int message
209 *
210 * @return Timestamp (milliseconds since system boot)
211 */
212static inline uint32_t mavlink_msg_named_value_int_get_time_boot_ms(const mavlink_message_t* msg)
213{
214 return _MAV_RETURN_uint32_t(msg, 0);
215}
216
217/**
218 * @brief Get field name from named_value_int message
219 *
220 * @return Name of the debug variable
221 */
222static inline uint16_t mavlink_msg_named_value_int_get_name(const mavlink_message_t* msg, char *name)
223{
224 return _MAV_RETURN_char_array(msg, name, 10, 8);
225}
226
227/**
228 * @brief Get field value from named_value_int message
229 *
230 * @return Signed integer value
231 */
232static inline int32_t mavlink_msg_named_value_int_get_value(const mavlink_message_t* msg)
233{
234 return _MAV_RETURN_int32_t(msg, 4);
235}
236
237/**
238 * @brief Decode a named_value_int message into a struct
239 *
240 * @param msg The message to decode
241 * @param named_value_int C-struct to decode the message contents into
242 */
243static inline void mavlink_msg_named_value_int_decode(const mavlink_message_t* msg, mavlink_named_value_int_t* named_value_int)
244{
245#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
246 named_value_int->time_boot_ms = mavlink_msg_named_value_int_get_time_boot_ms(msg);
247 named_value_int->value = mavlink_msg_named_value_int_get_value(msg);
248 mavlink_msg_named_value_int_get_name(msg, named_value_int->name);
249#else
250 uint8_t len = msg->len < MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN? msg->len : MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN;
251 memset(named_value_int, 0, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN);
252 memcpy(named_value_int, _MAV_PAYLOAD(msg), len);
253#endif
254}
Note: See TracBrowser for help on using the repository browser.