From 4095e911d85a0225f180a401694e49c23e1dfb6b Mon Sep 17 00:00:00 2001 From: Phil Crump Date: Sat, 22 Feb 2020 23:24:00 +0000 Subject: [PATCH] ubxtool.cc: Use monotonic clock for uptime calculation. --- ubxtool.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ubxtool.cc b/ubxtool.cc index a1d69cb..1f4fdab 100644 --- a/ubxtool.cc +++ b/ubxtool.cc @@ -565,7 +565,7 @@ int initFD(const char* fname, bool doRTSCTS) // ubxtool device srcid int main(int argc, char** argv) { - time_t starttime=time(0); + auto starttime = std::chrono::steady_clock::now(); GOOGLE_PROTOBUF_VERIFY_VERSION; CLI::App app(program); @@ -1629,7 +1629,7 @@ int main(int argc, char** argv) nmm.mutable_od()->set_owner(owner); nmm.mutable_od()->set_remark(remark); nmm.mutable_od()->set_recvgithash(g_gitHash); - nmm.mutable_od()->set_uptime(time(0) - starttime); + nmm.mutable_od()->set_uptime(std::chrono::duration_cast(std::chrono::steady_clock::now()-starttime).count()); ns.emitNMM( nmm);