mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 02:27:36 +08:00
Linux: Auto-detecting clock adjustment mode
This commit is contained in:
@@ -15,12 +15,36 @@ static std::string systime2str(const std::chrono::system_clock::time_point& tp)
|
||||
|
||||
int main()
|
||||
{
|
||||
uavcan_linux::SystemClock clock;
|
||||
|
||||
/*
|
||||
* Auto-detected clock adjustment mode
|
||||
*/
|
||||
std::cout << "Clock adjustment mode: ";
|
||||
switch (clock.getAdjustmentMode())
|
||||
{
|
||||
case uavcan_linux::ClockAdjustmentMode::SystemWide:
|
||||
{
|
||||
std::cout << "SystemWide";
|
||||
break;
|
||||
}
|
||||
case uavcan_linux::ClockAdjustmentMode::PerDriverPrivate:
|
||||
{
|
||||
std::cout << "PerDriverPrivate";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
std::abort();
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
/*
|
||||
* Test adjustment
|
||||
*/
|
||||
double sec = 0;
|
||||
std::cout << "Enter system time adjustment in seconds (fractions allowed): " << std::endl;
|
||||
std::cin >> sec;
|
||||
|
||||
uavcan_linux::SystemClock clock;
|
||||
|
||||
const auto before = std::chrono::system_clock::now();
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user