PDA

View Full Version : Serial communication, waitForReadyRead() doesn't wait



Cruz
5th February 2009, 09:40
I have a device connected to my PC with a usb converted serial port (FTDI). I'm using qextserialport and altogether it works great. However, waitForReadyRead() doesn't wait for data to arrive, but returns immidiately with false. I'm using it like this:



void Serial::checkForData()
{
port = new QextSerialPort("COM3");
port->setBaudRate(BAUD115200);
port->setFlowControl(FLOW_OFF);
port->setParity(PAR_NONE);
port->setDataBits(DATA_8);
port->setStopBits(STOP_1);
port->open(QIODevice::ReadWrite);

sendSomething();

if (port->waitForReadyRead(1000))
{
// Device replied within 1 second
}
else
{
// Device didn't reply.
}
}


The waitForReadyRead call returns immidiately with false, without waiting for 1 second.
Any ideas?

^NyAw^
5th February 2009, 09:53
Hi,

Reading the QextSerialPort docs. Only using 1.2 Alpha version with MS Windows and configuring it as "event driven" you will be able to get it work as you expected.
Using older versions or using another OS like Linux you will probably need to use a timer to read the data every X ms, or wait X ms and then perform a "read" operation(if you are sure that you have data).

Cruz
5th February 2009, 10:03
Thanks mate. What documentation did you read? I saw only the doxygen stuff on the website and the function description didn't say anything like what you described.

^NyAw^
5th February 2009, 10:10
Hi,

I don't remember were I readed it but I know that there is this problem. I had developed an application one year ago that uses it and ther is no other way to make it works(at least for me).

Cruz
5th February 2009, 10:13
Bumping into you here just saved me several days of time. :)