Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. if( QP->waitForFinished(100)) ???
Forum Updated to NodeBB v4.3 + New Features

if( QP->waitForFinished(100)) ???

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 248 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    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
    else

    Am 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.
    Christian EhrlicherC 1 Reply Last reply
    0
    • A Anonymous_Banned275

      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
      else

      Am 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.
      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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 case

      The 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.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      A 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @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 case

        The 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.

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3

        @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();
                }
            }
        
        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved