Hi to everyone.

I'm currently using the QextSerialPort v1.1 and I've got a problem when trying to use the waitForReadyRead (like in QTcpSocket and other IODevices...). My application currently uses three threads (GUI, socket and serial port) and in fact I want to use the waitForReadyRead method because my thread uses a loop approach (not being a GUI thread...)

I'm giving the method a 5s timeout (value 5000 as argument) and what actually happens when I call the method is that it won't wait until the timeout (if not data has been received yet) but it returns immediately returning me a -1 value which means that an error occurred...

If I use a counter decremented until 0 and call bytesAvailable() I'm able to read everything correctly but the counter, which is a polling approach, wastes me time...

Did someone of you had problems with this waitForReadyRead method in QextSerialPort?


By the way my code looks like the following:

Qt Code:
  1. ...
  2. quint32 count = 800000;
  3.  
  4. serial_port->write(&cdata, 1);
  5.  
  6. //qDebug() << "Wait: " << serial_port->waitForReadyRead(5000);
  7.  
  8. while(count--);
  9.  
  10. qDebug() << "bytes available: " << serial_port->bytesAvailable();
  11.  
  12. serial_port->read(&cdata, 1);
  13. ...
To copy to clipboard, switch view to plain text mode 


The following is the non-working version using waitForReadyRead()
Qt Code:
  1. ...
  2.  
  3. serial_port->write(&cdata, 1);
  4.  
  5. if(!serial_port->waitForReadyRead(5000)){
  6.  
  7. qDebug() << "Error";
  8.  
  9. }else{
  10.  
  11. qDebug() << "bytes available: " << serial_port->bytesAvailable();
  12.  
  13. serial_port->read(&cdata, 1);
  14.  
  15. }
  16. ...
To copy to clipboard, switch view to plain text mode 


It would be great if someone could be able to help me.

Cheers.