[Qt-creator] QFile read blocks forever on stty USB unplugging

Coda Highland coda at bobandgeorge.com
Fri Oct 9 17:58:07 CEST 2009


This is the wrong mailing list -- you should ask non-Creator questions
on qt-interest -- but let me answer you briefly because this is a
fairly simple question: QFile is incapable of dealing with non-file
devices, and what you're observing is exactly the problems you'll
encounter if you try. If QextSerialPort isn't working for you, try
QxtSerialDevice on UNIX platforms (I wrote it myself; feel free to
contact me at ahigerd at libqxt.org if you need further support).

/s/ Adam

On Fri, Oct 9, 2009 at 10:50 AM, Christophe Meessen
<christophe at meessen.net> wrote:
> Hello,
>
> my program has to communicate with a device through an RS232 connection.
> My OS is Linux and I'm using a USB to RS232 cable.
>
> I'm also using the qextserialport library but I suspect the problem is
> in QFile read operation.
>
> I'm not testing robustness of the system by checking how my program
> behaves when the device is switched off and on.
>
> The thing is that I open a device file to communicate with RS232. The
> connection remains open and functionning when the device is switched off
> and on. The read operation timesout and I can detect this since I get an
> empty response back. Retrying periodically is all it takes to recover
> when the device is switched on again.
>
> The problem shows up when I unplug the usb cable from the PC. The read
> operation seem to block forever (I didn't wait more than 10s though). If
> I reconnect the usb, it is assigned a different device file name and the
> program remains blocked. I have to kill it to stop it. The blocking read
> is in a separate thread for asynchronous operation.
>
> Shouldn't there be a timeout or a detection of the usb plug disconnection ?
>
>
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-creator
>



More information about the Qt-creator-old mailing list