diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-05-06 09:14:03 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-05-06 09:18:19 +0200 |
commit | aaa4ed77a2506144f470ce2b7fb269bedd17a2b3 (patch) | |
tree | 2536c83f06ae58743e48a39e498ad2712e597c4d /tracker-hatire | |
parent | e19893b91326e53868136bbf0f2cf6835344cc7c (diff) |
tracker/hatire: simplify
We don't need to move back the datagram since we're processing the
original.
Diffstat (limited to 'tracker-hatire')
-rwxr-xr-x | tracker-hatire/ftnoir_tracker_hat.cpp | 12 | ||||
-rwxr-xr-x | tracker-hatire/thread.cpp | 5 | ||||
-rwxr-xr-x | tracker-hatire/thread.hpp | 2 |
3 files changed, 6 insertions, 13 deletions
diff --git a/tracker-hatire/ftnoir_tracker_hat.cpp b/tracker-hatire/ftnoir_tracker_hat.cpp index 1ac0a1ad..25f0b903 100755 --- a/tracker-hatire/ftnoir_tracker_hat.cpp +++ b/tracker-hatire/ftnoir_tracker_hat.cpp @@ -10,6 +10,7 @@ */ #include <QDebug> #include "ftnoir_tracker_hat.h" +#include <algorithm> hatire::hatire() { @@ -93,7 +94,6 @@ void hatire::data(double *data) if (ok) { - while (data_read.length() >= 30) { //t.Log(data_read.toHex()); @@ -120,28 +120,28 @@ void hatire::data(double *data) } else { - bool ok = true; // resync frame int index = data_read.indexOf(Begin, 1); if (index == -1) { - ok = false; index = data_read.length(); } emit t.serial_debug_info(data_read.mid(0,index)); if (!ok) + { data_read.clear(); + } else + { data_read.remove(0, index); + } CptError++; - qDebug() << QTime::currentTime() << "hatire resync stream" << "index" << index << "ok" << ok; + qDebug() << QTime::currentTime() << "hatire resync stream" << "index" << index << "remaining" << data_read.size(); } } - - t.replace_data_nolock(std::move(data_read)); } } diff --git a/tracker-hatire/thread.cpp b/tracker-hatire/thread.cpp index a33d58e0..40648c9f 100755 --- a/tracker-hatire/thread.cpp +++ b/tracker-hatire/thread.cpp @@ -276,11 +276,6 @@ void hatire_thread::on_serial_read() portable::sleep(ms); } -void hatire_thread::replace_data_nolock(QByteArray&& data) -{ - data_read = std::move(data); -} - QByteArray& hatire_thread::send_data_read_nolock(bool& ret) { constexpr int packet_len = 30; diff --git a/tracker-hatire/thread.hpp b/tracker-hatire/thread.hpp index b1861bac..39719ef8 100755 --- a/tracker-hatire/thread.hpp +++ b/tracker-hatire/thread.hpp @@ -165,8 +165,6 @@ public: ~hatire_thread() override; hatire_thread(); - void replace_data_nolock(QByteArray&& data); - QByteArray& send_data_read_nolock(bool& ret); void Log(const QString& message); |