mavlink_msg_system_time.h
Go to the documentation of this file.
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_unix_usec; /*< Timestamp of the master clock in microseconds since UNIX epoch.*/
00008  uint32_t time_boot_ms; /*< Timestamp of the component clock since boot time in milliseconds.*/
00009 } mavlink_system_time_t;
00010 
00011 #define MAVLINK_MSG_ID_SYSTEM_TIME_LEN 12
00012 #define MAVLINK_MSG_ID_2_LEN 12
00013 
00014 #define MAVLINK_MSG_ID_SYSTEM_TIME_CRC 137
00015 #define MAVLINK_MSG_ID_2_CRC 137
00016 
00017 
00018 
00019 #define MAVLINK_MESSAGE_INFO_SYSTEM_TIME { \
00020         "SYSTEM_TIME", \
00021         2, \
00022         {  { "time_unix_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_system_time_t, time_unix_usec) }, \
00023          { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_system_time_t, time_boot_ms) }, \
00024          } \
00025 }
00026 
00027 
00038 static inline uint16_t mavlink_msg_system_time_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
00039                                                        uint64_t time_unix_usec, uint32_t time_boot_ms)
00040 {
00041 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
00042         char buf[MAVLINK_MSG_ID_SYSTEM_TIME_LEN];
00043         _mav_put_uint64_t(buf, 0, time_unix_usec);
00044         _mav_put_uint32_t(buf, 8, time_boot_ms);
00045 
00046         memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
00047 #else
00048         mavlink_system_time_t packet;
00049         packet.time_unix_usec = time_unix_usec;
00050         packet.time_boot_ms = time_boot_ms;
00051 
00052         memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
00053 #endif
00054 
00055         msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME;
00056 #if MAVLINK_CRC_EXTRA
00057     return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC);
00058 #else
00059     return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
00060 #endif
00061 }
00062 
00073 static inline uint16_t mavlink_msg_system_time_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
00074                                                            mavlink_message_t* msg,
00075                                                            uint64_t time_unix_usec,uint32_t time_boot_ms)
00076 {
00077 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
00078         char buf[MAVLINK_MSG_ID_SYSTEM_TIME_LEN];
00079         _mav_put_uint64_t(buf, 0, time_unix_usec);
00080         _mav_put_uint32_t(buf, 8, time_boot_ms);
00081 
00082         memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
00083 #else
00084         mavlink_system_time_t packet;
00085         packet.time_unix_usec = time_unix_usec;
00086         packet.time_boot_ms = time_boot_ms;
00087 
00088         memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
00089 #endif
00090 
00091         msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME;
00092 #if MAVLINK_CRC_EXTRA
00093     return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC);
00094 #else
00095     return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
00096 #endif
00097 }
00098 
00107 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)
00108 {
00109         return mavlink_msg_system_time_pack(system_id, component_id, msg, system_time->time_unix_usec, system_time->time_boot_ms);
00110 }
00111 
00121 static inline uint16_t mavlink_msg_system_time_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_system_time_t* system_time)
00122 {
00123         return mavlink_msg_system_time_pack_chan(system_id, component_id, chan, msg, system_time->time_unix_usec, system_time->time_boot_ms);
00124 }
00125 
00133 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
00134 
00135 static inline void mavlink_msg_system_time_send(mavlink_channel_t chan, uint64_t time_unix_usec, uint32_t time_boot_ms)
00136 {
00137 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
00138         char buf[MAVLINK_MSG_ID_SYSTEM_TIME_LEN];
00139         _mav_put_uint64_t(buf, 0, time_unix_usec);
00140         _mav_put_uint32_t(buf, 8, time_boot_ms);
00141 
00142 #if MAVLINK_CRC_EXTRA
00143     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, buf, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC);
00144 #else
00145     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, buf, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
00146 #endif
00147 #else
00148         mavlink_system_time_t packet;
00149         packet.time_unix_usec = time_unix_usec;
00150         packet.time_boot_ms = time_boot_ms;
00151 
00152 #if MAVLINK_CRC_EXTRA
00153     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)&packet, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC);
00154 #else
00155     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)&packet, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
00156 #endif
00157 #endif
00158 }
00159 
00160 #if MAVLINK_MSG_ID_SYSTEM_TIME_LEN <= MAVLINK_MAX_PAYLOAD_LEN
00161 /*
00162   This varient of _send() can be used to save stack space by re-using
00163   memory from the receive buffer.  The caller provides a
00164   mavlink_message_t which is the size of a full mavlink message. This
00165   is usually the receive buffer for the channel, and allows a reply to an
00166   incoming message with minimum stack space usage.
00167  */
00168 static inline void mavlink_msg_system_time_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan,  uint64_t time_unix_usec, uint32_t time_boot_ms)
00169 {
00170 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
00171         char *buf = (char *)msgbuf;
00172         _mav_put_uint64_t(buf, 0, time_unix_usec);
00173         _mav_put_uint32_t(buf, 8, time_boot_ms);
00174 
00175 #if MAVLINK_CRC_EXTRA
00176     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, buf, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC);
00177 #else
00178     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, buf, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
00179 #endif
00180 #else
00181         mavlink_system_time_t *packet = (mavlink_system_time_t *)msgbuf;
00182         packet->time_unix_usec = time_unix_usec;
00183         packet->time_boot_ms = time_boot_ms;
00184 
00185 #if MAVLINK_CRC_EXTRA
00186     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)packet, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC);
00187 #else
00188     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)packet, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
00189 #endif
00190 #endif
00191 }
00192 #endif
00193 
00194 #endif
00195 
00196 // MESSAGE SYSTEM_TIME UNPACKING
00197 
00198 
00204 static inline uint64_t mavlink_msg_system_time_get_time_unix_usec(const mavlink_message_t* msg)
00205 {
00206         return _MAV_RETURN_uint64_t(msg,  0);
00207 }
00208 
00214 static inline uint32_t mavlink_msg_system_time_get_time_boot_ms(const mavlink_message_t* msg)
00215 {
00216         return _MAV_RETURN_uint32_t(msg,  8);
00217 }
00218 
00225 static inline void mavlink_msg_system_time_decode(const mavlink_message_t* msg, mavlink_system_time_t* system_time)
00226 {
00227 #if MAVLINK_NEED_BYTE_SWAP
00228         system_time->time_unix_usec = mavlink_msg_system_time_get_time_unix_usec(msg);
00229         system_time->time_boot_ms = mavlink_msg_system_time_get_time_boot_ms(msg);
00230 #else
00231         memcpy(system_time, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
00232 #endif
00233 }


dji_sdk_dji2mav
Author(s):
autogenerated on Thu Jun 6 2019 17:55:35