Hi!
i'm trying to communicate some device that have been programmed myself to PC. Just a simple one to test QtSerialPort. In terminal example on QtSerialPort's help its work fine.
Here is the reading result :
308
307
309
308
.
.
.

But when i write my code using synchronous approach, the reading is terrible. Here is the code :
Qt Code:
  1. #include <QtCore/QCoreApplication>
  2. #include <QtDebug>
  3. #include <QtAddOnSerialPort/serialport.h>
  4.  
  5. QT_USE_NAMESPACE_SERIALPORT
  6.  
  7. void setup();
  8. SerialPort serial;
  9.  
  10. int main(int argc, char *argv[])
  11. {
  12. serial.setPort("COM20");
  13. serial.open(QIODevice::ReadOnly | QIODevice::Unbuffered);
  14. setup();
  15.  
  16. QCoreApplication a(argc, argv);
  17.  
  18. //here is the problem
  19. while (serial.waitForReadyRead(100)) {
  20. qDebug() << serial.read(8);
  21. }
  22.  
  23. return a.exec();
  24. }
  25.  
  26. void setup()
  27. {
  28. serial.setRate(SerialPort::Rate9600);
  29. // serial.setBaudRate(AbstractSerial::BaudRate9600);
  30. serial.setDataBits(SerialPort::Data8);
  31. serial.setParity(SerialPort::NoParity);
  32. serial.setStopBits(SerialPort::OneStop);
  33. serial.setFlowControl(SerialPort::NoFlowControl);
  34. }
To copy to clipboard, switch view to plain text mode 

and the result :
"308"
"307"
"308"
"3"
"0"
"9"
"
"
"3"
"0"
"7"
"
"3"
"0"
"9"
.
.

Well previusly i using QSerialDevice for Serial Communication its work fine with simple reading like that. Until i use it for multithreading, it mostly crash all over time. Then i use QtSerialPort for multithreading its work fine until i found the reading is bad. Is there a way to solve that problem?