mavlink_msg_raw_pressure.h 8.19 KB
Newer Older
James Goppert's avatar
James Goppert committed
1 2
// MESSAGE RAW_PRESSURE PACKING

lm's avatar
lm committed
3
#define MAVLINK_MSG_ID_RAW_PRESSURE 28
James Goppert's avatar
James Goppert committed
4

lm's avatar
lm committed
5
typedef struct __mavlink_raw_pressure_t
James Goppert's avatar
James Goppert committed
6
{
7
 uint64_t time_usec; ///< Timestamp (microseconds since UNIX epoch or microseconds since system boot)
lm's avatar
lm committed
8 9 10 11
 int16_t press_abs; ///< Absolute pressure (raw)
 int16_t press_diff1; ///< Differential pressure 1 (raw)
 int16_t press_diff2; ///< Differential pressure 2 (raw)
 int16_t temperature; ///< Raw Temperature measurement (raw)
James Goppert's avatar
James Goppert committed
12 13
} mavlink_raw_pressure_t;

lm's avatar
lm committed
14
#define MAVLINK_MSG_ID_RAW_PRESSURE_LEN 16
lm's avatar
lm committed
15
#define MAVLINK_MSG_ID_28_LEN 16
lm's avatar
lm committed
16 17 18 19 20 21



#define MAVLINK_MESSAGE_INFO_RAW_PRESSURE { \
	"RAW_PRESSURE", \
	5, \
lm's avatar
lm committed
22 23 24 25 26
	{  { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_raw_pressure_t, time_usec) }, \
         { "press_abs", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_raw_pressure_t, press_abs) }, \
         { "press_diff1", NULL, MAVLINK_TYPE_INT16_T, 0, 10, offsetof(mavlink_raw_pressure_t, press_diff1) }, \
         { "press_diff2", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_raw_pressure_t, press_diff2) }, \
         { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_raw_pressure_t, temperature) }, \
lm's avatar
lm committed
27 28 29 30
         } \
}


James Goppert's avatar
James Goppert committed
31 32 33 34 35 36
/**
 * @brief Pack a raw_pressure message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
37
 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
James Goppert's avatar
James Goppert committed
38 39 40 41
 * @param press_abs Absolute pressure (raw)
 * @param press_diff1 Differential pressure 1 (raw)
 * @param press_diff2 Differential pressure 2 (raw)
 * @param temperature Raw Temperature measurement (raw)
James Goppert's avatar
James Goppert committed
42 43
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
44
static inline uint16_t mavlink_msg_raw_pressure_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
45
						       uint64_t time_usec, int16_t press_abs, int16_t press_diff1, int16_t press_diff2, int16_t temperature)
James Goppert's avatar
James Goppert committed
46
{
LM's avatar
LM committed
47 48 49 50 51 52 53 54
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[16];
	_mav_put_uint64_t(buf, 0, time_usec);
	_mav_put_int16_t(buf, 8, press_abs);
	_mav_put_int16_t(buf, 10, press_diff1);
	_mav_put_int16_t(buf, 12, press_diff2);
	_mav_put_int16_t(buf, 14, temperature);

55
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 16);
LM's avatar
LM committed
56 57 58 59 60 61 62 63
#else
	mavlink_raw_pressure_t packet;
	packet.time_usec = time_usec;
	packet.press_abs = press_abs;
	packet.press_diff1 = press_diff1;
	packet.press_diff2 = press_diff2;
	packet.temperature = temperature;

64
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 16);
LM's avatar
LM committed
65
#endif
James Goppert's avatar
James Goppert committed
66

LM's avatar
LM committed
67
	msg->msgid = MAVLINK_MSG_ID_RAW_PRESSURE;
68
	return mavlink_finalize_message(msg, system_id, component_id, 16, 67);
James Goppert's avatar
James Goppert committed
69 70 71
}

/**
lm's avatar
lm committed
72
 * @brief Pack a raw_pressure message on a channel
James Goppert's avatar
James Goppert committed
73 74 75 76
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message was sent over
 * @param msg The MAVLink message to compress the data into
77
 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
James Goppert's avatar
James Goppert committed
78 79 80 81
 * @param press_abs Absolute pressure (raw)
 * @param press_diff1 Differential pressure 1 (raw)
 * @param press_diff2 Differential pressure 2 (raw)
 * @param temperature Raw Temperature measurement (raw)
James Goppert's avatar
James Goppert committed
82 83
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
84 85
static inline uint16_t mavlink_msg_raw_pressure_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
							   mavlink_message_t* msg,
86
						           uint64_t time_usec,int16_t press_abs,int16_t press_diff1,int16_t press_diff2,int16_t temperature)
James Goppert's avatar
James Goppert committed
87
{
LM's avatar
LM committed
88 89 90 91 92 93 94 95
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[16];
	_mav_put_uint64_t(buf, 0, time_usec);
	_mav_put_int16_t(buf, 8, press_abs);
	_mav_put_int16_t(buf, 10, press_diff1);
	_mav_put_int16_t(buf, 12, press_diff2);
	_mav_put_int16_t(buf, 14, temperature);

96
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 16);
LM's avatar
LM committed
97 98 99 100 101 102 103 104
#else
	mavlink_raw_pressure_t packet;
	packet.time_usec = time_usec;
	packet.press_abs = press_abs;
	packet.press_diff1 = press_diff1;
	packet.press_diff2 = press_diff2;
	packet.temperature = temperature;

105
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 16);
LM's avatar
LM committed
106
#endif
James Goppert's avatar
James Goppert committed
107

LM's avatar
LM committed
108
	msg->msgid = MAVLINK_MSG_ID_RAW_PRESSURE;
109
	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 16, 67);
James Goppert's avatar
James Goppert committed
110 111 112 113 114 115 116 117 118 119 120 121
}

/**
 * @brief Encode a raw_pressure struct into a message
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param raw_pressure C-struct to read the message contents from
 */
static 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)
{
122
	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);
James Goppert's avatar
James Goppert committed
123 124 125 126 127 128
}

/**
 * @brief Send a raw_pressure message
 * @param chan MAVLink channel to send the message
 *
129
 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
James Goppert's avatar
James Goppert committed
130 131 132 133
 * @param press_abs Absolute pressure (raw)
 * @param press_diff1 Differential pressure 1 (raw)
 * @param press_diff2 Differential pressure 2 (raw)
 * @param temperature Raw Temperature measurement (raw)
James Goppert's avatar
James Goppert committed
134
 */
lm's avatar
lm committed
135 136
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

137
static 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)
lm's avatar
lm committed
138
{
LM's avatar
LM committed
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[16];
	_mav_put_uint64_t(buf, 0, time_usec);
	_mav_put_int16_t(buf, 8, press_abs);
	_mav_put_int16_t(buf, 10, press_diff1);
	_mav_put_int16_t(buf, 12, press_diff2);
	_mav_put_int16_t(buf, 14, temperature);

	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_PRESSURE, buf, 16, 67);
#else
	mavlink_raw_pressure_t packet;
	packet.time_usec = time_usec;
	packet.press_abs = press_abs;
	packet.press_diff1 = press_diff1;
	packet.press_diff2 = press_diff2;
	packet.temperature = temperature;

	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_PRESSURE, (const char *)&packet, 16, 67);
#endif
James Goppert's avatar
James Goppert committed
158 159 160
}

#endif
lm's avatar
lm committed
161

James Goppert's avatar
James Goppert committed
162 163
// MESSAGE RAW_PRESSURE UNPACKING

lm's avatar
lm committed
164

James Goppert's avatar
James Goppert committed
165
/**
166
 * @brief Get field time_usec from raw_pressure message
James Goppert's avatar
James Goppert committed
167 168 169
 *
 * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot)
 */
170
static inline uint64_t mavlink_msg_raw_pressure_get_time_usec(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
171
{
LM's avatar
LM committed
172
	return _MAV_RETURN_uint64_t(msg,  0);
James Goppert's avatar
James Goppert committed
173 174 175 176 177
}

/**
 * @brief Get field press_abs from raw_pressure message
 *
James Goppert's avatar
James Goppert committed
178
 * @return Absolute pressure (raw)
James Goppert's avatar
James Goppert committed
179
 */
James Goppert's avatar
James Goppert committed
180
static inline int16_t mavlink_msg_raw_pressure_get_press_abs(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
181
{
LM's avatar
LM committed
182
	return _MAV_RETURN_int16_t(msg,  8);
James Goppert's avatar
James Goppert committed
183 184 185 186 187
}

/**
 * @brief Get field press_diff1 from raw_pressure message
 *
James Goppert's avatar
James Goppert committed
188
 * @return Differential pressure 1 (raw)
James Goppert's avatar
James Goppert committed
189
 */
James Goppert's avatar
James Goppert committed
190
static inline int16_t mavlink_msg_raw_pressure_get_press_diff1(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
191
{
LM's avatar
LM committed
192
	return _MAV_RETURN_int16_t(msg,  10);
James Goppert's avatar
James Goppert committed
193 194 195 196 197
}

/**
 * @brief Get field press_diff2 from raw_pressure message
 *
James Goppert's avatar
James Goppert committed
198
 * @return Differential pressure 2 (raw)
James Goppert's avatar
James Goppert committed
199
 */
James Goppert's avatar
James Goppert committed
200
static inline int16_t mavlink_msg_raw_pressure_get_press_diff2(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
201
{
LM's avatar
LM committed
202
	return _MAV_RETURN_int16_t(msg,  12);
James Goppert's avatar
James Goppert committed
203 204 205 206 207
}

/**
 * @brief Get field temperature from raw_pressure message
 *
James Goppert's avatar
James Goppert committed
208
 * @return Raw Temperature measurement (raw)
James Goppert's avatar
James Goppert committed
209 210 211
 */
static inline int16_t mavlink_msg_raw_pressure_get_temperature(const mavlink_message_t* msg)
{
LM's avatar
LM committed
212
	return _MAV_RETURN_int16_t(msg,  14);
James Goppert's avatar
James Goppert committed
213 214 215 216 217 218 219 220 221 222
}

/**
 * @brief Decode a raw_pressure message into a struct
 *
 * @param msg The message to decode
 * @param raw_pressure C-struct to decode the message contents into
 */
static inline void mavlink_msg_raw_pressure_decode(const mavlink_message_t* msg, mavlink_raw_pressure_t* raw_pressure)
{
lm's avatar
lm committed
223
#if MAVLINK_NEED_BYTE_SWAP
224
	raw_pressure->time_usec = mavlink_msg_raw_pressure_get_time_usec(msg);
lm's avatar
lm committed
225 226 227 228 229
	raw_pressure->press_abs = mavlink_msg_raw_pressure_get_press_abs(msg);
	raw_pressure->press_diff1 = mavlink_msg_raw_pressure_get_press_diff1(msg);
	raw_pressure->press_diff2 = mavlink_msg_raw_pressure_get_press_diff2(msg);
	raw_pressure->temperature = mavlink_msg_raw_pressure_get_temperature(msg);
#else
LM's avatar
LM committed
230
	memcpy(raw_pressure, _MAV_PAYLOAD(msg), 16);
lm's avatar
lm committed
231
#endif
James Goppert's avatar
James Goppert committed
232
}