From 21cb382c2a09405d9ca85e4193582bfd8ae00731 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 3 Jul 2018 08:23:05 +0200 Subject: cleanup --- tracker-hatire/lang/nl_NL.ts | 8 -------- tracker-hatire/lang/ru_RU.ts | 8 -------- tracker-hatire/lang/stub.ts | 8 -------- tracker-hatire/lang/zh_CN.ts | 8 -------- tracker-hatire/thread.cpp | 24 ++++++++++-------------- tracker-hatire/thread.hpp | 8 +------- 6 files changed, 11 insertions(+), 53 deletions(-) (limited to 'tracker-hatire') diff --git a/tracker-hatire/lang/nl_NL.ts b/tracker-hatire/lang/nl_NL.ts index aee6d99c..a1e613b0 100644 --- a/tracker-hatire/lang/nl_NL.ts +++ b/tracker-hatire/lang/nl_NL.ts @@ -15,14 +15,6 @@ Serial port - - Buggy serial port uses too much CPU - - - - Workaround - - Zero diff --git a/tracker-hatire/lang/ru_RU.ts b/tracker-hatire/lang/ru_RU.ts index b25d092b..f7f3024d 100644 --- a/tracker-hatire/lang/ru_RU.ts +++ b/tracker-hatire/lang/ru_RU.ts @@ -15,14 +15,6 @@ Serial port - - Buggy serial port uses too much CPU - - - - Workaround - - Zero diff --git a/tracker-hatire/lang/stub.ts b/tracker-hatire/lang/stub.ts index b920a489..0d22bf81 100644 --- a/tracker-hatire/lang/stub.ts +++ b/tracker-hatire/lang/stub.ts @@ -15,14 +15,6 @@ Serial port - - Buggy serial port uses too much CPU - - - - Workaround - - Zero diff --git a/tracker-hatire/lang/zh_CN.ts b/tracker-hatire/lang/zh_CN.ts index b920a489..0d22bf81 100644 --- a/tracker-hatire/lang/zh_CN.ts +++ b/tracker-hatire/lang/zh_CN.ts @@ -15,14 +15,6 @@ Serial port - - Buggy serial port uses too much CPU - - - - Workaround - - Zero diff --git a/tracker-hatire/thread.cpp b/tracker-hatire/thread.cpp index 07e97d78..3eb2579f 100644 --- a/tracker-hatire/thread.cpp +++ b/tracker-hatire/thread.cpp @@ -1,13 +1,15 @@ #include "thread.hpp" -#include "compat/sleep.hpp" #include "compat/base-path.hpp" +#include "compat/sleep.hpp" + #include +#include #include #include -#include +#include -#include +#include void hatire_thread::sendcmd_impl(const QByteArray &cmd) { @@ -123,7 +125,8 @@ void hatire_thread::teardown_serial() } emit serial_debug_info(msg); - disconnect(&com_port, SIGNAL(readyRead()), nullptr, nullptr); + // XXX does this make any sense? -sh 20180703 + //disconnect(&com_port, SIGNAL(readyRead()), nullptr, nullptr); com_port.close(); } } @@ -305,9 +308,6 @@ void hatire_thread::on_serial_read() if (sz > 0) { - stat.input(timer.elapsed_ms()); - timer.start(); - QMutexLocker lck(&data_mtx); data_read.append(buf, sz); } @@ -319,20 +319,16 @@ void hatire_thread::on_serial_read() } #endif - if (s.serial_bug_workaround || sz <= 0) + if (sz <= 0) { // qt can fire QSerialPort::readyRead() needlessly, causing a busy loop. // see https://github.com/opentrack/opentrack/issues/327#issuecomment-207941003 + + // this probably happens with flaky BT/usb-to-serial converters (?) constexpr int hz = 90; constexpr int ms = 1000/hz; portable::sleep(ms); } - - if (throttle_timer.elapsed_ms() >= 3000) - { - throttle_timer.start(); - qDebug() << "stat:" << "avg" << stat.avg() << "stddev" << stat.stddev(); - } } QByteArray& hatire_thread::send_data_read_nolock() diff --git a/tracker-hatire/thread.hpp b/tracker-hatire/thread.hpp index 93c50c9e..5cecbdce 100644 --- a/tracker-hatire/thread.hpp +++ b/tracker-hatire/thread.hpp @@ -4,16 +4,12 @@ #include "ftnoir_tracker_hat_settings.h" #include -#include #include #include #include #include -#include "compat/variance.hpp" -#include "compat/timer.hpp" - enum results { result_ok, @@ -34,7 +30,7 @@ struct serial_result serial_result(results code, const QString& error) : error(error), code(code) {} QString error; - results code; + results code { result_error }; }; class hatire_thread : public QThread @@ -51,8 +47,6 @@ class hatire_thread : public QThread QByteArray data_read; serial_t com_port; TrackerSettings s; - variance stat; - Timer timer, throttle_timer; char buf[1024]; void run() override; -- cgit v1.2.3