![](/media/cache/profiles/2012_sf_avc_095.jpg.50x50_q85.jpg)
Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.
Dependencies: mbed Watchdog SDFileSystem DigoleSerialDisp
MAVlink/include/slugs/mavlink_msg_gps_date_time.h@25:bb5356402687, 2018-11-30 (annotated)
- Committer:
- shimniok
- Date:
- Fri Nov 30 16:11:53 2018 +0000
- Revision:
- 25:bb5356402687
- Parent:
- 0:a6a169de725f
Initial publish of revised version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:a6a169de725f | 1 | // MESSAGE GPS_DATE_TIME PACKING |
shimniok | 0:a6a169de725f | 2 | |
shimniok | 0:a6a169de725f | 3 | #define MAVLINK_MSG_ID_GPS_DATE_TIME 179 |
shimniok | 0:a6a169de725f | 4 | |
shimniok | 0:a6a169de725f | 5 | typedef struct __mavlink_gps_date_time_t |
shimniok | 0:a6a169de725f | 6 | { |
shimniok | 0:a6a169de725f | 7 | uint8_t year; ///< Year reported by Gps |
shimniok | 0:a6a169de725f | 8 | uint8_t month; ///< Month reported by Gps |
shimniok | 0:a6a169de725f | 9 | uint8_t day; ///< Day reported by Gps |
shimniok | 0:a6a169de725f | 10 | uint8_t hour; ///< Hour reported by Gps |
shimniok | 0:a6a169de725f | 11 | uint8_t min; ///< Min reported by Gps |
shimniok | 0:a6a169de725f | 12 | uint8_t sec; ///< Sec reported by Gps |
shimniok | 0:a6a169de725f | 13 | uint8_t visSat; ///< Visible sattelites reported by Gps |
shimniok | 0:a6a169de725f | 14 | |
shimniok | 0:a6a169de725f | 15 | } mavlink_gps_date_time_t; |
shimniok | 0:a6a169de725f | 16 | |
shimniok | 0:a6a169de725f | 17 | |
shimniok | 0:a6a169de725f | 18 | |
shimniok | 0:a6a169de725f | 19 | /** |
shimniok | 0:a6a169de725f | 20 | * @brief Pack a gps_date_time message |
shimniok | 0:a6a169de725f | 21 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 22 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 23 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 24 | * |
shimniok | 0:a6a169de725f | 25 | * @param year Year reported by Gps |
shimniok | 0:a6a169de725f | 26 | * @param month Month reported by Gps |
shimniok | 0:a6a169de725f | 27 | * @param day Day reported by Gps |
shimniok | 0:a6a169de725f | 28 | * @param hour Hour reported by Gps |
shimniok | 0:a6a169de725f | 29 | * @param min Min reported by Gps |
shimniok | 0:a6a169de725f | 30 | * @param sec Sec reported by Gps |
shimniok | 0:a6a169de725f | 31 | * @param visSat Visible sattelites reported by Gps |
shimniok | 0:a6a169de725f | 32 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:a6a169de725f | 33 | */ |
shimniok | 0:a6a169de725f | 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:a6a169de725f | 35 | { |
shimniok | 0:a6a169de725f | 36 | uint16_t i = 0; |
shimniok | 0:a6a169de725f | 37 | msg->msgid = MAVLINK_MSG_ID_GPS_DATE_TIME; |
shimniok | 0:a6a169de725f | 38 | |
shimniok | 0:a6a169de725f | 39 | i += put_uint8_t_by_index(year, i, msg->payload); // Year reported by Gps |
shimniok | 0:a6a169de725f | 40 | i += put_uint8_t_by_index(month, i, msg->payload); // Month reported by Gps |
shimniok | 0:a6a169de725f | 41 | i += put_uint8_t_by_index(day, i, msg->payload); // Day reported by Gps |
shimniok | 0:a6a169de725f | 42 | i += put_uint8_t_by_index(hour, i, msg->payload); // Hour reported by Gps |
shimniok | 0:a6a169de725f | 43 | i += put_uint8_t_by_index(min, i, msg->payload); // Min reported by Gps |
shimniok | 0:a6a169de725f | 44 | i += put_uint8_t_by_index(sec, i, msg->payload); // Sec reported by Gps |
shimniok | 0:a6a169de725f | 45 | i += put_uint8_t_by_index(visSat, i, msg->payload); // Visible sattelites reported by Gps |
shimniok | 0:a6a169de725f | 46 | |
shimniok | 0:a6a169de725f | 47 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:a6a169de725f | 48 | } |
shimniok | 0:a6a169de725f | 49 | |
shimniok | 0:a6a169de725f | 50 | /** |
shimniok | 0:a6a169de725f | 51 | * @brief Pack a gps_date_time message |
shimniok | 0:a6a169de725f | 52 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 53 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 54 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:a6a169de725f | 55 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 56 | * @param year Year reported by Gps |
shimniok | 0:a6a169de725f | 57 | * @param month Month reported by Gps |
shimniok | 0:a6a169de725f | 58 | * @param day Day reported by Gps |
shimniok | 0:a6a169de725f | 59 | * @param hour Hour reported by Gps |
shimniok | 0:a6a169de725f | 60 | * @param min Min reported by Gps |
shimniok | 0:a6a169de725f | 61 | * @param sec Sec reported by Gps |
shimniok | 0:a6a169de725f | 62 | * @param visSat Visible sattelites reported by Gps |
shimniok | 0:a6a169de725f | 63 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:a6a169de725f | 64 | */ |
shimniok | 0:a6a169de725f | 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:a6a169de725f | 66 | { |
shimniok | 0:a6a169de725f | 67 | uint16_t i = 0; |
shimniok | 0:a6a169de725f | 68 | msg->msgid = MAVLINK_MSG_ID_GPS_DATE_TIME; |
shimniok | 0:a6a169de725f | 69 | |
shimniok | 0:a6a169de725f | 70 | i += put_uint8_t_by_index(year, i, msg->payload); // Year reported by Gps |
shimniok | 0:a6a169de725f | 71 | i += put_uint8_t_by_index(month, i, msg->payload); // Month reported by Gps |
shimniok | 0:a6a169de725f | 72 | i += put_uint8_t_by_index(day, i, msg->payload); // Day reported by Gps |
shimniok | 0:a6a169de725f | 73 | i += put_uint8_t_by_index(hour, i, msg->payload); // Hour reported by Gps |
shimniok | 0:a6a169de725f | 74 | i += put_uint8_t_by_index(min, i, msg->payload); // Min reported by Gps |
shimniok | 0:a6a169de725f | 75 | i += put_uint8_t_by_index(sec, i, msg->payload); // Sec reported by Gps |
shimniok | 0:a6a169de725f | 76 | i += put_uint8_t_by_index(visSat, i, msg->payload); // Visible sattelites reported by Gps |
shimniok | 0:a6a169de725f | 77 | |
shimniok | 0:a6a169de725f | 78 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:a6a169de725f | 79 | } |
shimniok | 0:a6a169de725f | 80 | |
shimniok | 0:a6a169de725f | 81 | /** |
shimniok | 0:a6a169de725f | 82 | * @brief Encode a gps_date_time struct into a message |
shimniok | 0:a6a169de725f | 83 | * |
shimniok | 0:a6a169de725f | 84 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 85 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 86 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 87 | * @param gps_date_time C-struct to read the message contents from |
shimniok | 0:a6a169de725f | 88 | */ |
shimniok | 0:a6a169de725f | 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:a6a169de725f | 90 | { |
shimniok | 0:a6a169de725f | 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:a6a169de725f | 92 | } |
shimniok | 0:a6a169de725f | 93 | |
shimniok | 0:a6a169de725f | 94 | /** |
shimniok | 0:a6a169de725f | 95 | * @brief Send a gps_date_time message |
shimniok | 0:a6a169de725f | 96 | * @param chan MAVLink channel to send the message |
shimniok | 0:a6a169de725f | 97 | * |
shimniok | 0:a6a169de725f | 98 | * @param year Year reported by Gps |
shimniok | 0:a6a169de725f | 99 | * @param month Month reported by Gps |
shimniok | 0:a6a169de725f | 100 | * @param day Day reported by Gps |
shimniok | 0:a6a169de725f | 101 | * @param hour Hour reported by Gps |
shimniok | 0:a6a169de725f | 102 | * @param min Min reported by Gps |
shimniok | 0:a6a169de725f | 103 | * @param sec Sec reported by Gps |
shimniok | 0:a6a169de725f | 104 | * @param visSat Visible sattelites reported by Gps |
shimniok | 0:a6a169de725f | 105 | */ |
shimniok | 0:a6a169de725f | 106 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:a6a169de725f | 107 | |
shimniok | 0:a6a169de725f | 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:a6a169de725f | 109 | { |
shimniok | 0:a6a169de725f | 110 | mavlink_message_t msg; |
shimniok | 0:a6a169de725f | 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:a6a169de725f | 112 | mavlink_send_uart(chan, &msg); |
shimniok | 0:a6a169de725f | 113 | } |
shimniok | 0:a6a169de725f | 114 | |
shimniok | 0:a6a169de725f | 115 | #endif |
shimniok | 0:a6a169de725f | 116 | // MESSAGE GPS_DATE_TIME UNPACKING |
shimniok | 0:a6a169de725f | 117 | |
shimniok | 0:a6a169de725f | 118 | /** |
shimniok | 0:a6a169de725f | 119 | * @brief Get field year from gps_date_time message |
shimniok | 0:a6a169de725f | 120 | * |
shimniok | 0:a6a169de725f | 121 | * @return Year reported by Gps |
shimniok | 0:a6a169de725f | 122 | */ |
shimniok | 0:a6a169de725f | 123 | static inline uint8_t mavlink_msg_gps_date_time_get_year(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 124 | { |
shimniok | 0:a6a169de725f | 125 | return (uint8_t)(msg->payload)[0]; |
shimniok | 0:a6a169de725f | 126 | } |
shimniok | 0:a6a169de725f | 127 | |
shimniok | 0:a6a169de725f | 128 | /** |
shimniok | 0:a6a169de725f | 129 | * @brief Get field month from gps_date_time message |
shimniok | 0:a6a169de725f | 130 | * |
shimniok | 0:a6a169de725f | 131 | * @return Month reported by Gps |
shimniok | 0:a6a169de725f | 132 | */ |
shimniok | 0:a6a169de725f | 133 | static inline uint8_t mavlink_msg_gps_date_time_get_month(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 134 | { |
shimniok | 0:a6a169de725f | 135 | return (uint8_t)(msg->payload+sizeof(uint8_t))[0]; |
shimniok | 0:a6a169de725f | 136 | } |
shimniok | 0:a6a169de725f | 137 | |
shimniok | 0:a6a169de725f | 138 | /** |
shimniok | 0:a6a169de725f | 139 | * @brief Get field day from gps_date_time message |
shimniok | 0:a6a169de725f | 140 | * |
shimniok | 0:a6a169de725f | 141 | * @return Day reported by Gps |
shimniok | 0:a6a169de725f | 142 | */ |
shimniok | 0:a6a169de725f | 143 | static inline uint8_t mavlink_msg_gps_date_time_get_day(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 144 | { |
shimniok | 0:a6a169de725f | 145 | return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t))[0]; |
shimniok | 0:a6a169de725f | 146 | } |
shimniok | 0:a6a169de725f | 147 | |
shimniok | 0:a6a169de725f | 148 | /** |
shimniok | 0:a6a169de725f | 149 | * @brief Get field hour from gps_date_time message |
shimniok | 0:a6a169de725f | 150 | * |
shimniok | 0:a6a169de725f | 151 | * @return Hour reported by Gps |
shimniok | 0:a6a169de725f | 152 | */ |
shimniok | 0:a6a169de725f | 153 | static inline uint8_t mavlink_msg_gps_date_time_get_hour(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 154 | { |
shimniok | 0:a6a169de725f | 155 | return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t))[0]; |
shimniok | 0:a6a169de725f | 156 | } |
shimniok | 0:a6a169de725f | 157 | |
shimniok | 0:a6a169de725f | 158 | /** |
shimniok | 0:a6a169de725f | 159 | * @brief Get field min from gps_date_time message |
shimniok | 0:a6a169de725f | 160 | * |
shimniok | 0:a6a169de725f | 161 | * @return Min reported by Gps |
shimniok | 0:a6a169de725f | 162 | */ |
shimniok | 0:a6a169de725f | 163 | static inline uint8_t mavlink_msg_gps_date_time_get_min(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 164 | { |
shimniok | 0:a6a169de725f | 165 | return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t))[0]; |
shimniok | 0:a6a169de725f | 166 | } |
shimniok | 0:a6a169de725f | 167 | |
shimniok | 0:a6a169de725f | 168 | /** |
shimniok | 0:a6a169de725f | 169 | * @brief Get field sec from gps_date_time message |
shimniok | 0:a6a169de725f | 170 | * |
shimniok | 0:a6a169de725f | 171 | * @return Sec reported by Gps |
shimniok | 0:a6a169de725f | 172 | */ |
shimniok | 0:a6a169de725f | 173 | static inline uint8_t mavlink_msg_gps_date_time_get_sec(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 174 | { |
shimniok | 0:a6a169de725f | 175 | return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t))[0]; |
shimniok | 0:a6a169de725f | 176 | } |
shimniok | 0:a6a169de725f | 177 | |
shimniok | 0:a6a169de725f | 178 | /** |
shimniok | 0:a6a169de725f | 179 | * @brief Get field visSat from gps_date_time message |
shimniok | 0:a6a169de725f | 180 | * |
shimniok | 0:a6a169de725f | 181 | * @return Visible sattelites reported by Gps |
shimniok | 0:a6a169de725f | 182 | */ |
shimniok | 0:a6a169de725f | 183 | static inline uint8_t mavlink_msg_gps_date_time_get_visSat(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 184 | { |
shimniok | 0:a6a169de725f | 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:a6a169de725f | 186 | } |
shimniok | 0:a6a169de725f | 187 | |
shimniok | 0:a6a169de725f | 188 | /** |
shimniok | 0:a6a169de725f | 189 | * @brief Decode a gps_date_time message into a struct |
shimniok | 0:a6a169de725f | 190 | * |
shimniok | 0:a6a169de725f | 191 | * @param msg The message to decode |
shimniok | 0:a6a169de725f | 192 | * @param gps_date_time C-struct to decode the message contents into |
shimniok | 0:a6a169de725f | 193 | */ |
shimniok | 0:a6a169de725f | 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:a6a169de725f | 195 | { |
shimniok | 0:a6a169de725f | 196 | gps_date_time->year = mavlink_msg_gps_date_time_get_year(msg); |
shimniok | 0:a6a169de725f | 197 | gps_date_time->month = mavlink_msg_gps_date_time_get_month(msg); |
shimniok | 0:a6a169de725f | 198 | gps_date_time->day = mavlink_msg_gps_date_time_get_day(msg); |
shimniok | 0:a6a169de725f | 199 | gps_date_time->hour = mavlink_msg_gps_date_time_get_hour(msg); |
shimniok | 0:a6a169de725f | 200 | gps_date_time->min = mavlink_msg_gps_date_time_get_min(msg); |
shimniok | 0:a6a169de725f | 201 | gps_date_time->sec = mavlink_msg_gps_date_time_get_sec(msg); |
shimniok | 0:a6a169de725f | 202 | gps_date_time->visSat = mavlink_msg_gps_date_time_get_visSat(msg); |
shimniok | 0:a6a169de725f | 203 | } |