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

#define MAVLINK_MSG_ID_RAW_PRESSURE 29
lm's avatar
lm committed
4 5
#define MAVLINK_MSG_ID_RAW_PRESSURE_LEN 16
#define MAVLINK_MSG_29_LEN 16
lm's avatar
lm committed
6 7
#define MAVLINK_MSG_ID_RAW_PRESSURE_KEY 0x15
#define MAVLINK_MSG_29_KEY 0x15
James Goppert's avatar
James Goppert committed
8 9 10

typedef struct __mavlink_raw_pressure_t 
{
lm's avatar
lm committed
11 12 13 14 15
	uint64_t usec;	///< Timestamp (microseconds since UNIX epoch or microseconds since system boot)
	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
16 17 18 19 20 21 22 23 24 25

} mavlink_raw_pressure_t;

/**
 * @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
 *
 * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
James Goppert's avatar
James Goppert committed
26 27 28 29
 * @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
30 31
 * @return length of the message in bytes (excluding serial stream start sign)
 */
James Goppert's avatar
James Goppert committed
32
static inline uint16_t mavlink_msg_raw_pressure_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint64_t usec, int16_t press_abs, int16_t press_diff1, int16_t press_diff2, int16_t temperature)
James Goppert's avatar
James Goppert committed
33
{
lm's avatar
lm committed
34
	mavlink_raw_pressure_t *p = (mavlink_raw_pressure_t *)&msg->payload[0];
James Goppert's avatar
James Goppert committed
35 36
	msg->msgid = MAVLINK_MSG_ID_RAW_PRESSURE;

lm's avatar
lm committed
37 38 39 40 41
	p->usec = usec;	// uint64_t:Timestamp (microseconds since UNIX epoch or microseconds since system boot)
	p->press_abs = press_abs;	// int16_t:Absolute pressure (raw)
	p->press_diff1 = press_diff1;	// int16_t:Differential pressure 1 (raw)
	p->press_diff2 = press_diff2;	// int16_t:Differential pressure 2 (raw)
	p->temperature = temperature;	// int16_t:Raw Temperature measurement (raw)
James Goppert's avatar
James Goppert committed
42

lm's avatar
lm committed
43
	return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RAW_PRESSURE_LEN);
James Goppert's avatar
James Goppert committed
44 45 46 47 48 49 50 51 52
}

/**
 * @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 chan The MAVLink channel this message was sent over
 * @param msg The MAVLink message to compress the data into
 * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
James Goppert's avatar
James Goppert committed
53 54 55 56
 * @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
57 58
 * @return length of the message in bytes (excluding serial stream start sign)
 */
James Goppert's avatar
James Goppert committed
59
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, uint64_t usec, int16_t press_abs, int16_t press_diff1, int16_t press_diff2, int16_t temperature)
James Goppert's avatar
James Goppert committed
60
{
lm's avatar
lm committed
61
	mavlink_raw_pressure_t *p = (mavlink_raw_pressure_t *)&msg->payload[0];
James Goppert's avatar
James Goppert committed
62 63
	msg->msgid = MAVLINK_MSG_ID_RAW_PRESSURE;

lm's avatar
lm committed
64 65 66 67 68
	p->usec = usec;	// uint64_t:Timestamp (microseconds since UNIX epoch or microseconds since system boot)
	p->press_abs = press_abs;	// int16_t:Absolute pressure (raw)
	p->press_diff1 = press_diff1;	// int16_t:Differential pressure 1 (raw)
	p->press_diff2 = press_diff2;	// int16_t:Differential pressure 2 (raw)
	p->temperature = temperature;	// int16_t:Raw Temperature measurement (raw)
James Goppert's avatar
James Goppert committed
69

lm's avatar
lm committed
70
	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_RAW_PRESSURE_LEN);
James Goppert's avatar
James Goppert committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
}

/**
 * @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)
{
	return mavlink_msg_raw_pressure_pack(system_id, component_id, msg, raw_pressure->usec, raw_pressure->press_abs, raw_pressure->press_diff1, raw_pressure->press_diff2, raw_pressure->temperature);
}

lm's avatar
lm committed
86 87

#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
James Goppert's avatar
James Goppert committed
88 89 90 91 92
/**
 * @brief Send a raw_pressure message
 * @param chan MAVLink channel to send the message
 *
 * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
James Goppert's avatar
James Goppert committed
93 94 95 96
 * @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
97
 */
lm's avatar
lm committed
98 99 100 101 102
static inline void mavlink_msg_raw_pressure_send(mavlink_channel_t chan, uint64_t usec, int16_t press_abs, int16_t press_diff1, int16_t press_diff2, int16_t temperature)
{
	mavlink_header_t hdr;
	mavlink_raw_pressure_t payload;

lm's avatar
lm committed
103 104 105 106 107 108
	MAVLINK_BUFFER_CHECK_START( chan, MAVLINK_MSG_ID_RAW_PRESSURE_LEN )
	payload.usec = usec;	// uint64_t:Timestamp (microseconds since UNIX epoch or microseconds since system boot)
	payload.press_abs = press_abs;	// int16_t:Absolute pressure (raw)
	payload.press_diff1 = press_diff1;	// int16_t:Differential pressure 1 (raw)
	payload.press_diff2 = press_diff2;	// int16_t:Differential pressure 2 (raw)
	payload.temperature = temperature;	// int16_t:Raw Temperature measurement (raw)
lm's avatar
lm committed
109 110 111 112 113 114 115 116 117 118

	hdr.STX = MAVLINK_STX;
	hdr.len = MAVLINK_MSG_ID_RAW_PRESSURE_LEN;
	hdr.msgid = MAVLINK_MSG_ID_RAW_PRESSURE;
	hdr.sysid = mavlink_system.sysid;
	hdr.compid = mavlink_system.compid;
	hdr.seq = mavlink_get_channel_status(chan)->current_tx_seq;
	mavlink_get_channel_status(chan)->current_tx_seq = hdr.seq + 1;
	mavlink_send_mem(chan, (uint8_t *)&hdr.STX, MAVLINK_NUM_HEADER_BYTES );

lm's avatar
lm committed
119 120 121 122 123 124
	crc_init(&hdr.ck);
	crc_calculate_mem((uint8_t *)&hdr.len, &hdr.ck, MAVLINK_CORE_HEADER_LEN);
	crc_calculate_mem((uint8_t *)&payload, &hdr.ck, hdr.len );
	crc_accumulate( 0x15, &hdr.ck); /// include key in X25 checksum
	mavlink_send_mem(chan, (uint8_t *)&hdr.ck, MAVLINK_NUM_CHECKSUM_BYTES);
	MAVLINK_BUFFER_CHECK_END
James Goppert's avatar
James Goppert committed
125 126 127 128 129 130 131 132 133 134 135 136
}

#endif
// MESSAGE RAW_PRESSURE UNPACKING

/**
 * @brief Get field usec from raw_pressure message
 *
 * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot)
 */
static inline uint64_t mavlink_msg_raw_pressure_get_usec(const mavlink_message_t* msg)
{
lm's avatar
lm committed
137 138
	mavlink_raw_pressure_t *p = (mavlink_raw_pressure_t *)&msg->payload[0];
	return (uint64_t)(p->usec);
James Goppert's avatar
James Goppert committed
139 140 141 142 143
}

/**
 * @brief Get field press_abs from raw_pressure message
 *
James Goppert's avatar
James Goppert committed
144
 * @return Absolute pressure (raw)
James Goppert's avatar
James Goppert committed
145
 */
James Goppert's avatar
James Goppert committed
146
static inline int16_t mavlink_msg_raw_pressure_get_press_abs(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
147
{
lm's avatar
lm committed
148 149
	mavlink_raw_pressure_t *p = (mavlink_raw_pressure_t *)&msg->payload[0];
	return (int16_t)(p->press_abs);
James Goppert's avatar
James Goppert committed
150 151 152 153 154
}

/**
 * @brief Get field press_diff1 from raw_pressure message
 *
James Goppert's avatar
James Goppert committed
155
 * @return Differential pressure 1 (raw)
James Goppert's avatar
James Goppert committed
156
 */
James Goppert's avatar
James Goppert committed
157
static inline int16_t mavlink_msg_raw_pressure_get_press_diff1(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
158
{
lm's avatar
lm committed
159 160
	mavlink_raw_pressure_t *p = (mavlink_raw_pressure_t *)&msg->payload[0];
	return (int16_t)(p->press_diff1);
James Goppert's avatar
James Goppert committed
161 162 163 164 165
}

/**
 * @brief Get field press_diff2 from raw_pressure message
 *
James Goppert's avatar
James Goppert committed
166
 * @return Differential pressure 2 (raw)
James Goppert's avatar
James Goppert committed
167
 */
James Goppert's avatar
James Goppert committed
168
static inline int16_t mavlink_msg_raw_pressure_get_press_diff2(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
169
{
lm's avatar
lm committed
170 171
	mavlink_raw_pressure_t *p = (mavlink_raw_pressure_t *)&msg->payload[0];
	return (int16_t)(p->press_diff2);
James Goppert's avatar
James Goppert committed
172 173 174 175 176
}

/**
 * @brief Get field temperature from raw_pressure message
 *
James Goppert's avatar
James Goppert committed
177
 * @return Raw Temperature measurement (raw)
James Goppert's avatar
James Goppert committed
178 179 180
 */
static inline int16_t mavlink_msg_raw_pressure_get_temperature(const mavlink_message_t* msg)
{
lm's avatar
lm committed
181 182
	mavlink_raw_pressure_t *p = (mavlink_raw_pressure_t *)&msg->payload[0];
	return (int16_t)(p->temperature);
James Goppert's avatar
James Goppert committed
183 184 185 186 187 188 189 190 191 192
}

/**
 * @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
193
	memcpy( raw_pressure, msg->payload, sizeof(mavlink_raw_pressure_t));
James Goppert's avatar
James Goppert committed
194
}