Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void IOThread::run(){
- QSerialPort serial;
- serial.setPortName(portname)
- serial.setBaudRage(QSerialPort::Baud115200);
- serial.setStopBits(QSerialPort::OneStop)
- serial.setParity(QSerialPort::NoParity);
- serial.setDataBits(QSerialPort::Data8);
- serial.setFlowControl(QSerialPort::NoFlowControl);
- if(!serial.open(QIODevice::ReadWrite)
- {
- qDebug() << "Error Opening Port";
- return;
- }
- while(true)
- {
- if(serial.waitForReadyRead(1000))
- {
- qDebug() << "Normal read";
- reception_buffer = serial.readAll();
- }
- else
- {
- qDebug() << "Timeout";
- //serial.readAll() here will read huge chunk of data
- continue;
- }
- }
- // Process data...
- }
- if(serial.waitForReadyRead(-1))
Add Comment
Please, Sign In to add comment