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 QProcess is not working in MAC os?
QtWS25 Last Chance

why QProcess is not working in MAC os?

Scheduled Pinned Locked Moved Solved General and Desktop
macrosqt 5.11.0bundleqprocess
19 Posts 6 Posters 5.3k Views
  • 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.
  • Y Yash001

    @mrjj @raven-worx

    It is returning QProcess::FailedToStart.

    raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on last edited by raven-worx
    #6

    @Yash001 said in why QProcess is not working in MAC os?:

    It is returning QProcess::FailedToStart.

    well, you already know that ;)
    I said errorString(), for the sake of a more readable error message

    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
    If you have a question please use the forum so others can benefit from the solution in the future

    Y 1 Reply Last reply
    1
    • raven-worxR raven-worx

      @Yash001 said in why QProcess is not working in MAC os?:

      It is returning QProcess::FailedToStart.

      well, you already know that ;)
      I said errorString(), for the sake of a more readable error message

      Y Offline
      Y Offline
      Yash001
      wrote on last edited by
      #7

      @raven-worx

      Qprocess::errorString() is return "execvp: No such file or directory".

      1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        @Yash001 is teensy_loader_cli it’s own appbundle, or did you extract the executable out of it?

        if it‘s an app bundle than your path is wrong.
        From my experience QProcess doesn‘t execute the bundle, you have to go into the contents

        e.g
        teensy_loader_cli.app/Contents/MacOS/teensy_loader_cli

        Y Offline
        Y Offline
        Yash001
        wrote on last edited by Yash001
        #8

        @J.Hilk
        It is executable file. it is not bundle. I am not able to do cd teensy_loader_cli.app/Contents/MacOS

        J.HilkJ 1 Reply Last reply
        0
        • Y Yash001

          @J.Hilk
          It is executable file. it is not bundle. I am not able to do cd teensy_loader_cli.app/Contents/MacOS

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #9

          @Yash001 in that case I would suggest opening a QDir instance, on using the entryList function to check if your file is actually there, and if you're actually where you think you are on the file system ;-)


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          Y 1 Reply Last reply
          1
          • J.HilkJ J.Hilk

            @Yash001 in that case I would suggest opening a QDir instance, on using the entryList function to check if your file is actually there, and if you're actually where you think you are on the file system ;-)

            Y Offline
            Y Offline
            Yash001
            wrote on last edited by Yash001
            #10

            @J.Hilk As per my understanding you are talking about to verify the hexfileFile. Is it there or not. Right?

            In my case I am selecting the hexFileName file manually from GUI.

            // on click of HexFile button 
            	m_connections << QObject::connect(hexFilePbt, &QPushButton::clicked, [=]() {
            
            		// open the file path which is strore into the SQUID_STAT_PARAMETERS_INI file
            		QSettings settings(SQUID_STAT_PARAMETERS_INI, QSettings::IniFormat);
            		QString dirName = settings.value(FW_HEX_OPEN_PATH, "").toString();
            
            		QString filePath = QFileDialog::getOpenFileName(frame, "Select firmware file", dirName, "Intel HEX (*.hex)");
            
            		if (filePath.isEmpty()) {
            			return;
            		}
            
            		settings.setValue(FW_HEX_OPEN_PATH, QFileInfo(filePath).absolutePath());
            		hexFileLed->setText(filePath);
            	});
            
            1 Reply Last reply
            0
            • Y Offline
              Y Offline
              Yash001
              wrote on last edited by
              #11

              Is it any way to determine the what is input string to terminal while using QProcess.

              When I manually load firmware at that time my input is
              ./teensy_loader_cli -mmcu=mk20dx256 -wv "/Users/Computer/Desktop/Frimware/3.Squidstat prime firmware Mar 06 2019 (copy) with autoreset.hex"

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #12

                Hi,

                Where is that executable located on your machine ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                Y 1 Reply Last reply
                0
                • SGaistS SGaist

                  Hi,

                  Where is that executable located on your machine ?

                  Y Offline
                  Y Offline
                  Yash001
                  wrote on last edited by Yash001
                  #13

                  @SGaist
                  I am compiling full code in Qt and after that I am adding all dependency of SquidStat.app with help of shell script.

                  In shell script, I copy my teensy_loader_cli executable file from machine location to SquidStat.app/Contents/MacOS/.

                  If I will call SquidStat.app from the Qt run button at that time it is work. But I will go at output dir, and click on SquidStat.app. It is open SquidStat.app software but Updating firmware functionality is not working.

                  In general, executable file is located at location SquidStat.app/Contents/MacOS/

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #14

                    Then you should use QCoreApplication::applicationDirPath to build the path to that executable.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    Y 1 Reply Last reply
                    3
                    • SGaistS SGaist

                      Then you should use QCoreApplication::applicationDirPath to build the path to that executable.

                      Y Offline
                      Y Offline
                      Yash001
                      wrote on last edited by
                      #15

                      Thank you @SGaist for guidance. application is not able to find the correct location of teensy_loader_cli.

                      Now, I am able get correct functionality with help QCoreApplication::applicationDirPath()

                      Here modify code, and It is work.

                      void UpdateFirmware::UpdateHardware(const QString hexFileName) {
                      	QProcess process;
                      	process.setReadChannel(QProcess::StandardOutput);
                      	process.setReadChannelMode(QProcess::MergedChannels);
                      	QStringList arguments;
                      	arguments << "-mmcu=mk20dx256" << "-wv" << hexFileName;
                      	auto program = QCoreApplication::applicationDirPath() +"/"+QString("teensy_loader_cli");
                              process.start(program, arguments);
                      	process.waitForStarted(1000);
                      	process.waitForFinished();
                      }
                      

                      I have one last question if I will add QThread thread; process.moveToThread(&thread) then Process will be start on separate thread. Right?

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #16

                        If you want UpdateHardware to not block your GUI, then you should rather take advantage of QProcess's asynchronous nature rather than involving threads.

                        What exactly do you want to achieve ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        Y 1 Reply Last reply
                        2
                        • SGaistS SGaist

                          If you want UpdateHardware to not block your GUI, then you should rather take advantage of QProcess's asynchronous nature rather than involving threads.

                          What exactly do you want to achieve ?

                          Y Offline
                          Y Offline
                          Yash001
                          wrote on last edited by Yash001
                          #17

                          @SGaist

                          I am trying to update the firmware in hardware with help of teensy_loader_cli. teensy_loader_cli loader need reset signal before updating firmware.

                          case 1:
                          If hardware received reset signal from software before QProcess is start then QProcess will not block (teensy_loader_cli will not block the process). It is execute.

                          case 2:
                          If hardware received reset signal from software after QProcess is start then QProcess will block (teensy_loader_cli will block the process) until reset signal is received from software.

                          Reset signal is always call before process is start, But Signal is not received immediately in hardware (code is little messy, I will make it clean)
                          0_1555537882072_91b9191e-7d68-47dc-83c5-90f9486b930b-image.png

                          In both case User will not access the other functionality of Software. For blocking functionality I am using one dialog boxauto dialog = new QDialog(parent, Qt::SplashScreen). which is give update regrading firmware. Once firmware update is done after that User will get the OK button on dialog box. By click on OK button dialog box will be close and User will get all other access.

                          So I am thinking about to start QProcess on separate thread and give update to GUI regrading firmware update through signals like emit BootloaderStarted(); emit BootloaderFound();emit BootloaderSetProgress(100);emit BootloaderFinished(true);.

                          JonBJ 1 Reply Last reply
                          0
                          • Y Yash001

                            @SGaist

                            I am trying to update the firmware in hardware with help of teensy_loader_cli. teensy_loader_cli loader need reset signal before updating firmware.

                            case 1:
                            If hardware received reset signal from software before QProcess is start then QProcess will not block (teensy_loader_cli will not block the process). It is execute.

                            case 2:
                            If hardware received reset signal from software after QProcess is start then QProcess will block (teensy_loader_cli will block the process) until reset signal is received from software.

                            Reset signal is always call before process is start, But Signal is not received immediately in hardware (code is little messy, I will make it clean)
                            0_1555537882072_91b9191e-7d68-47dc-83c5-90f9486b930b-image.png

                            In both case User will not access the other functionality of Software. For blocking functionality I am using one dialog boxauto dialog = new QDialog(parent, Qt::SplashScreen). which is give update regrading firmware. Once firmware update is done after that User will get the OK button on dialog box. By click on OK button dialog box will be close and User will get all other access.

                            So I am thinking about to start QProcess on separate thread and give update to GUI regrading firmware update through signals like emit BootloaderStarted(); emit BootloaderFound();emit BootloaderSetProgress(100);emit BootloaderFinished(true);.

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

                            @Yash001
                            You should not need to run a QProcess in a separate thread. Instead, do not call waitForStarted()/waitForFinished() as you show, rather use the QProcess::finished etc. signals. That is what @SGaist was indicating when he said:

                            take advantage of QProcess's asynchronous nature rather than involving threads

                            Y 1 Reply Last reply
                            4
                            • JonBJ JonB

                              @Yash001
                              You should not need to run a QProcess in a separate thread. Instead, do not call waitForStarted()/waitForFinished() as you show, rather use the QProcess::finished etc. signals. That is what @SGaist was indicating when he said:

                              take advantage of QProcess's asynchronous nature rather than involving threads

                              Y Offline
                              Y Offline
                              Yash001
                              wrote on last edited by Yash001
                              #19

                              @JonB Thank you for correct direction. I will modify my code and use it finished Signal for updating dialog box.

                              1 Reply Last reply
                              1

                              • Login

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