Guest User

Untitled

a guest
Mar 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. void IOThread::run(){
  2.  
  3. QSerialPort serial;
  4. serial.setPortName(portname)
  5. serial.setBaudRage(QSerialPort::Baud115200);
  6. serial.setStopBits(QSerialPort::OneStop)
  7. serial.setParity(QSerialPort::NoParity);
  8. serial.setDataBits(QSerialPort::Data8);
  9. serial.setFlowControl(QSerialPort::NoFlowControl);
  10.  
  11. if(!serial.open(QIODevice::ReadWrite)
  12. {
  13. qDebug() << "Error Opening Port";
  14. return;
  15. }
  16.  
  17. while(true)
  18. {
  19. if(serial.waitForReadyRead(1000))
  20. {
  21. qDebug() << "Normal read";
  22. reception_buffer = serial.readAll();
  23. }
  24. else
  25. {
  26. qDebug() << "Timeout";
  27. //serial.readAll() here will read huge chunk of data
  28. continue;
  29. }
  30. }
  31.  
  32. // Process data...
  33. }
  34.  
  35. if(serial.waitForReadyRead(-1))
Add Comment
Please, Sign In to add comment