RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_system_time.h
1#pragma once
2// MESSAGE SYSTEM_TIME PACKING
3
4#define MAVLINK_MSG_ID_SYSTEM_TIME 2
5
6MAVPACKED(
7typedef struct __mavlink_system_time_t {
8 uint64_t time_unix_usec; /*< Timestamp of the master clock in microseconds since UNIX epoch.*/
9 uint32_t time_boot_ms; /*< Timestamp of the component clock since boot time in milliseconds.*/
10}) mavlink_system_time_t;
11
12#define MAVLINK_MSG_ID_SYSTEM_TIME_LEN 12
13#define MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN 12
14#define MAVLINK_MSG_ID_2_LEN 12
15#define MAVLINK_MSG_ID_2_MIN_LEN 12
16
17#define MAVLINK_MSG_ID_SYSTEM_TIME_CRC 137
18#define MAVLINK_MSG_ID_2_CRC 137
19
20
21
22#if MAVLINK_COMMAND_24BIT
23#define MAVLINK_MESSAGE_INFO_SYSTEM_TIME { \
24 2, \
25 "SYSTEM_TIME", \
26 2, \
27 { { "time_unix_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_system_time_t, time_unix_usec) }, \
28 { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_system_time_t, time_boot_ms) }, \
29 } \
30}
31#else
32#define MAVLINK_MESSAGE_INFO_SYSTEM_TIME { \
33 "SYSTEM_TIME", \
34 2, \
35 { { "time_unix_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_system_time_t, time_unix_usec) }, \
36 { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_system_time_t, time_boot_ms) }, \
37 } \
38}
39#endif
40
51static inline uint16_t mavlink_msg_system_time_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
52 uint64_t time_unix_usec, uint32_t time_boot_ms)
53{
54#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
55 char buf[MAVLINK_MSG_ID_SYSTEM_TIME_LEN];
56 _mav_put_uint64_t(buf, 0, time_unix_usec);
57 _mav_put_uint32_t(buf, 8, time_boot_ms);
58
59 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
60#else
61 mavlink_system_time_t packet;
62 packet.time_unix_usec = time_unix_usec;
63 packet.time_boot_ms = time_boot_ms;
64
65 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
66#endif
67
68 msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME;
69 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC);
70}
71
82static inline uint16_t mavlink_msg_system_time_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
83 mavlink_message_t* msg,
84 uint64_t time_unix_usec,uint32_t time_boot_ms)
85{
86#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
87 char buf[MAVLINK_MSG_ID_SYSTEM_TIME_LEN];
88 _mav_put_uint64_t(buf, 0, time_unix_usec);
89 _mav_put_uint32_t(buf, 8, time_boot_ms);
90
91 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
92#else
93 mavlink_system_time_t packet;
94 packet.time_unix_usec = time_unix_usec;
95 packet.time_boot_ms = time_boot_ms;
96
97 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
98#endif
99
100 msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME;
101 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC);
102}
103
112static 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)
113{
114 return mavlink_msg_system_time_pack(system_id, component_id, msg, system_time->time_unix_usec, system_time->time_boot_ms);
115}
116
126static 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)
127{
128 return mavlink_msg_system_time_pack_chan(system_id, component_id, chan, msg, system_time->time_unix_usec, system_time->time_boot_ms);
129}
130
138#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
139
140static inline void mavlink_msg_system_time_send(mavlink_channel_t chan, uint64_t time_unix_usec, uint32_t time_boot_ms)
141{
142#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
143 char buf[MAVLINK_MSG_ID_SYSTEM_TIME_LEN];
144 _mav_put_uint64_t(buf, 0, time_unix_usec);
145 _mav_put_uint32_t(buf, 8, time_boot_ms);
146
147 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, buf, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC);
148#else
149 mavlink_system_time_t packet;
150 packet.time_unix_usec = time_unix_usec;
151 packet.time_boot_ms = time_boot_ms;
152
153 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)&packet, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC);
154#endif
155}
156
162static inline void mavlink_msg_system_time_send_struct(mavlink_channel_t chan, const mavlink_system_time_t* system_time)
163{
164#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
165 mavlink_msg_system_time_send(chan, system_time->time_unix_usec, system_time->time_boot_ms);
166#else
167 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)system_time, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC);
168#endif
169}
170
171#if MAVLINK_MSG_ID_SYSTEM_TIME_LEN <= MAVLINK_MAX_PAYLOAD_LEN
172/*
173 This varient of _send() can be used to save stack space by re-using
174 memory from the receive buffer. The caller provides a
175 mavlink_message_t which is the size of a full mavlink message. This
176 is usually the receive buffer for the channel, and allows a reply to an
177 incoming message with minimum stack space usage.
178 */
179static 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)
180{
181#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
182 char *buf = (char *)msgbuf;
183 _mav_put_uint64_t(buf, 0, time_unix_usec);
184 _mav_put_uint32_t(buf, 8, time_boot_ms);
185
186 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, buf, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC);
187#else
188 mavlink_system_time_t *packet = (mavlink_system_time_t *)msgbuf;
189 packet->time_unix_usec = time_unix_usec;
190 packet->time_boot_ms = time_boot_ms;
191
192 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)packet, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC);
193#endif
194}
195#endif
196
197#endif
198
199// MESSAGE SYSTEM_TIME UNPACKING
200
201
207static inline uint64_t mavlink_msg_system_time_get_time_unix_usec(const mavlink_message_t* msg)
208{
209 return _MAV_RETURN_uint64_t(msg, 0);
210}
211
217static inline uint32_t mavlink_msg_system_time_get_time_boot_ms(const mavlink_message_t* msg)
218{
219 return _MAV_RETURN_uint32_t(msg, 8);
220}
221
228static inline void mavlink_msg_system_time_decode(const mavlink_message_t* msg, mavlink_system_time_t* system_time)
229{
230#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
231 system_time->time_unix_usec = mavlink_msg_system_time_get_time_unix_usec(msg);
232 system_time->time_boot_ms = mavlink_msg_system_time_get_time_boot_ms(msg);
233#else
234 uint8_t len = msg->len < MAVLINK_MSG_ID_SYSTEM_TIME_LEN? msg->len : MAVLINK_MSG_ID_SYSTEM_TIME_LEN;
235 memset(system_time, 0, MAVLINK_MSG_ID_SYSTEM_TIME_LEN);
236 memcpy(system_time, _MAV_PAYLOAD(msg), len);
237#endif
238}