mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 22:35:27 +00:00
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>
This commit is contained in:
parent
34da4801f4
commit
8417e84e82
1 changed files with 7 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue