if( QP->waitForFinished(100)) ???
-
I expect the if( QP->waitForFinished(100))
to process the code AFTER it is done stalling. 100 mS in this case
it instead goes to
elseAm I using it wrong ?
do { text = "Process loop "; qDebug() <<text; result = QP->readAllStandardOutput(); qDebug() << result; if( QP->waitForFinished(100)) { // done waiting if(QP->waitForReadyRead()) // QP->waitForFinished(5000) | QP->waitForReadyRead()) { text = "QProcess waitForReadyRead()"; qDebug() << text; result = QP->readAllStandardOutput(); } } else { // should never get here text = " PROCESS NOT FINISHED ?? QP->waitForFinished(100)"; qDebug() << text; } } while( time->elapsed() <500); text = "Elapsed time "; text += QString::number(time->elapsed()); qDebug() << text; ```* "verify list Discovery started" * "verify list SPP_CA" * DEBUG TRACE start new QProcess(); * "DEBUG TRACE start new QProcess();" * "QProcess running.." * "Process loop " * "" * " PROCESS NOT FINISHED ?? QP->waitForFinished(100)" * "Process loop " * "" * " PROCESS NOT FINISHED ?? QP->waitForFinished(100)" * "Process loop " * "Waiting to connect to bluetoothd...\r\u001B[0;94m[bluetooth]\u001B[0m# \r\r\u001B[0;94m[bluetooth]\u001B[0m# \r \rAgent registered\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:50:B6:80:4D:5D Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:15:83:15:A2:CB Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# " * " PROCESS NOT FINISHED ?? QP->waitForFinished(100)" * "Process loop " * "" * " PROCESS NOT FINISHED ?? QP->waitForFinished(100)" * "Process loop " * "" * " PROCESS NOT FINISHED ?? QP->waitForFinished(100)" * "Elapsed time 512" * "verify list Discovery started" * "verify list SPP_CA" * "DONE Process command...QString BT_Utility_Library::ProcessCommand(char *, QStringList)" * 07:50:17: /mnt/RAID_124/PROJECTS_MAR3_CONFIG/mdi/MDI crashed. -
I expect the if( QP->waitForFinished(100))
to process the code AFTER it is done stalling. 100 mS in this case
it instead goes to
elseAm I using it wrong ?
do { text = "Process loop "; qDebug() <<text; result = QP->readAllStandardOutput(); qDebug() << result; if( QP->waitForFinished(100)) { // done waiting if(QP->waitForReadyRead()) // QP->waitForFinished(5000) | QP->waitForReadyRead()) { text = "QProcess waitForReadyRead()"; qDebug() << text; result = QP->readAllStandardOutput(); } } else { // should never get here text = " PROCESS NOT FINISHED ?? QP->waitForFinished(100)"; qDebug() << text; } } while( time->elapsed() <500); text = "Elapsed time "; text += QString::number(time->elapsed()); qDebug() << text; ```* "verify list Discovery started" * "verify list SPP_CA" * DEBUG TRACE start new QProcess(); * "DEBUG TRACE start new QProcess();" * "QProcess running.." * "Process loop " * "" * " PROCESS NOT FINISHED ?? QP->waitForFinished(100)" * "Process loop " * "" * " PROCESS NOT FINISHED ?? QP->waitForFinished(100)" * "Process loop " * "Waiting to connect to bluetoothd...\r\u001B[0;94m[bluetooth]\u001B[0m# \r\r\u001B[0;94m[bluetooth]\u001B[0m# \r \rAgent registered\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:50:B6:80:4D:5D Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:15:83:15:A2:CB Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# " * " PROCESS NOT FINISHED ?? QP->waitForFinished(100)" * "Process loop " * "" * " PROCESS NOT FINISHED ?? QP->waitForFinished(100)" * "Process loop " * "" * " PROCESS NOT FINISHED ?? QP->waitForFinished(100)" * "Elapsed time 512" * "verify list Discovery started" * "verify list SPP_CA" * "DONE Process command...QString BT_Utility_Library::ProcessCommand(char *, QStringList)" * 07:50:17: /mnt/RAID_124/PROJECTS_MAR3_CONFIG/mdi/MDI crashed.@AnneRanch said in if( QP->waitForFinished(100)) ???:
I expect the if( QP->waitForFinished(100))
to process the code AFTER it is done stalling. 100 mS in this caseThe documentation is very clear about it:
Blocks until the process has finished and the finished() signal has been emitted, or until msecs milliseconds have passed.
-
@AnneRanch said in if( QP->waitForFinished(100)) ???:
I expect the if( QP->waitForFinished(100))
to process the code AFTER it is done stalling. 100 mS in this caseThe documentation is very clear about it:
Blocks until the process has finished and the finished() signal has been emitted, or until msecs milliseconds have passed.
@Christian-Ehrlicher Unfortunately one has to read more than one sentence.
On top of that I have made few logical errors.
Just in case it may be of real interest to some - here is the revised BASIC code .There are few issues running "bluetoothctl" command.
It responds with its own "wait" - hence it gives false waitForReadyRead.
But additional fake 100 mS delay seems to be OK .
Then readAllStandardOutput() can be used only ONCE after real
waiting for output is done....{ text = "Process single shot "; qDebug() <<text; if (QP->waitForReadyRead(500)) { // READY TO READ // make sure it is all QP->waitForFinished(100); fake delay result = QP->readAllStandardOutput(); qDebug() << result; if(result.isEmpty()) { text = "failed to get any data output "; qDebug() << text; } else analyze output here } else { text = "waitForReadyRead(500) timed out "; qDebug() << text; } text = "Elapsed time "; text += QString::number(time->elapsed()); qDebug() << text; QP->close(); } }