Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
mavlink_msg_raw_pressure.h
00001 // MESSAGE RAW_PRESSURE PACKING 00002 00003 #define MAVLINK_MSG_ID_RAW_PRESSURE 29 00004 00005 typedef struct __mavlink_raw_pressure_t 00006 { 00007 uint64_t usec; ///< Timestamp (microseconds since UNIX epoch or microseconds since system boot) 00008 int16_t press_abs; ///< Absolute pressure (raw) 00009 int16_t press_diff1; ///< Differential pressure 1 (raw) 00010 int16_t press_diff2; ///< Differential pressure 2 (raw) 00011 int16_t temperature; ///< Raw Temperature measurement (raw) 00012 00013 } mavlink_raw_pressure_t; 00014 00015 00016 00017 /** 00018 * @brief Pack a raw_pressure message 00019 * @param system_id ID of this system 00020 * @param component_id ID of this component (e.g. 200 for IMU) 00021 * @param msg The MAVLink message to compress the data into 00022 * 00023 * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot) 00024 * @param press_abs Absolute pressure (raw) 00025 * @param press_diff1 Differential pressure 1 (raw) 00026 * @param press_diff2 Differential pressure 2 (raw) 00027 * @param temperature Raw Temperature measurement (raw) 00028 * @return length of the message in bytes (excluding serial stream start sign) 00029 */ 00030 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) 00031 { 00032 uint16_t i = 0; 00033 msg->msgid = MAVLINK_MSG_ID_RAW_PRESSURE; 00034 00035 i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (microseconds since UNIX epoch or microseconds since system boot) 00036 i += put_int16_t_by_index(press_abs, i, msg->payload); // Absolute pressure (raw) 00037 i += put_int16_t_by_index(press_diff1, i, msg->payload); // Differential pressure 1 (raw) 00038 i += put_int16_t_by_index(press_diff2, i, msg->payload); // Differential pressure 2 (raw) 00039 i += put_int16_t_by_index(temperature, i, msg->payload); // Raw Temperature measurement (raw) 00040 00041 return mavlink_finalize_message(msg, system_id, component_id, i); 00042 } 00043 00044 /** 00045 * @brief Pack a raw_pressure message 00046 * @param system_id ID of this system 00047 * @param component_id ID of this component (e.g. 200 for IMU) 00048 * @param chan The MAVLink channel this message was sent over 00049 * @param msg The MAVLink message to compress the data into 00050 * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot) 00051 * @param press_abs Absolute pressure (raw) 00052 * @param press_diff1 Differential pressure 1 (raw) 00053 * @param press_diff2 Differential pressure 2 (raw) 00054 * @param temperature Raw Temperature measurement (raw) 00055 * @return length of the message in bytes (excluding serial stream start sign) 00056 */ 00057 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) 00058 { 00059 uint16_t i = 0; 00060 msg->msgid = MAVLINK_MSG_ID_RAW_PRESSURE; 00061 00062 i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (microseconds since UNIX epoch or microseconds since system boot) 00063 i += put_int16_t_by_index(press_abs, i, msg->payload); // Absolute pressure (raw) 00064 i += put_int16_t_by_index(press_diff1, i, msg->payload); // Differential pressure 1 (raw) 00065 i += put_int16_t_by_index(press_diff2, i, msg->payload); // Differential pressure 2 (raw) 00066 i += put_int16_t_by_index(temperature, i, msg->payload); // Raw Temperature measurement (raw) 00067 00068 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); 00069 } 00070 00071 /** 00072 * @brief Encode a raw_pressure struct into a message 00073 * 00074 * @param system_id ID of this system 00075 * @param component_id ID of this component (e.g. 200 for IMU) 00076 * @param msg The MAVLink message to compress the data into 00077 * @param raw_pressure C-struct to read the message contents from 00078 */ 00079 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) 00080 { 00081 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); 00082 } 00083 00084 /** 00085 * @brief Send a raw_pressure message 00086 * @param chan MAVLink channel to send the message 00087 * 00088 * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot) 00089 * @param press_abs Absolute pressure (raw) 00090 * @param press_diff1 Differential pressure 1 (raw) 00091 * @param press_diff2 Differential pressure 2 (raw) 00092 * @param temperature Raw Temperature measurement (raw) 00093 */ 00094 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 00095 00096 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) 00097 { 00098 mavlink_message_t msg; 00099 mavlink_msg_raw_pressure_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, usec, press_abs, press_diff1, press_diff2, temperature); 00100 mavlink_send_uart(chan, &msg); 00101 } 00102 00103 #endif 00104 // MESSAGE RAW_PRESSURE UNPACKING 00105 00106 /** 00107 * @brief Get field usec from raw_pressure message 00108 * 00109 * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot) 00110 */ 00111 static inline uint64_t mavlink_msg_raw_pressure_get_usec(const mavlink_message_t* msg) 00112 { 00113 generic_64bit r; 00114 r.b[7] = (msg->payload)[0]; 00115 r.b[6] = (msg->payload)[1]; 00116 r.b[5] = (msg->payload)[2]; 00117 r.b[4] = (msg->payload)[3]; 00118 r.b[3] = (msg->payload)[4]; 00119 r.b[2] = (msg->payload)[5]; 00120 r.b[1] = (msg->payload)[6]; 00121 r.b[0] = (msg->payload)[7]; 00122 return (uint64_t)r.ll; 00123 } 00124 00125 /** 00126 * @brief Get field press_abs from raw_pressure message 00127 * 00128 * @return Absolute pressure (raw) 00129 */ 00130 static inline int16_t mavlink_msg_raw_pressure_get_press_abs(const mavlink_message_t* msg) 00131 { 00132 generic_16bit r; 00133 r.b[1] = (msg->payload+sizeof(uint64_t))[0]; 00134 r.b[0] = (msg->payload+sizeof(uint64_t))[1]; 00135 return (int16_t)r.s; 00136 } 00137 00138 /** 00139 * @brief Get field press_diff1 from raw_pressure message 00140 * 00141 * @return Differential pressure 1 (raw) 00142 */ 00143 static inline int16_t mavlink_msg_raw_pressure_get_press_diff1(const mavlink_message_t* msg) 00144 { 00145 generic_16bit r; 00146 r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t))[0]; 00147 r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t))[1]; 00148 return (int16_t)r.s; 00149 } 00150 00151 /** 00152 * @brief Get field press_diff2 from raw_pressure message 00153 * 00154 * @return Differential pressure 2 (raw) 00155 */ 00156 static inline int16_t mavlink_msg_raw_pressure_get_press_diff2(const mavlink_message_t* msg) 00157 { 00158 generic_16bit r; 00159 r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t))[0]; 00160 r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t))[1]; 00161 return (int16_t)r.s; 00162 } 00163 00164 /** 00165 * @brief Get field temperature from raw_pressure message 00166 * 00167 * @return Raw Temperature measurement (raw) 00168 */ 00169 static inline int16_t mavlink_msg_raw_pressure_get_temperature(const mavlink_message_t* msg) 00170 { 00171 generic_16bit r; 00172 r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[0]; 00173 r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[1]; 00174 return (int16_t)r.s; 00175 } 00176 00177 /** 00178 * @brief Decode a raw_pressure message into a struct 00179 * 00180 * @param msg The message to decode 00181 * @param raw_pressure C-struct to decode the message contents into 00182 */ 00183 static inline void mavlink_msg_raw_pressure_decode(const mavlink_message_t* msg, mavlink_raw_pressure_t* raw_pressure) 00184 { 00185 raw_pressure->usec = mavlink_msg_raw_pressure_get_usec(msg); 00186 raw_pressure->press_abs = mavlink_msg_raw_pressure_get_press_abs(msg); 00187 raw_pressure->press_diff1 = mavlink_msg_raw_pressure_get_press_diff1(msg); 00188 raw_pressure->press_diff2 = mavlink_msg_raw_pressure_get_press_diff2(msg); 00189 raw_pressure->temperature = mavlink_msg_raw_pressure_get_temperature(msg); 00190 }
Generated on Tue Jul 12 2022 14:09:26 by 1.7.2