diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2014-09-21 19:45:59 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2014-09-21 21:28:15 +0200 |
commit | aafe709c798996317472de7ffdf68c466e3b4bca (patch) | |
tree | 9ed2bb05442396622437d61552317747931e12d6 /ftnoir_tracker_freepie-udp | |
parent | 34cfb18a68c3a626a8927aa1216a642c2aba35f8 (diff) |
workaround bug in apk logic
Issue: #48
flag for raw sensor data set despite datagram with fused data only
Diffstat (limited to 'ftnoir_tracker_freepie-udp')
-rw-r--r-- | ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp index 3a63df6e..7223a33f 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp @@ -1,6 +1,7 @@ #include "ftnoir_tracker_freepie-udp.h" #include "facetracknoir/plugin-support.h" +#include <stddef.h> #include <cinttypes> TrackerImpl::TrackerImpl() : pose { 0,0,0, 0,0,0 }, should_quit(false) @@ -41,9 +42,16 @@ void TrackerImpl::run() { while (sock.hasPendingDatagrams()) { data = decltype(data){0,0, 0,0,0}; - (void) sock.readDatagram(reinterpret_cast<char*>(&data), sizeof(data)); + int sz = sock.readDatagram(reinterpret_cast<char*>(&data), sizeof(data)); int flags = data.flags & F::Mask; + + constexpr int minsz = offsetof(decltype(data), raw_rot) + sizeof(decltype(data)::raw_rot); + const bool flags_came_out_wrong = minsz > sz; + + if (flags_came_out_wrong) + flags &= ~F::flag_Raw; + switch (flags) { case flag_Raw: |