On 21 September, 2015 - Anton Lundin wrote:

> 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 <[email protected]>
> ---
>  qtserialbluetooth.cpp | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/qtserialbluetooth.cpp b/qtserialbluetooth.cpp
> index 442702d..6e717a3 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 0;

Darn! Should have bin nbytes instead of zero here.

Dirk: will you fix that typo?


//Anton - who codes one thing and then sends something else out


-- 
Anton Lundin    +46702-161604
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to