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_system_time.h
00001 // MESSAGE SYSTEM_TIME PACKING 00002 00003 #define MAVLINK_MSG_ID_SYSTEM_TIME 2 00004 00005 typedef struct __mavlink_system_time_t 00006 { 00007 uint64_t time_usec; ///< Timestamp of the master clock in microseconds since UNIX epoch. 00008 00009 } mavlink_system_time_t; 00010 00011 00012 00013 /** 00014 * @brief Pack a system_time message 00015 * @param system_id ID of this system 00016 * @param component_id ID of this component (e.g. 200 for IMU) 00017 * @param msg The MAVLink message to compress the data into 00018 * 00019 * @param time_usec Timestamp of the master clock in microseconds since UNIX epoch. 00020 * @return length of the message in bytes (excluding serial stream start sign) 00021 */ 00022 static inline uint16_t mavlink_msg_system_time_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint64_t time_usec) 00023 { 00024 uint16_t i = 0; 00025 msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME; 00026 00027 i += put_uint64_t_by_index(time_usec, i, msg->payload); // Timestamp of the master clock in microseconds since UNIX epoch. 00028 00029 return mavlink_finalize_message(msg, system_id, component_id, i); 00030 } 00031 00032 /** 00033 * @brief Pack a system_time message 00034 * @param system_id ID of this system 00035 * @param component_id ID of this component (e.g. 200 for IMU) 00036 * @param chan The MAVLink channel this message was sent over 00037 * @param msg The MAVLink message to compress the data into 00038 * @param time_usec Timestamp of the master clock in microseconds since UNIX epoch. 00039 * @return length of the message in bytes (excluding serial stream start sign) 00040 */ 00041 static inline uint16_t mavlink_msg_system_time_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint64_t time_usec) 00042 { 00043 uint16_t i = 0; 00044 msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME; 00045 00046 i += put_uint64_t_by_index(time_usec, i, msg->payload); // Timestamp of the master clock in microseconds since UNIX epoch. 00047 00048 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); 00049 } 00050 00051 /** 00052 * @brief Encode a system_time struct into a message 00053 * 00054 * @param system_id ID of this system 00055 * @param component_id ID of this component (e.g. 200 for IMU) 00056 * @param msg The MAVLink message to compress the data into 00057 * @param system_time C-struct to read the message contents from 00058 */ 00059 static inline uint16_t mavlink_msg_system_time_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_system_time_t* system_time) 00060 { 00061 return mavlink_msg_system_time_pack(system_id, component_id, msg, system_time->time_usec); 00062 } 00063 00064 /** 00065 * @brief Send a system_time message 00066 * @param chan MAVLink channel to send the message 00067 * 00068 * @param time_usec Timestamp of the master clock in microseconds since UNIX epoch. 00069 */ 00070 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 00071 00072 static inline void mavlink_msg_system_time_send(mavlink_channel_t chan, uint64_t time_usec) 00073 { 00074 mavlink_message_t msg; 00075 mavlink_msg_system_time_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, time_usec); 00076 mavlink_send_uart(chan, &msg); 00077 } 00078 00079 #endif 00080 // MESSAGE SYSTEM_TIME UNPACKING 00081 00082 /** 00083 * @brief Get field time_usec from system_time message 00084 * 00085 * @return Timestamp of the master clock in microseconds since UNIX epoch. 00086 */ 00087 static inline uint64_t mavlink_msg_system_time_get_time_usec(const mavlink_message_t* msg) 00088 { 00089 generic_64bit r; 00090 r.b[7] = (msg->payload)[0]; 00091 r.b[6] = (msg->payload)[1]; 00092 r.b[5] = (msg->payload)[2]; 00093 r.b[4] = (msg->payload)[3]; 00094 r.b[3] = (msg->payload)[4]; 00095 r.b[2] = (msg->payload)[5]; 00096 r.b[1] = (msg->payload)[6]; 00097 r.b[0] = (msg->payload)[7]; 00098 return (uint64_t)r.ll; 00099 } 00100 00101 /** 00102 * @brief Decode a system_time message into a struct 00103 * 00104 * @param msg The message to decode 00105 * @param system_time C-struct to decode the message contents into 00106 */ 00107 static inline void mavlink_msg_system_time_decode(const mavlink_message_t* msg, mavlink_system_time_t* system_time) 00108 { 00109 system_time->time_usec = mavlink_msg_system_time_get_time_usec(msg); 00110 }
Generated on Tue Jul 12 2022 14:09:27 by 1.7.2