summaryrefslogtreecommitdiffhomepage
path: root/tracker-hatire/ftnoir_tracker_hat.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-05-09 10:51:32 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-05-09 10:51:32 +0200
commit2db4accd652a3a156046c373355535247b2ea7aa (patch)
treea5acf0ed02608ea36e2c0b5cd921bc0500fc2c6e /tracker-hatire/ftnoir_tracker_hat.cpp
parent469371da434e1fcd1cbe51ce8b7e493ea7580a7f (diff)
tracker/hatire: remove min length check duplication
The api callee already takes care of that so remove the "ok" argument.
Diffstat (limited to 'tracker-hatire/ftnoir_tracker_hat.cpp')
-rwxr-xr-xtracker-hatire/ftnoir_tracker_hat.cpp66
1 files changed, 29 insertions, 37 deletions
diff --git a/tracker-hatire/ftnoir_tracker_hat.cpp b/tracker-hatire/ftnoir_tracker_hat.cpp
index 25f0b903..2dc35b3b 100755
--- a/tracker-hatire/ftnoir_tracker_hat.cpp
+++ b/tracker-hatire/ftnoir_tracker_hat.cpp
@@ -88,54 +88,46 @@ void hatire::data(double *data)
{
QMutexLocker l(&t.data_mtx);
- bool ok = false;
+ QByteArray& data_read = t.send_data_read_nolock();
- QByteArray& data_read = t.send_data_read_nolock(ok);
-
- if (ok)
+ while (data_read.length() >= 30)
{
- while (data_read.length() >= 30)
+ //t.Log(data_read.toHex());
+ // .Begin==0xAAAA .End==0x5555
+ if (data_read[0] == Begin[0] && data_read[1] == Begin[1] &&
+ data_read[28] == End[0] && data_read[29] == End[1])
{
- //t.Log(data_read.toHex());
- // .Begin==0xAAAA .End==0x5555
- if (data_read[0] == Begin[0] && data_read[1] == Begin[1] &&
- data_read[28] == End[0] && data_read[29] == End[1])
- {
- QDataStream stream(&data_read, QIODevice::ReadOnly);
+ QDataStream stream(&data_read, QIODevice::ReadOnly);
- if (ts.bBigEndian)
- stream.setByteOrder(QDataStream::BigEndian);
- else
- stream.setByteOrder(QDataStream::LittleEndian);
+ if (ts.bBigEndian)
+ stream.setByteOrder(QDataStream::BigEndian);
+ else
+ stream.setByteOrder(QDataStream::LittleEndian);
- stream >> ArduinoData;
+ stream >> ArduinoData;
- frame_cnt++;
+ frame_cnt++;
- if (ArduinoData.Code <= 1000)
- HAT = ArduinoData;
- else
- emit t.serial_debug_info(data_read.mid(4,24)) ;
- data_read.remove(0, 30);
- }
+ if (ArduinoData.Code <= 1000)
+ HAT = ArduinoData;
else
+ emit t.serial_debug_info(data_read.mid(4,24)) ;
+ data_read.remove(0, 30);
+ }
+ else
+ {
+ // resync frame
+ int index = data_read.indexOf(Begin, 1);
+ if (index == -1)
+ {
+ index = data_read.length();
+ }
+
+ if (data_read.length() != 0)
{
- // resync frame
- int index = data_read.indexOf(Begin, 1);
- if (index == -1)
- {
- 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);
- }
+ data_read.remove(0, index);
CptError++;