From 5843b0d3651d635677e9884bdfa2f8daf8681090 Mon Sep 17 00:00:00 2001 From: steffen Date: Sun, 7 Mar 2021 18:20:54 +0000 Subject: [PATCH] fixed sleep function, hight cpu load while doing nothing --- server/server.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/server.cc b/server/server.cc index bfc7b38..4643541 100644 --- a/server/server.cc +++ b/server/server.cc @@ -117,18 +117,18 @@ void Server::ThreadProcess() { // // mode manual else if (mode == SMODE_MANUAL) { + server->locomotives.Loop(); } // // mode auto else if (mode == SMODE_AUTO) { - server->locomotives.Loop(); } gettimeofday (&tv, NULL); i = (tv.tv_sec-tv_loop.tv_sec) * 1000 + (tv.tv_usec - tv_loop.tv_usec) / 1000; if (i > cycletime_max) cycletime_max = i; - if (i < 25 && i > 0) usleep (25000 - i*1000); + if (i < 25 && i >= 0) usleep (25000 - i*1000); gettimeofday (&tv, NULL); i = (tv.tv_sec-tv_loop.tv_sec) * 1000 + (tv.tv_usec - tv_loop.tv_usec) / 1000; if (i > cyclelooptime_max) cyclelooptime_max = i;