G'Day,
I have the following code ( which works ) but during run time can potentially crash. It uses the qextserialport library.
Code:
recflag = true; rec = serialPort->bytesAvailable(); while ( recflag ) { serialPort->read( retdata, 60 ); if ( retdata[39] == 0x4F && retdata[40] == 0x04B ) { sendwin->label_2->setText("Switch "+swnum+" succeeded" ); recflag = false; } else { errorlist << "\nswitch "+swnum+" failed"; sendwin->label_2->setText( "Switch "+swnum+" FAILED" ); errorflag = true; recflag = false; } }
If no data is seen on the serial port, the app just sits there until something comes in or I crash the app. My question is how can I implement a timer of, say 500ms, to break the loop. I have tried using a timer but they don't seem to trigger the slot.
Any suggestions would be greatly appreciated.
Thank, B1.