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.
  • J J.Hilk
    17 Apr 2019, 18:33

    @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 17 Apr 2019, 18:41 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 17 Apr 2019, 18:49 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
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 17 Apr 2019, 18:51 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 17 Apr 2019, 18:57
        0
        • S SGaist
          17 Apr 2019, 18:51

          Hi,

          Where is that executable located on your machine ?

          Y Offline
          Y Offline
          Yash001
          wrote on 17 Apr 2019, 18:57 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
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 17 Apr 2019, 20:20 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 17 Apr 2019, 21:13
            3
            • S SGaist
              17 Apr 2019, 20:20

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

              Y Offline
              Y Offline
              Yash001
              wrote on 17 Apr 2019, 21:13 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
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 17 Apr 2019, 21:26 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 17 Apr 2019, 21:57
                2
                • S SGaist
                  17 Apr 2019, 21:26

                  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 17 Apr 2019, 21:57 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);.

                  J 1 Reply Last reply 17 Apr 2019, 22:33
                  0
                  • Y Yash001
                    17 Apr 2019, 21:57

                    @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);.

                    J Offline
                    J Offline
                    JonB
                    wrote on 17 Apr 2019, 22:33 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 17 Apr 2019, 23:00
                    4
                    • J JonB
                      17 Apr 2019, 22:33

                      @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 17 Apr 2019, 23:00 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

                      19/19

                      17 Apr 2019, 23:00

                      • Login

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