Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.

Dependencies:   Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo

Committer:
shimniok
Date:
Wed Jun 20 14:57:48 2012 +0000
Revision:
0:826c6171fc1b
Updated documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 0:826c6171fc1b 1 // MESSAGE GPS_DATE_TIME PACKING
shimniok 0:826c6171fc1b 2
shimniok 0:826c6171fc1b 3 #define MAVLINK_MSG_ID_GPS_DATE_TIME 179
shimniok 0:826c6171fc1b 4
shimniok 0:826c6171fc1b 5 typedef struct __mavlink_gps_date_time_t
shimniok 0:826c6171fc1b 6 {
shimniok 0:826c6171fc1b 7 uint8_t year; ///< Year reported by Gps
shimniok 0:826c6171fc1b 8 uint8_t month; ///< Month reported by Gps
shimniok 0:826c6171fc1b 9 uint8_t day; ///< Day reported by Gps
shimniok 0:826c6171fc1b 10 uint8_t hour; ///< Hour reported by Gps
shimniok 0:826c6171fc1b 11 uint8_t min; ///< Min reported by Gps
shimniok 0:826c6171fc1b 12 uint8_t sec; ///< Sec reported by Gps
shimniok 0:826c6171fc1b 13 uint8_t visSat; ///< Visible sattelites reported by Gps
shimniok 0:826c6171fc1b 14
shimniok 0:826c6171fc1b 15 } mavlink_gps_date_time_t;
shimniok 0:826c6171fc1b 16
shimniok 0:826c6171fc1b 17
shimniok 0:826c6171fc1b 18
shimniok 0:826c6171fc1b 19 /**
shimniok 0:826c6171fc1b 20 * @brief Pack a gps_date_time message
shimniok 0:826c6171fc1b 21 * @param system_id ID of this system
shimniok 0:826c6171fc1b 22 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:826c6171fc1b 23 * @param msg The MAVLink message to compress the data into
shimniok 0:826c6171fc1b 24 *
shimniok 0:826c6171fc1b 25 * @param year Year reported by Gps
shimniok 0:826c6171fc1b 26 * @param month Month reported by Gps
shimniok 0:826c6171fc1b 27 * @param day Day reported by Gps
shimniok 0:826c6171fc1b 28 * @param hour Hour reported by Gps
shimniok 0:826c6171fc1b 29 * @param min Min reported by Gps
shimniok 0:826c6171fc1b 30 * @param sec Sec reported by Gps
shimniok 0:826c6171fc1b 31 * @param visSat Visible sattelites reported by Gps
shimniok 0:826c6171fc1b 32 * @return length of the message in bytes (excluding serial stream start sign)
shimniok 0:826c6171fc1b 33 */
shimniok 0:826c6171fc1b 34 static inline uint16_t mavlink_msg_gps_date_time_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec, uint8_t visSat)
shimniok 0:826c6171fc1b 35 {
shimniok 0:826c6171fc1b 36 uint16_t i = 0;
shimniok 0:826c6171fc1b 37 msg->msgid = MAVLINK_MSG_ID_GPS_DATE_TIME;
shimniok 0:826c6171fc1b 38
shimniok 0:826c6171fc1b 39 i += put_uint8_t_by_index(year, i, msg->payload); // Year reported by Gps
shimniok 0:826c6171fc1b 40 i += put_uint8_t_by_index(month, i, msg->payload); // Month reported by Gps
shimniok 0:826c6171fc1b 41 i += put_uint8_t_by_index(day, i, msg->payload); // Day reported by Gps
shimniok 0:826c6171fc1b 42 i += put_uint8_t_by_index(hour, i, msg->payload); // Hour reported by Gps
shimniok 0:826c6171fc1b 43 i += put_uint8_t_by_index(min, i, msg->payload); // Min reported by Gps
shimniok 0:826c6171fc1b 44 i += put_uint8_t_by_index(sec, i, msg->payload); // Sec reported by Gps
shimniok 0:826c6171fc1b 45 i += put_uint8_t_by_index(visSat, i, msg->payload); // Visible sattelites reported by Gps
shimniok 0:826c6171fc1b 46
shimniok 0:826c6171fc1b 47 return mavlink_finalize_message(msg, system_id, component_id, i);
shimniok 0:826c6171fc1b 48 }
shimniok 0:826c6171fc1b 49
shimniok 0:826c6171fc1b 50 /**
shimniok 0:826c6171fc1b 51 * @brief Pack a gps_date_time message
shimniok 0:826c6171fc1b 52 * @param system_id ID of this system
shimniok 0:826c6171fc1b 53 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:826c6171fc1b 54 * @param chan The MAVLink channel this message was sent over
shimniok 0:826c6171fc1b 55 * @param msg The MAVLink message to compress the data into
shimniok 0:826c6171fc1b 56 * @param year Year reported by Gps
shimniok 0:826c6171fc1b 57 * @param month Month reported by Gps
shimniok 0:826c6171fc1b 58 * @param day Day reported by Gps
shimniok 0:826c6171fc1b 59 * @param hour Hour reported by Gps
shimniok 0:826c6171fc1b 60 * @param min Min reported by Gps
shimniok 0:826c6171fc1b 61 * @param sec Sec reported by Gps
shimniok 0:826c6171fc1b 62 * @param visSat Visible sattelites reported by Gps
shimniok 0:826c6171fc1b 63 * @return length of the message in bytes (excluding serial stream start sign)
shimniok 0:826c6171fc1b 64 */
shimniok 0:826c6171fc1b 65 static inline uint16_t mavlink_msg_gps_date_time_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec, uint8_t visSat)
shimniok 0:826c6171fc1b 66 {
shimniok 0:826c6171fc1b 67 uint16_t i = 0;
shimniok 0:826c6171fc1b 68 msg->msgid = MAVLINK_MSG_ID_GPS_DATE_TIME;
shimniok 0:826c6171fc1b 69
shimniok 0:826c6171fc1b 70 i += put_uint8_t_by_index(year, i, msg->payload); // Year reported by Gps
shimniok 0:826c6171fc1b 71 i += put_uint8_t_by_index(month, i, msg->payload); // Month reported by Gps
shimniok 0:826c6171fc1b 72 i += put_uint8_t_by_index(day, i, msg->payload); // Day reported by Gps
shimniok 0:826c6171fc1b 73 i += put_uint8_t_by_index(hour, i, msg->payload); // Hour reported by Gps
shimniok 0:826c6171fc1b 74 i += put_uint8_t_by_index(min, i, msg->payload); // Min reported by Gps
shimniok 0:826c6171fc1b 75 i += put_uint8_t_by_index(sec, i, msg->payload); // Sec reported by Gps
shimniok 0:826c6171fc1b 76 i += put_uint8_t_by_index(visSat, i, msg->payload); // Visible sattelites reported by Gps
shimniok 0:826c6171fc1b 77
shimniok 0:826c6171fc1b 78 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
shimniok 0:826c6171fc1b 79 }
shimniok 0:826c6171fc1b 80
shimniok 0:826c6171fc1b 81 /**
shimniok 0:826c6171fc1b 82 * @brief Encode a gps_date_time struct into a message
shimniok 0:826c6171fc1b 83 *
shimniok 0:826c6171fc1b 84 * @param system_id ID of this system
shimniok 0:826c6171fc1b 85 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:826c6171fc1b 86 * @param msg The MAVLink message to compress the data into
shimniok 0:826c6171fc1b 87 * @param gps_date_time C-struct to read the message contents from
shimniok 0:826c6171fc1b 88 */
shimniok 0:826c6171fc1b 89 static inline uint16_t mavlink_msg_gps_date_time_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_gps_date_time_t* gps_date_time)
shimniok 0:826c6171fc1b 90 {
shimniok 0:826c6171fc1b 91 return mavlink_msg_gps_date_time_pack(system_id, component_id, msg, gps_date_time->year, gps_date_time->month, gps_date_time->day, gps_date_time->hour, gps_date_time->min, gps_date_time->sec, gps_date_time->visSat);
shimniok 0:826c6171fc1b 92 }
shimniok 0:826c6171fc1b 93
shimniok 0:826c6171fc1b 94 /**
shimniok 0:826c6171fc1b 95 * @brief Send a gps_date_time message
shimniok 0:826c6171fc1b 96 * @param chan MAVLink channel to send the message
shimniok 0:826c6171fc1b 97 *
shimniok 0:826c6171fc1b 98 * @param year Year reported by Gps
shimniok 0:826c6171fc1b 99 * @param month Month reported by Gps
shimniok 0:826c6171fc1b 100 * @param day Day reported by Gps
shimniok 0:826c6171fc1b 101 * @param hour Hour reported by Gps
shimniok 0:826c6171fc1b 102 * @param min Min reported by Gps
shimniok 0:826c6171fc1b 103 * @param sec Sec reported by Gps
shimniok 0:826c6171fc1b 104 * @param visSat Visible sattelites reported by Gps
shimniok 0:826c6171fc1b 105 */
shimniok 0:826c6171fc1b 106 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
shimniok 0:826c6171fc1b 107
shimniok 0:826c6171fc1b 108 static inline void mavlink_msg_gps_date_time_send(mavlink_channel_t chan, uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec, uint8_t visSat)
shimniok 0:826c6171fc1b 109 {
shimniok 0:826c6171fc1b 110 mavlink_message_t msg;
shimniok 0:826c6171fc1b 111 mavlink_msg_gps_date_time_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, year, month, day, hour, min, sec, visSat);
shimniok 0:826c6171fc1b 112 mavlink_send_uart(chan, &msg);
shimniok 0:826c6171fc1b 113 }
shimniok 0:826c6171fc1b 114
shimniok 0:826c6171fc1b 115 #endif
shimniok 0:826c6171fc1b 116 // MESSAGE GPS_DATE_TIME UNPACKING
shimniok 0:826c6171fc1b 117
shimniok 0:826c6171fc1b 118 /**
shimniok 0:826c6171fc1b 119 * @brief Get field year from gps_date_time message
shimniok 0:826c6171fc1b 120 *
shimniok 0:826c6171fc1b 121 * @return Year reported by Gps
shimniok 0:826c6171fc1b 122 */
shimniok 0:826c6171fc1b 123 static inline uint8_t mavlink_msg_gps_date_time_get_year(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 124 {
shimniok 0:826c6171fc1b 125 return (uint8_t)(msg->payload)[0];
shimniok 0:826c6171fc1b 126 }
shimniok 0:826c6171fc1b 127
shimniok 0:826c6171fc1b 128 /**
shimniok 0:826c6171fc1b 129 * @brief Get field month from gps_date_time message
shimniok 0:826c6171fc1b 130 *
shimniok 0:826c6171fc1b 131 * @return Month reported by Gps
shimniok 0:826c6171fc1b 132 */
shimniok 0:826c6171fc1b 133 static inline uint8_t mavlink_msg_gps_date_time_get_month(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 134 {
shimniok 0:826c6171fc1b 135 return (uint8_t)(msg->payload+sizeof(uint8_t))[0];
shimniok 0:826c6171fc1b 136 }
shimniok 0:826c6171fc1b 137
shimniok 0:826c6171fc1b 138 /**
shimniok 0:826c6171fc1b 139 * @brief Get field day from gps_date_time message
shimniok 0:826c6171fc1b 140 *
shimniok 0:826c6171fc1b 141 * @return Day reported by Gps
shimniok 0:826c6171fc1b 142 */
shimniok 0:826c6171fc1b 143 static inline uint8_t mavlink_msg_gps_date_time_get_day(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 144 {
shimniok 0:826c6171fc1b 145 return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t))[0];
shimniok 0:826c6171fc1b 146 }
shimniok 0:826c6171fc1b 147
shimniok 0:826c6171fc1b 148 /**
shimniok 0:826c6171fc1b 149 * @brief Get field hour from gps_date_time message
shimniok 0:826c6171fc1b 150 *
shimniok 0:826c6171fc1b 151 * @return Hour reported by Gps
shimniok 0:826c6171fc1b 152 */
shimniok 0:826c6171fc1b 153 static inline uint8_t mavlink_msg_gps_date_time_get_hour(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 154 {
shimniok 0:826c6171fc1b 155 return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t))[0];
shimniok 0:826c6171fc1b 156 }
shimniok 0:826c6171fc1b 157
shimniok 0:826c6171fc1b 158 /**
shimniok 0:826c6171fc1b 159 * @brief Get field min from gps_date_time message
shimniok 0:826c6171fc1b 160 *
shimniok 0:826c6171fc1b 161 * @return Min reported by Gps
shimniok 0:826c6171fc1b 162 */
shimniok 0:826c6171fc1b 163 static inline uint8_t mavlink_msg_gps_date_time_get_min(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 164 {
shimniok 0:826c6171fc1b 165 return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t))[0];
shimniok 0:826c6171fc1b 166 }
shimniok 0:826c6171fc1b 167
shimniok 0:826c6171fc1b 168 /**
shimniok 0:826c6171fc1b 169 * @brief Get field sec from gps_date_time message
shimniok 0:826c6171fc1b 170 *
shimniok 0:826c6171fc1b 171 * @return Sec reported by Gps
shimniok 0:826c6171fc1b 172 */
shimniok 0:826c6171fc1b 173 static inline uint8_t mavlink_msg_gps_date_time_get_sec(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 174 {
shimniok 0:826c6171fc1b 175 return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t))[0];
shimniok 0:826c6171fc1b 176 }
shimniok 0:826c6171fc1b 177
shimniok 0:826c6171fc1b 178 /**
shimniok 0:826c6171fc1b 179 * @brief Get field visSat from gps_date_time message
shimniok 0:826c6171fc1b 180 *
shimniok 0:826c6171fc1b 181 * @return Visible sattelites reported by Gps
shimniok 0:826c6171fc1b 182 */
shimniok 0:826c6171fc1b 183 static inline uint8_t mavlink_msg_gps_date_time_get_visSat(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 184 {
shimniok 0:826c6171fc1b 185 return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t))[0];
shimniok 0:826c6171fc1b 186 }
shimniok 0:826c6171fc1b 187
shimniok 0:826c6171fc1b 188 /**
shimniok 0:826c6171fc1b 189 * @brief Decode a gps_date_time message into a struct
shimniok 0:826c6171fc1b 190 *
shimniok 0:826c6171fc1b 191 * @param msg The message to decode
shimniok 0:826c6171fc1b 192 * @param gps_date_time C-struct to decode the message contents into
shimniok 0:826c6171fc1b 193 */
shimniok 0:826c6171fc1b 194 static inline void mavlink_msg_gps_date_time_decode(const mavlink_message_t* msg, mavlink_gps_date_time_t* gps_date_time)
shimniok 0:826c6171fc1b 195 {
shimniok 0:826c6171fc1b 196 gps_date_time->year = mavlink_msg_gps_date_time_get_year(msg);
shimniok 0:826c6171fc1b 197 gps_date_time->month = mavlink_msg_gps_date_time_get_month(msg);
shimniok 0:826c6171fc1b 198 gps_date_time->day = mavlink_msg_gps_date_time_get_day(msg);
shimniok 0:826c6171fc1b 199 gps_date_time->hour = mavlink_msg_gps_date_time_get_hour(msg);
shimniok 0:826c6171fc1b 200 gps_date_time->min = mavlink_msg_gps_date_time_get_min(msg);
shimniok 0:826c6171fc1b 201 gps_date_time->sec = mavlink_msg_gps_date_time_get_sec(msg);
shimniok 0:826c6171fc1b 202 gps_date_time->visSat = mavlink_msg_gps_date_time_get_visSat(msg);
shimniok 0:826c6171fc1b 203 }