[PATCH 2/2] qtserialbluetooth: use QIODevice::Unbuffered io

Anton Lundin glance at acc.umu.se
Tue Sep 29 12:59:31 PDT 2015


On 29 September, 2015 - Thiago Macieira wrote:

> On Tuesday 29 September 2015 21:12:55 Anton Lundin wrote:
> > This adds the QIODevice::Unbuffered flag to our rfcomm connections to
> > bypass the buffering layer in QIODevice.
> > 
> > This fixes so firmware upgrades work against the OSTC Sport.
> 
> Both patches look good.
> 
> The unbuffered mode should not have made a difference. If it does, it's probably 
> a bug somewhere (the firmware receiving the update or QtBluetooth).
> 

While playing around with this i tried all kinds of different tricks.

One that mostly worked was in qt_serial_write having a block that
looked something like:
if (device->socket->bytesToWrite() > 0) {
	QEventLoop loop;
	QTimer timer;
	...
	timer.start(device->timeout * 4); // 4 is the magic number
	...
}

Another one was spraying qDebug() << QByteArray((char *) data ....) in
lots of places.


Another one was :

-               rc = device->socket->write((char *) data + nbytes, size - nbytes);
+               rc = device->socket->write((char *) data + nbytes, size - nbytes > 16 ? 16 : size - nbytes);


All tree made things better to various degrees, but unbuffered made it
100%

All tests where made on 15.04 and different 4.2/4.3 rc kernels. I even
rebooted into the ubuntu 3.19.0-28-generic kernel to verify that there
were no wierdness in my kernel either.

Bluez 4.101-0ubuntu25 and Qt 5.5.0 binaries from qt.io.


//Anton


-- 
Anton Lundin	+46702-161604


More information about the subsurface mailing list