libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
linux_timebase.hpp
1#include <sys/time.h>
2
3#include "timebase.hpp"
4
5extern struct timeval libxr_linux_start_time;
6
7namespace LibXR
8{
13class LinuxTimebase : public Timebase
14{
15 public:
22 {
23 struct timeval tv;
24 gettimeofday(&tv, nullptr);
25 return ((tv.tv_sec - libxr_linux_start_time.tv_sec) * 1000000 +
26 (tv.tv_usec - libxr_linux_start_time.tv_usec)) %
27 UINT32_MAX;
28 }
29
36 {
37 struct timeval tv;
38 gettimeofday(&tv, nullptr);
39 return ((tv.tv_sec - libxr_linux_start_time.tv_sec) * 1000 +
40 (tv.tv_usec - libxr_linux_start_time.tv_usec) / 1000) %
41 UINT32_MAX;
42 }
43};
44} // namespace LibXR
Linux 时间基准实现 / Linux timebase implementation.
MicrosecondTimestamp _get_microseconds()
获取当前微秒计数 / Get current timestamp in microseconds
MillisecondTimestamp _get_milliseconds()
获取当前毫秒计数 / Get current timestamp in milliseconds
表示微秒级时间戳的类。Class representing a timestamp in microseconds.
表示毫秒级时间戳的类。Class representing a timestamp in milliseconds.
时间基类,用于提供高精度时间戳。 Timebase class for providing high-precision timestamps.
Definition timebase.hpp:18
LibXR 命名空间
Definition ch32_can.hpp:14