source: flair-src/trunk/tools/Controller/Mavlink/src/include/common/mavlink_msg_raw_pressure.h@ 137

Last change on this file since 137 was 88, checked in by Sanahuja Guillaume, 8 years ago

m

File size: 12.9 KB
Line 
1// MESSAGE RAW_PRESSURE PACKING
2
3#define MAVLINK_MSG_ID_RAW_PRESSURE 28
4
5typedef struct MAVLINK_PACKED __mavlink_raw_pressure_t
6{
7 uint64_t time_usec; /*< Timestamp (microseconds since UNIX epoch or microseconds since system boot)*/
8 int16_t press_abs; /*< Absolute pressure (raw)*/
9 int16_t press_diff1; /*< Differential pressure 1 (raw, 0 if nonexistant)*/
10 int16_t press_diff2; /*< Differential pressure 2 (raw, 0 if nonexistant)*/
11 int16_t temperature; /*< Raw Temperature measurement (raw)*/
12} mavlink_raw_pressure_t;
13
14#define MAVLINK_MSG_ID_RAW_PRESSURE_LEN 16
15#define MAVLINK_MSG_ID_RAW_PRESSURE_MIN_LEN 16
16#define MAVLINK_MSG_ID_28_LEN 16
17#define MAVLINK_MSG_ID_28_MIN_LEN 16
18
19#define MAVLINK_MSG_ID_RAW_PRESSURE_CRC 67
20#define MAVLINK_MSG_ID_28_CRC 67
21
22
23
24#if MAVLINK_COMMAND_24BIT
25#define MAVLINK_MESSAGE_INFO_RAW_PRESSURE { \
26 28, \
27 "RAW_PRESSURE", \
28 5, \
29 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_raw_pressure_t, time_usec) }, \
30 { "press_abs", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_raw_pressure_t, press_abs) }, \
31 { "press_diff1", NULL, MAVLINK_TYPE_INT16_T, 0, 10, offsetof(mavlink_raw_pressure_t, press_diff1) }, \
32 { "press_diff2", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_raw_pressure_t, press_diff2) }, \
33 { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_raw_pressure_t, temperature) }, \
34 } \
35}
36#else
37#define MAVLINK_MESSAGE_INFO_RAW_PRESSURE { \
38 "RAW_PRESSURE", \
39 5, \
40 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_raw_pressure_t, time_usec) }, \
41 { "press_abs", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_raw_pressure_t, press_abs) }, \
42 { "press_diff1", NULL, MAVLINK_TYPE_INT16_T, 0, 10, offsetof(mavlink_raw_pressure_t, press_diff1) }, \
43 { "press_diff2", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_raw_pressure_t, press_diff2) }, \
44 { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_raw_pressure_t, temperature) }, \
45 } \
46}
47#endif
48
49/**
50 * @brief Pack a raw_pressure message
51 * @param system_id ID of this system
52 * @param component_id ID of this component (e.g. 200 for IMU)
53 * @param msg The MAVLink message to compress the data into
54 *
55 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
56 * @param press_abs Absolute pressure (raw)
57 * @param press_diff1 Differential pressure 1 (raw, 0 if nonexistant)
58 * @param press_diff2 Differential pressure 2 (raw, 0 if nonexistant)
59 * @param temperature Raw Temperature measurement (raw)
60 * @return length of the message in bytes (excluding serial stream start sign)
61 */
62static inline uint16_t mavlink_msg_raw_pressure_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
63 uint64_t time_usec, int16_t press_abs, int16_t press_diff1, int16_t press_diff2, int16_t temperature)
64{
65#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
66 char buf[MAVLINK_MSG_ID_RAW_PRESSURE_LEN];
67 _mav_put_uint64_t(buf, 0, time_usec);
68 _mav_put_int16_t(buf, 8, press_abs);
69 _mav_put_int16_t(buf, 10, press_diff1);
70 _mav_put_int16_t(buf, 12, press_diff2);
71 _mav_put_int16_t(buf, 14, temperature);
72
73 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_PRESSURE_LEN);
74#else
75 mavlink_raw_pressure_t packet;
76 packet.time_usec = time_usec;
77 packet.press_abs = press_abs;
78 packet.press_diff1 = press_diff1;
79 packet.press_diff2 = press_diff2;
80 packet.temperature = temperature;
81
82 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_PRESSURE_LEN);
83#endif
84
85 msg->msgid = MAVLINK_MSG_ID_RAW_PRESSURE;
86 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RAW_PRESSURE_MIN_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_CRC);
87}
88
89/**
90 * @brief Pack a raw_pressure message on a channel
91 * @param system_id ID of this system
92 * @param component_id ID of this component (e.g. 200 for IMU)
93 * @param chan The MAVLink channel this message will be sent over
94 * @param msg The MAVLink message to compress the data into
95 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
96 * @param press_abs Absolute pressure (raw)
97 * @param press_diff1 Differential pressure 1 (raw, 0 if nonexistant)
98 * @param press_diff2 Differential pressure 2 (raw, 0 if nonexistant)
99 * @param temperature Raw Temperature measurement (raw)
100 * @return length of the message in bytes (excluding serial stream start sign)
101 */
102static inline uint16_t mavlink_msg_raw_pressure_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
103 mavlink_message_t* msg,
104 uint64_t time_usec,int16_t press_abs,int16_t press_diff1,int16_t press_diff2,int16_t temperature)
105{
106#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
107 char buf[MAVLINK_MSG_ID_RAW_PRESSURE_LEN];
108 _mav_put_uint64_t(buf, 0, time_usec);
109 _mav_put_int16_t(buf, 8, press_abs);
110 _mav_put_int16_t(buf, 10, press_diff1);
111 _mav_put_int16_t(buf, 12, press_diff2);
112 _mav_put_int16_t(buf, 14, temperature);
113
114 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_PRESSURE_LEN);
115#else
116 mavlink_raw_pressure_t packet;
117 packet.time_usec = time_usec;
118 packet.press_abs = press_abs;
119 packet.press_diff1 = press_diff1;
120 packet.press_diff2 = press_diff2;
121 packet.temperature = temperature;
122
123 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_PRESSURE_LEN);
124#endif
125
126 msg->msgid = MAVLINK_MSG_ID_RAW_PRESSURE;
127 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_RAW_PRESSURE_MIN_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_CRC);
128}
129
130/**
131 * @brief Encode a raw_pressure struct
132 *
133 * @param system_id ID of this system
134 * @param component_id ID of this component (e.g. 200 for IMU)
135 * @param msg The MAVLink message to compress the data into
136 * @param raw_pressure C-struct to read the message contents from
137 */
138static inline uint16_t mavlink_msg_raw_pressure_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_raw_pressure_t* raw_pressure)
139{
140 return mavlink_msg_raw_pressure_pack(system_id, component_id, msg, raw_pressure->time_usec, raw_pressure->press_abs, raw_pressure->press_diff1, raw_pressure->press_diff2, raw_pressure->temperature);
141}
142
143/**
144 * @brief Encode a raw_pressure struct on a channel
145 *
146 * @param system_id ID of this system
147 * @param component_id ID of this component (e.g. 200 for IMU)
148 * @param chan The MAVLink channel this message will be sent over
149 * @param msg The MAVLink message to compress the data into
150 * @param raw_pressure C-struct to read the message contents from
151 */
152static inline uint16_t mavlink_msg_raw_pressure_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_raw_pressure_t* raw_pressure)
153{
154 return mavlink_msg_raw_pressure_pack_chan(system_id, component_id, chan, msg, raw_pressure->time_usec, raw_pressure->press_abs, raw_pressure->press_diff1, raw_pressure->press_diff2, raw_pressure->temperature);
155}
156
157/**
158 * @brief Send a raw_pressure message
159 * @param chan MAVLink channel to send the message
160 *
161 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
162 * @param press_abs Absolute pressure (raw)
163 * @param press_diff1 Differential pressure 1 (raw, 0 if nonexistant)
164 * @param press_diff2 Differential pressure 2 (raw, 0 if nonexistant)
165 * @param temperature Raw Temperature measurement (raw)
166 */
167#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
168
169static inline void mavlink_msg_raw_pressure_send(mavlink_channel_t chan, uint64_t time_usec, int16_t press_abs, int16_t press_diff1, int16_t press_diff2, int16_t temperature)
170{
171#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
172 char buf[MAVLINK_MSG_ID_RAW_PRESSURE_LEN];
173 _mav_put_uint64_t(buf, 0, time_usec);
174 _mav_put_int16_t(buf, 8, press_abs);
175 _mav_put_int16_t(buf, 10, press_diff1);
176 _mav_put_int16_t(buf, 12, press_diff2);
177 _mav_put_int16_t(buf, 14, temperature);
178
179 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_PRESSURE, buf, MAVLINK_MSG_ID_RAW_PRESSURE_MIN_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_CRC);
180#else
181 mavlink_raw_pressure_t packet;
182 packet.time_usec = time_usec;
183 packet.press_abs = press_abs;
184 packet.press_diff1 = press_diff1;
185 packet.press_diff2 = press_diff2;
186 packet.temperature = temperature;
187
188 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_PRESSURE, (const char *)&packet, MAVLINK_MSG_ID_RAW_PRESSURE_MIN_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_CRC);
189#endif
190}
191
192/**
193 * @brief Send a raw_pressure message
194 * @param chan MAVLink channel to send the message
195 * @param struct The MAVLink struct to serialize
196 */
197static inline void mavlink_msg_raw_pressure_send_struct(mavlink_channel_t chan, const mavlink_raw_pressure_t* raw_pressure)
198{
199#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
200 mavlink_msg_raw_pressure_send(chan, raw_pressure->time_usec, raw_pressure->press_abs, raw_pressure->press_diff1, raw_pressure->press_diff2, raw_pressure->temperature);
201#else
202 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_PRESSURE, (const char *)raw_pressure, MAVLINK_MSG_ID_RAW_PRESSURE_MIN_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_CRC);
203#endif
204}
205
206#if MAVLINK_MSG_ID_RAW_PRESSURE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
207/*
208 This varient of _send() can be used to save stack space by re-using
209 memory from the receive buffer. The caller provides a
210 mavlink_message_t which is the size of a full mavlink message. This
211 is usually the receive buffer for the channel, and allows a reply to an
212 incoming message with minimum stack space usage.
213 */
214static inline void mavlink_msg_raw_pressure_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, int16_t press_abs, int16_t press_diff1, int16_t press_diff2, int16_t temperature)
215{
216#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
217 char *buf = (char *)msgbuf;
218 _mav_put_uint64_t(buf, 0, time_usec);
219 _mav_put_int16_t(buf, 8, press_abs);
220 _mav_put_int16_t(buf, 10, press_diff1);
221 _mav_put_int16_t(buf, 12, press_diff2);
222 _mav_put_int16_t(buf, 14, temperature);
223
224 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_PRESSURE, buf, MAVLINK_MSG_ID_RAW_PRESSURE_MIN_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_CRC);
225#else
226 mavlink_raw_pressure_t *packet = (mavlink_raw_pressure_t *)msgbuf;
227 packet->time_usec = time_usec;
228 packet->press_abs = press_abs;
229 packet->press_diff1 = press_diff1;
230 packet->press_diff2 = press_diff2;
231 packet->temperature = temperature;
232
233 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_PRESSURE, (const char *)packet, MAVLINK_MSG_ID_RAW_PRESSURE_MIN_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_CRC);
234#endif
235}
236#endif
237
238#endif
239
240// MESSAGE RAW_PRESSURE UNPACKING
241
242
243/**
244 * @brief Get field time_usec from raw_pressure message
245 *
246 * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot)
247 */
248static inline uint64_t mavlink_msg_raw_pressure_get_time_usec(const mavlink_message_t* msg)
249{
250 return _MAV_RETURN_uint64_t(msg, 0);
251}
252
253/**
254 * @brief Get field press_abs from raw_pressure message
255 *
256 * @return Absolute pressure (raw)
257 */
258static inline int16_t mavlink_msg_raw_pressure_get_press_abs(const mavlink_message_t* msg)
259{
260 return _MAV_RETURN_int16_t(msg, 8);
261}
262
263/**
264 * @brief Get field press_diff1 from raw_pressure message
265 *
266 * @return Differential pressure 1 (raw, 0 if nonexistant)
267 */
268static inline int16_t mavlink_msg_raw_pressure_get_press_diff1(const mavlink_message_t* msg)
269{
270 return _MAV_RETURN_int16_t(msg, 10);
271}
272
273/**
274 * @brief Get field press_diff2 from raw_pressure message
275 *
276 * @return Differential pressure 2 (raw, 0 if nonexistant)
277 */
278static inline int16_t mavlink_msg_raw_pressure_get_press_diff2(const mavlink_message_t* msg)
279{
280 return _MAV_RETURN_int16_t(msg, 12);
281}
282
283/**
284 * @brief Get field temperature from raw_pressure message
285 *
286 * @return Raw Temperature measurement (raw)
287 */
288static inline int16_t mavlink_msg_raw_pressure_get_temperature(const mavlink_message_t* msg)
289{
290 return _MAV_RETURN_int16_t(msg, 14);
291}
292
293/**
294 * @brief Decode a raw_pressure message into a struct
295 *
296 * @param msg The message to decode
297 * @param raw_pressure C-struct to decode the message contents into
298 */
299static inline void mavlink_msg_raw_pressure_decode(const mavlink_message_t* msg, mavlink_raw_pressure_t* raw_pressure)
300{
301#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
302 raw_pressure->time_usec = mavlink_msg_raw_pressure_get_time_usec(msg);
303 raw_pressure->press_abs = mavlink_msg_raw_pressure_get_press_abs(msg);
304 raw_pressure->press_diff1 = mavlink_msg_raw_pressure_get_press_diff1(msg);
305 raw_pressure->press_diff2 = mavlink_msg_raw_pressure_get_press_diff2(msg);
306 raw_pressure->temperature = mavlink_msg_raw_pressure_get_temperature(msg);
307#else
308 uint8_t len = msg->len < MAVLINK_MSG_ID_RAW_PRESSURE_LEN? msg->len : MAVLINK_MSG_ID_RAW_PRESSURE_LEN;
309 memset(raw_pressure, 0, MAVLINK_MSG_ID_RAW_PRESSURE_LEN);
310 memcpy(raw_pressure, _MAV_PAYLOAD(msg), len);
311#endif
312}
Note: See TracBrowser for help on using the repository browser.