[Interest] QSerialPort read issue

nus1998 nus1998 at yeah.net
Wed Oct 16 05:51:00 CEST 2013


I write a workaround function as below which now works although the actual timeout doesn't match with "TIMEOUT" since sometimes "waitForReadyRead" will return immediately without data available. I have patched "https://codereview.qt-project.org/#patch,sidebyside,67962,2,src/serialport/qserialport_win.cpp" yet.


boolWidget::waitBytes(qint64n)
{
for(inti=0;i<TIMEOUT;i++)
{
if(m_serial->bytesAvailable()>=n)
returntrue;


m_serial->waitForReadyRead(1);
}


returnfalse;
}







At 2013-10-16 11:41:18,"Mandeep Sandhu" <mandeepsandhu.chd at gmail.com> wrote:
>You can also try doing a raw read (non Qt way) on the device using
>open/read system calls and check if data is actually available.
>That'll make sure that the OS is indeed receiving data and the problem
>can then be isolated to QSerialPort.
>
>HTH,
>-mandeep
>
>On Wed, Oct 16, 2013 at 6:25 AM, nus1998 <nus1998 at yeah.net> wrote:
>> HI Denis,
>>
>> Thanks for the reply.
>>
>> Even if I don't use "waitForReadyRead" but polling "bytesAvailable" instead,
>> the later always returns 0 although there is data received and I can use
>> other terminal software to display it too.
>>
>> Best regards,
>> Je
>>
>>
>>
>>
>>
>> At 2013-10-16 01:15:36,"Denis Shienkov" <scapig2 at yandex.ru> wrote:
>>
>> Hi.
>>
>> Seems it is a bug, see: https://bugreports.qt-project.org/browse/QTBUG-33987
>>
>> You can test this patch.
>>
>> Besd regards,
>> Denis
>>
>>
>> 15.10.2013 18:37, nus1998 пишет:
>>
>>
>> I found a strange issue, when I read from serial, first I will call
>> "waitForReadyRead", it returns with true in specified time, however, when I
>> call "read" function thereafter, I can't read even a byte. the hardware
>> works fine since I checked it by logic analyzer.
>>
>> env: win7 64, qt 5.1 mingw version
>>
>> thanks
>> Je
>> ----
>> from iPad
>>
>>
>>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>>
>>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131016/5242e14d/attachment.html>


More information about the Interest mailing list