/* * Copyright (C) 2014 Pavel Kirienko */ #include #include #include #include static std::string systime2str(const std::chrono::system_clock::time_point& tp) { const auto tt = std::chrono::system_clock::to_time_t(tp); return std::ctime(&tt); } int main() { 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 { clock.adjustUtc(uavcan::UtcDuration::fromUSec(sec * 1e6)); } catch (const uavcan_linux::Exception& ex) { std::cout << ex.what() << std::endl; std::cout << strerror(ex.getErrno()) << std::endl; return 1; } const auto after = std::chrono::system_clock::now(); std::cout << "Time before: " << systime2str(before) << "\n" << "Time after: " << systime2str(after) << "\n" << "Millisecond diff (after - before): " << std::chrono::duration_cast(after - before).count() << std::endl; return 0; }