PDA

View Full Version : QFile waitForReadyReadyRead() and bytesAvailable() not working on generic USB device



apargeter
8th January 2016, 04:09
Hi all,

I'm having a problem where QFile.read() hangs until it eventually times out (several seconds) when reading from a USB device. I wrote the USB device driver (based on the OSRFX2 sample driver).

Neither waitForReadyRead() or bytesAvailable() work as advertised.

QFile.write() also has a delay which is unexpected but not problematic.

I wrote a c program using the stdlib read()/write() functions and it works perfectly as expected.

I am calling QFile.read() from within a QThread if that matters.

I have searched all over the WEB for answers but can't find any answers.

What could be the problem?

Is there any way to abort a QFile.read()?

Thanks,
Andrew

apargeter
8th January 2016, 18:58
I want to add that there is data available to be read by QFile read but there is a few second delay before it returns.

yeye_olive
8th January 2016, 19:47
Neither waitForReadyRead() or bytesAvailable() work as advertised.
Here is an excerpt from the documentation of QFile:
Unlike other QIODevice implementations, such as QTcpSocket, QFile does not emit the aboutToClose(), bytesWritten(), or readyRead() signals.
IFAIK there is nothing in Qt for asynchronous file I/O. See https://bugreports.qt.io/browse/QTBUG-19345.

apargeter
9th January 2016, 01:28
Forgot to mention that I am doing all of this on Ubuntu LTS 14.0.4