From acec691b5d6d6373e8f8f41f288d5fb6e2f84215 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 9 May 2016 16:25:31 +0200 Subject: tracker/hatire: add serial 100% cpu usage workaround Issue: #327 --- tracker-hatire/thread.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'tracker-hatire/thread.cpp') diff --git a/tracker-hatire/thread.cpp b/tracker-hatire/thread.cpp index 238c5fdd..d512e463 100755 --- a/tracker-hatire/thread.cpp +++ b/tracker-hatire/thread.cpp @@ -309,11 +309,14 @@ void hatire_thread::on_serial_read() qDebug() << "stat:" << "avg" << stat.avg() << "stddev" << stat.stddev(); } - // qt can fire QSerialPort::readyRead() needlessly, causing a busy loop. - // see https://github.com/opentrack/opentrack/issues/327#issuecomment-207941003 - constexpr int hz = 90; - constexpr int ms = 1000/hz; - portable::sleep(ms); + if (s.serial_bug_workaround) + { + // qt can fire QSerialPort::readyRead() needlessly, causing a busy loop. + // see https://github.com/opentrack/opentrack/issues/327#issuecomment-207941003 + constexpr int hz = 90; + constexpr int ms = 1000/hz; + portable::sleep(ms); + } } QByteArray& hatire_thread::send_data_read_nolock() -- cgit v1.2.3