summaryrefslogtreecommitdiffstats
path: root/qtserialbluetooth.cpp
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2015-09-22 23:33:14 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-22 19:36:54 -0700
commit8417e84e8295d478f77512bcac455cd2ce925726 (patch)
tree1802916bf776d1275d9b637914c0f001ada8a028 /qtserialbluetooth.cpp
parent34da4801f45c6fb06d3a7b55029fc4ebd702a6e6 (diff)
downloadsubsurface-8417e84e8295d478f77512bcac455cd2ce925726.tar.gz
qtbluetooth: add a read timeout
This adds a read timeout to the qt serial bluetooth code. This is needed for error handling and error recovery purposes. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qtserialbluetooth.cpp')
-rw-r--r--qtserialbluetooth.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/qtserialbluetooth.cpp b/qtserialbluetooth.cpp
index 442702da7..ee8b2b793 100644
--- a/qtserialbluetooth.cpp
+++ b/qtserialbluetooth.cpp
@@ -248,8 +248,15 @@ static int qt_serial_read(serial_t *device, void* data, unsigned int size)
} else if (rc == 0) {
// Wait until the device is available for read operations
QEventLoop loop;
+ QTimer timer;
+ timer.setSingleShot(true);
+ loop.connect(&timer, SIGNAL(timeout()), SLOT(quit()));
loop.connect(device->socket, SIGNAL(readyRead()), SLOT(quit()));
+ timer.start(device->timeout);
loop.exec();
+
+ if (!timer.isActive())
+ return nbytes;
}
nbytes += rc;