summaryrefslogtreecommitdiffhomepage
path: root/tracker-udp/ftnoir_tracker_udp.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-10 10:36:37 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-08-10 10:42:03 +0200
commit5889b83298ca22dde8d374a701eed3eddd3e28de (patch)
treedb94306a4d4bd4e76305a106b0d079728fc6fc1a /tracker-udp/ftnoir_tracker_udp.cpp
parentc08d63041e184ae642486eebfb4fd770d0a142b6 (diff)
tracker/udp: quit if socket can't be bound
Diffstat (limited to 'tracker-udp/ftnoir_tracker_udp.cpp')
-rw-r--r--tracker-udp/ftnoir_tracker_udp.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/tracker-udp/ftnoir_tracker_udp.cpp b/tracker-udp/ftnoir_tracker_udp.cpp
index 1610f917..bc3bebc6 100644
--- a/tracker-udp/ftnoir_tracker_udp.cpp
+++ b/tracker-udp/ftnoir_tracker_udp.cpp
@@ -17,18 +17,20 @@ FTNoIR_Tracker::~FTNoIR_Tracker()
wait();
}
-void FTNoIR_Tracker::run() {
+void FTNoIR_Tracker::run()
+{
QByteArray datagram;
datagram.resize(sizeof(last_recv_pose));
- (void) sock.bind(QHostAddress::Any, (int) s.port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
- for (;;) {
- if (should_quit)
- break;
+
+ should_quit = sock.bind(QHostAddress::Any, quint16(s.port), QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
+
+ while (!should_quit)
+ {
{
QMutexLocker foo(&mutex);
- while (sock.hasPendingDatagrams()) {
- sock.readDatagram((char * ) last_recv_pose, sizeof(double[6]));
- }
+
+ while (sock.hasPendingDatagrams())
+ sock.readDatagram(reinterpret_cast<char*>(last_recv_pose), sizeof(double[6]));
}
msleep(1);
}
@@ -36,7 +38,7 @@ void FTNoIR_Tracker::run() {
void FTNoIR_Tracker::start_tracker(QFrame*)
{
- start();
+ start();
sock.moveToThread(this);
}
@@ -45,7 +47,7 @@ void FTNoIR_Tracker::data(double *data)
QMutexLocker foo(&mutex);
for (int i = 0; i < 6; i++)
data[i] = last_recv_pose[i];
-
+
int values[] = {
0,
90,
@@ -58,7 +60,7 @@ void FTNoIR_Tracker::data(double *data)
s.add_pitch,
s.add_roll,
};
-
+
for (int i = 0; i < 3; i++)
{
int k = std::min<unsigned>(sizeof(values)/sizeof(values[0]), std::max(0, indices[i]));