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. Why does it takes soo long...?
Forum Updated to NodeBB v4.3 + New Features

Why does it takes soo long...?

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 1.1k Views 3 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 Chris Kawa
    #1

    *I am including my code.

    My objective is to start a new process and execute "system call".
    Such call takes no noticeable time when executed in "terminal".

    It QT it takes ESTIMATED time of about 20 -30 seconds. ( I have no implemented the timer) to finish the "new process".

    WHY?

    I also do not get why it runs the "waiting for..." twice, but that is NOT my main concern for now.

    
            // run QProcess first time
            time->start();
            QP = new QProcess();
            qDebug() << "DEBUG TRACE start new QProcess();";
            text = "DEBUG TRACE start new QProcess();";
            //TRACE_TextEdit->addItem(text);
            qDebug() << text;
            text = " command ";
            text += command;
            // add file
            text += " | tee /tmp/temp";
            qDebug() << text;
    
            QP->start("/bin/sh", QStringList() << "-c" << command);
            if(QP->Running)
            {
                text = "QProcess running..";
                qDebug() << text;
            }
    //#ifdef BYPASS
            if(QP->waitForFinished())
            {
                text = "QProcess finished";
                qDebug() << text;
            };
            time->elapsed();
    //#endif
    
            text = "read stadard error ";
            qDebug() << text;
            text = "read stadard output ";
            qDebug() << text;
    
            text = QP->readAllStandardOutput();
    
            qDebug() << text;
            return text;
    

    Debug output

    "setup Bluetooth virtual serial port \n void MainWindow_Bluetooth::on_actionBluetooith_virtiual_port_triggered()"
    "Process command...QString BT_Utility_Library::ProcessCommand(char *)"
    DEBUG TRACE start new QProcess();
    "DEBUG TRACE start new QProcess();"
    " command bluetoothctl | tee /tmp/temp"
    "QProcess running.."
    "read stadard error "
    "read stadard output "
    "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 command...QString BT_Utility_Library::ProcessCommand(char *)"
    DEBUG TRACE start new QProcess();
    "DEBUG TRACE start new QProcess();"
    " command bluetoothctl | tee /tmp/temp"
    "QProcess running.."
    "read stadard error "
    "read stadard output "
    "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# "
    "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# "
    "Failed Controller"
    "Agent registered"
    09:39:59: /mnt/RAID_124/PROJECTS_FEB26_LIB/mdi/MDI exited with code 0

    Pl45m4P 1 Reply Last reply
    0
    • A Anonymous_Banned275

      *I am including my code.

      My objective is to start a new process and execute "system call".
      Such call takes no noticeable time when executed in "terminal".

      It QT it takes ESTIMATED time of about 20 -30 seconds. ( I have no implemented the timer) to finish the "new process".

      WHY?

      I also do not get why it runs the "waiting for..." twice, but that is NOT my main concern for now.

      
              // run QProcess first time
              time->start();
              QP = new QProcess();
              qDebug() << "DEBUG TRACE start new QProcess();";
              text = "DEBUG TRACE start new QProcess();";
              //TRACE_TextEdit->addItem(text);
              qDebug() << text;
              text = " command ";
              text += command;
              // add file
              text += " | tee /tmp/temp";
              qDebug() << text;
      
              QP->start("/bin/sh", QStringList() << "-c" << command);
              if(QP->Running)
              {
                  text = "QProcess running..";
                  qDebug() << text;
              }
      //#ifdef BYPASS
              if(QP->waitForFinished())
              {
                  text = "QProcess finished";
                  qDebug() << text;
              };
              time->elapsed();
      //#endif
      
              text = "read stadard error ";
              qDebug() << text;
              text = "read stadard output ";
              qDebug() << text;
      
              text = QP->readAllStandardOutput();
      
              qDebug() << text;
              return text;
      

      Debug output

      "setup Bluetooth virtual serial port \n void MainWindow_Bluetooth::on_actionBluetooith_virtiual_port_triggered()"
      "Process command...QString BT_Utility_Library::ProcessCommand(char *)"
      DEBUG TRACE start new QProcess();
      "DEBUG TRACE start new QProcess();"
      " command bluetoothctl | tee /tmp/temp"
      "QProcess running.."
      "read stadard error "
      "read stadard output "
      "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 command...QString BT_Utility_Library::ProcessCommand(char *)"
      DEBUG TRACE start new QProcess();
      "DEBUG TRACE start new QProcess();"
      " command bluetoothctl | tee /tmp/temp"
      "QProcess running.."
      "read stadard error "
      "read stadard output "
      "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# "
      "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# "
      "Failed Controller"
      "Agent registered"
      09:39:59: /mnt/RAID_124/PROJECTS_FEB26_LIB/mdi/MDI exited with code 0

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @AnneRanch said in Why does it takes soo long...?:

      text = " command ";
      text += command;
      // add file
      text += " | tee /tmp/temp";
      qDebug() << text;
      QP->start("/bin/sh", QStringList() << "-c" << command);

      What's the reason to actually write "command" to command line?
      Don't you just want to call bluetoothctl and pipe it with tee /tmp/temp?

      Edit:
      Does it make any difference, if you don't explicitly use command bluetoothctl?


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      A 1 Reply Last reply
      0
      • Pl45m4P Pl45m4

        @AnneRanch said in Why does it takes soo long...?:

        text = " command ";
        text += command;
        // add file
        text += " | tee /tmp/temp";
        qDebug() << text;
        QP->start("/bin/sh", QStringList() << "-c" << command);

        What's the reason to actually write "command" to command line?
        Don't you just want to call bluetoothctl and pipe it with tee /tmp/temp?

        Edit:
        Does it make any difference, if you don't explicitly use command bluetoothctl?

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

        @Pl45m4 I have removed the stupid mistake of adding ":command" text, removed the redirection to temp file and it still takes forever and rums twice.

        I never see "fished" ....

        Here is the full debug op0utput

        11:50:29: Starting /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI...
        Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
        "void MainWindow::menu_slot_indexed(int)"
        "add it as subwindow "
        "setup Bluetooth virtual serial port \n void MainWindow_Bluetooth::on_actionBluetooith_virtiual_port_triggered()"
        "Process command...QString BT_Utility_Library::ProcessCommand(char *)"
        DEBUG TRACE start new QProcess();
        "DEBUG TRACE start new QProcess();"
        "QProcess running.."
        
        why is it running this  BEFORE "finished" ??
        
        
        "read stadard error "
        "read stadard output "
        "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 command...QString BT_Utility_Library::ProcessCommand(char *)"
        DEBUG TRACE start new QProcess();
        "DEBUG TRACE start new QProcess();"
        "QProcess running.."
        "read stadard error "
        "read stadard output "
        "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# "
        "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# "
        "Failed Controller"
        "Agent registered"
        11:51:57: /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI exited with code 0
        
        
        Pl45m4P 1 Reply Last reply
        0
        • A Anonymous_Banned275

          @Pl45m4 I have removed the stupid mistake of adding ":command" text, removed the redirection to temp file and it still takes forever and rums twice.

          I never see "fished" ....

          Here is the full debug op0utput

          11:50:29: Starting /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI...
          Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
          "void MainWindow::menu_slot_indexed(int)"
          "add it as subwindow "
          "setup Bluetooth virtual serial port \n void MainWindow_Bluetooth::on_actionBluetooith_virtiual_port_triggered()"
          "Process command...QString BT_Utility_Library::ProcessCommand(char *)"
          DEBUG TRACE start new QProcess();
          "DEBUG TRACE start new QProcess();"
          "QProcess running.."
          
          why is it running this  BEFORE "finished" ??
          
          
          "read stadard error "
          "read stadard output "
          "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 command...QString BT_Utility_Library::ProcessCommand(char *)"
          DEBUG TRACE start new QProcess();
          "DEBUG TRACE start new QProcess();"
          "QProcess running.."
          "read stadard error "
          "read stadard output "
          "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# "
          "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# "
          "Failed Controller"
          "Agent registered"
          11:51:57: /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI exited with code 0
          
          
          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #4

          @AnneRanch said in Why does it takes soo long...?:

          I have removed the stupid mistake of adding ":command" text

          command is an actual CL command, but I dont think it's needed here to call bluetoothctl.

          • https://askubuntu.com/questions/512770/what-is-the-bash-command-command

          "Failed Controller"

          Note this error, which comes from bluetoothctl output.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          A 1 Reply Last reply
          0
          • Pl45m4P Pl45m4

            @AnneRanch said in Why does it takes soo long...?:

            I have removed the stupid mistake of adding ":command" text

            command is an actual CL command, but I dont think it's needed here to call bluetoothctl.

            • https://askubuntu.com/questions/512770/what-is-the-bash-command-command

            "Failed Controller"

            Note this error, which comes from bluetoothctl output.

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

            @Pl45m4 Partially solved. Had two instances of QProcess...
            Will add real time timer to see the actual processing time. Still feels sluggish.

            A 1 Reply Last reply
            1
            • A Anonymous_Banned275

              @Pl45m4 Partially solved. Had two instances of QProcess...
              Will add real time timer to see the actual processing time. Still feels sluggish.

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

              @AnneRanch Here is the latest - after fixing few "yser errors" it is still back to the original - why it takes 30 seconds to finish ??

              It look s as the QProcess ":finished" is not really monitoring the "finished " but it runs some standard fixed timeout

              12:18:01: Starting /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI...
              Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
              "void MainWindow::menu_slot_indexed(int)"
              "add it as subwindow "
              "setup Bluetooth virtual serial port \n void MainWindow_Bluetooth::on_actionBluetooith_virtiual_port_triggered()"
              "Process command...QString BT_Utility_Library::ProcessCommand(char *)"
              DEBUG TRACE start new QProcess();
              "DEBUG TRACE start new QProcess();"
              "QProcess running.."
              
              **"QProcess elapsed time 30035"**
              
              "read stadard error "
              "read stadard output "
              "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# "
              "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# "
              "result OK"
              "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# "
              "Controller"
              "Agent registered"
              12:18:54: /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI exited with code 0
              
              
              A 1 Reply Last reply
              0
              • A Anonymous_Banned275

                @AnneRanch Here is the latest - after fixing few "yser errors" it is still back to the original - why it takes 30 seconds to finish ??

                It look s as the QProcess ":finished" is not really monitoring the "finished " but it runs some standard fixed timeout

                12:18:01: Starting /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI...
                Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
                "void MainWindow::menu_slot_indexed(int)"
                "add it as subwindow "
                "setup Bluetooth virtual serial port \n void MainWindow_Bluetooth::on_actionBluetooith_virtiual_port_triggered()"
                "Process command...QString BT_Utility_Library::ProcessCommand(char *)"
                DEBUG TRACE start new QProcess();
                "DEBUG TRACE start new QProcess();"
                "QProcess running.."
                
                **"QProcess elapsed time 30035"**
                
                "read stadard error "
                "read stadard output "
                "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# "
                "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# "
                "result OK"
                "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# "
                "Controller"
                "Agent registered"
                12:18:54: /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI exited with code 0
                
                
                A Offline
                A Offline
                Anonymous_Banned275
                wrote on last edited by
                #7

                @AnneRanch SOLVED ??

                I just realized I have been here before....
                Here is the problem
                "finished" does NOT monitor the QProcess for "end of story, done" it just waits until preset timeout... ( 30 s default )

                waitForReadyRead() actu8ally monitors the QProcess BUT

                bluetoothctl FIRST line response is

                "Waiting to connect to bluetoothd..."

                and
                waitForReadyRead() detect that line as " QProcess is done ..."

                DEBUG TRACE start new QProcess();
                "DEBUG TRACE start new QProcess();"
                "QProcess running.."
                "QProcess finished"
                "QProcess elapsed time 24"
                "read stadard error "
                "read stadard output "
                "Waiting to connect to bluetoothd..."
                "Waiting to connect to bluetoothd..."
                "result OK"
                "Waiting to connect to bluetoothd..."
                "Failed Controller"
                "Failed Agent registered"
                12:49:17: /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI exited with code 0

                S 1 Reply Last reply
                0
                • A Anonymous_Banned275

                  @AnneRanch SOLVED ??

                  I just realized I have been here before....
                  Here is the problem
                  "finished" does NOT monitor the QProcess for "end of story, done" it just waits until preset timeout... ( 30 s default )

                  waitForReadyRead() actu8ally monitors the QProcess BUT

                  bluetoothctl FIRST line response is

                  "Waiting to connect to bluetoothd..."

                  and
                  waitForReadyRead() detect that line as " QProcess is done ..."

                  DEBUG TRACE start new QProcess();
                  "DEBUG TRACE start new QProcess();"
                  "QProcess running.."
                  "QProcess finished"
                  "QProcess elapsed time 24"
                  "read stadard error "
                  "read stadard output "
                  "Waiting to connect to bluetoothd..."
                  "Waiting to connect to bluetoothd..."
                  "result OK"
                  "Waiting to connect to bluetoothd..."
                  "Failed Controller"
                  "Failed Agent registered"
                  12:49:17: /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI exited with code 0

                  S Offline
                  S Offline
                  SimonSchroeder
                  wrote on last edited by
                  #8

                  @AnneRanch IIRC finished() is a signal that is emitted when the process is actually finished. However, waitForFinished() has a default parameter for 3 seconds. So, after 3 seconds it will just stop waiting. This is most likely now what you want.

                  JonBJ A 2 Replies Last reply
                  0
                  • S SimonSchroeder

                    @AnneRanch IIRC finished() is a signal that is emitted when the process is actually finished. However, waitForFinished() has a default parameter for 3 seconds. So, after 3 seconds it will just stop waiting. This is most likely now what you want.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #9

                    @SimonSchroeder said in Why does it takes soo long...?:

                    has a default parameter for 3 seconds

                    The default is 30000 ms == 30 seconds.

                    1 Reply Last reply
                    0
                    • S SimonSchroeder

                      @AnneRanch IIRC finished() is a signal that is emitted when the process is actually finished. However, waitForFinished() has a default parameter for 3 seconds. So, after 3 seconds it will just stop waiting. This is most likely now what you want.

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

                      @SimonSchroeder OK, let's define "process is finished" .
                      In my case the process task is to execute system command.
                      The command response is a raw text output - control characters and ASCII .

                      How does process detects that the command output is done / fished?

                      ( how does QProcess detects ANY "task is finished " ?)

                      In my opinion - it cannot .

                      So I ended with this - pseudo code

                      do
                      wait for "finshed"
                      check for "ReadyRead"

                      did the read text contain desired data
                      in selected time interval ?

                      while
                      no, go back to "do"

                      or if selected time interval expired without data
                      exit

                      JonBJ 1 Reply Last reply
                      0
                      • A Anonymous_Banned275

                        @SimonSchroeder OK, let's define "process is finished" .
                        In my case the process task is to execute system command.
                        The command response is a raw text output - control characters and ASCII .

                        How does process detects that the command output is done / fished?

                        ( how does QProcess detects ANY "task is finished " ?)

                        In my opinion - it cannot .

                        So I ended with this - pseudo code

                        do
                        wait for "finshed"
                        check for "ReadyRead"

                        did the read text contain desired data
                        in selected time interval ?

                        while
                        no, go back to "do"

                        or if selected time interval expired without data
                        exit

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by JonB
                        #11

                        @AnneRanch said in Why does it takes soo long...?:

                        How does process detects that the command output is done / fished?
                        ( how does QProcess detects ANY "task is finished " ?)
                        In my opinion - it cannot .

                        QProcess detects when the process exits, which the OS reports to it. It is not determined by any output the process might or might not produce.

                        While the process is still running the parent does not get/emit the finished signal and it may see output from the subprocess depending on how the sub-process output code is written.

                        When the process does finish any remaining output can be read.

                        A 1 Reply Last reply
                        2
                        • JonBJ JonB

                          @AnneRanch said in Why does it takes soo long...?:

                          How does process detects that the command output is done / fished?
                          ( how does QProcess detects ANY "task is finished " ?)
                          In my opinion - it cannot .

                          QProcess detects when the process exits, which the OS reports to it. It is not determined by any output the process might or might not produce.

                          While the process is still running the parent does not get/emit the finished signal and it may see output from the subprocess depending on how the sub-process output code is written.

                          When the process does finish any remaining output can be read.

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

                          @JonB So when I actually time my process by monitoring the actual data detected I get something around 500 ms. However , when I set the "finished" back to default ( 30 s) - the QProcess runs full 30 s .

                          I can probably set the "finished" to an hours and it will wait that long...

                          It tells me that OS , as you claim, does not generate anything to the QProcess to tell it (OS) is finished.

                          Your claim and my practical example just do not agree...

                          JonBJ A 2 Replies Last reply
                          0
                          • A Anonymous_Banned275

                            @JonB So when I actually time my process by monitoring the actual data detected I get something around 500 ms. However , when I set the "finished" back to default ( 30 s) - the QProcess runs full 30 s .

                            I can probably set the "finished" to an hours and it will wait that long...

                            It tells me that OS , as you claim, does not generate anything to the QProcess to tell it (OS) is finished.

                            Your claim and my practical example just do not agree...

                            JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on last edited by JonB
                            #13

                            @AnneRanch
                            Mine isn't a claim, it's how it works. You can also check the Qt source code.

                            If waitForFinished() takes 30 seconds that tells you the subprocess has not exited. So obviously if you have connected the finished signal you will never get that.

                            You can verify whether the subprocess you have spawned is still running (while your Qt app is still running) via a suitable ps.

                            If what you spawn is an "interactive" program which waits for the user to type something it will not finish/exit. If your command is bluetoothctl does that not sit and wait for the user to type into it?

                            1 Reply Last reply
                            2
                            • A Anonymous_Banned275

                              @JonB So when I actually time my process by monitoring the actual data detected I get something around 500 ms. However , when I set the "finished" back to default ( 30 s) - the QProcess runs full 30 s .

                              I can probably set the "finished" to an hours and it will wait that long...

                              It tells me that OS , as you claim, does not generate anything to the QProcess to tell it (OS) is finished.

                              Your claim and my practical example just do not agree...

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

                              @AnneRanch Disregard r my last post... I just recall I have been thru this before and the real "problem" is - the "command" DOES not finishes - it is still running the "script" hence there is nothing to tell OS it is done .
                              END OF STORY

                              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