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. macOs Qprocess, calling a unix exec
Forum Updated to NodeBB v4.3 + New Features

macOs Qprocess, calling a unix exec

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 5 Posters 1.6k Views 2 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.
  • M MatthewFelton

    Hello, im a super noob learning Qt and i thought id jump into making a nice little gui for an application that runs in the terminal/command prompt called avrdude. everythings going great so far i first made a console application that calls avrdude via QProcess. it works great on both mac and windows. now i have added a gui and the code itself is almost identical but for some reason it doesnt work.

        QString exePath {};
        QString comPort{};
        QString config {};
    
        if (os == "macOs")
        {
            comPort = "/dev/"+ connectedPort;
            exePath = "avrdude/mac/avrdude";
            config = "-Cavrdude/mac/avrdude.conf";
        }
        if (os == "windows")
        {
            comPort = connectedPort;
            exePath = "avrdude/win/avrdude";
            config = "-Cavrdude/win/avrdude.conf";
        }
    
        QStringList args =(QStringList()
                            << config
                            << "-v"
                            << "-patmega32u4"
                            << "-cavr109"
                            << "-P"
                            << comPort
                            << "-b57600"
                            << "-D"
                            << updateString
                            );
    
    
    
        QProcess pro;
        pro.waitForStarted();
        pro.start(exePath,args);
        pro.waitForFinished();
    

    This code runs as a console app perfectly on mac and windows. It also runs perfectly on windows as a Gui application but on mac it doesn't work as a Gui application. it simply runs the command, doesn't do anything then finishes. i tried catching errors with QProcess. unknown error. programme doesnt crash , it completes, it just doesnt open the terminal and run the args. Maybe i have to open the terminal directly first and then run the args. i notice on window running the avrdude.exe opens the command prompt whereas on mac it doesnt know what to do with the unix exec file avrdude.

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

    @MatthewFelton said in macOs Qprocess, calling a unix exec:

    i notice on window running the avrdude.exe opens the command prompt whereas on mac it doesnt know what to do with the unix exec file avrdude

    One more thing besides the Qt / thread stuff:
    Does the stuff you are passing to QProcess work at all when putting it in a Mac Terminal?
    You've mentioned that Mac doesn't seem to find (or being able to run) the avrdude executable?!


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

    ~E. W. Dijkstra

    JonBJ Pl45m4P 2 Replies Last reply
    0
    • Pl45m4P Pl45m4

      @MatthewFelton said in macOs Qprocess, calling a unix exec:

      i notice on window running the avrdude.exe opens the command prompt whereas on mac it doesnt know what to do with the unix exec file avrdude

      One more thing besides the Qt / thread stuff:
      Does the stuff you are passing to QProcess work at all when putting it in a Mac Terminal?
      You've mentioned that Mac doesn't seem to find (or being able to run) the avrdude executable?!

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

      @Pl45m4

      @MatthewFelton said in macOs Qprocess, calling a unix exec:

      i first made a console application that calls avrdude via QProcess. it works great on both mac and windows. now i have added a gui and the code itself is almost identical but for some reason it doesnt work.

      ?

      1 Reply Last reply
      0
      • Pl45m4P Pl45m4

        @MatthewFelton said in macOs Qprocess, calling a unix exec:

        i notice on window running the avrdude.exe opens the command prompt whereas on mac it doesnt know what to do with the unix exec file avrdude

        One more thing besides the Qt / thread stuff:
        Does the stuff you are passing to QProcess work at all when putting it in a Mac Terminal?
        You've mentioned that Mac doesn't seem to find (or being able to run) the avrdude executable?!

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

        @MatthewFelton said in macOs Qprocess, calling a unix exec:

        i notice on window running the avrdude.exe opens the command prompt whereas on mac it doesnt know what to do with the unix exec file avrdude

        @JonB

        !

        :)

        No idea whether the command works at all now or not. @MatthewFelton should verify that first before digging deeper into QProcess and why it does or doesn't work.


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

        ~E. W. Dijkstra

        1 Reply Last reply
        1
        • JonBJ JonB

          @MatthewFelton said in macOs Qprocess, calling a unix exec:

          I do infact have this class running in a worker thread

          This may or may not have anything to do with your Mac problem, but why do you have any threads, especially if you are beginner? Large numbers of beginners put threads in when there is no need, and threads are a major source of complexity/bugs. If you try your code from the main/single UI thread does it make any difference to the bad behaviour?

          M Offline
          M Offline
          MatthewFelton
          wrote on last edited by MatthewFelton
          #10

          @JonB The code is a little more complicated than the snippet I showed you. I'm using a worker thread because I have a while loop looking for the Arduino and it was stopping my Gui from drawing when the arduino was unplugged. its all good. I have an interface class talking between the threaded class and my QML Gui and everything working great. apart from the QProcess issue on mac. so just to re-iterate.

          I created a console application first. Its works for both mac and windows. I then created a GuiApplication and utilized the console app code. On windows the GuiApplication works as expected but on mac the GuiApplication does not. Its like it doesnt call the exepath... or does call the expath but doesnt input the arguments. I have tested the same code in the terminal and it also works. And as previously stated the exact same code is also currently working on mac for the console application.

          SGaistS 1 Reply Last reply
          0
          • M MatthewFelton

            @JonB The code is a little more complicated than the snippet I showed you. I'm using a worker thread because I have a while loop looking for the Arduino and it was stopping my Gui from drawing when the arduino was unplugged. its all good. I have an interface class talking between the threaded class and my QML Gui and everything working great. apart from the QProcess issue on mac. so just to re-iterate.

            I created a console application first. Its works for both mac and windows. I then created a GuiApplication and utilized the console app code. On windows the GuiApplication works as expected but on mac the GuiApplication does not. Its like it doesnt call the exepath... or does call the expath but doesnt input the arguments. I have tested the same code in the terminal and it also works. And as previously stated the exact same code is also currently working on mac for the console application.

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #11

            Hi,

            How do you move the helper executable to the right on macOS ?

            On macOS you do not have a single executable file for a GUI application like you have for a CLI application. A bundle is created by default.

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

            M 1 Reply Last reply
            0
            • SGaistS SGaist

              Hi,

              How do you move the helper executable to the right on macOS ?

              On macOS you do not have a single executable file for a GUI application like you have for a CLI application. A bundle is created by default.

              M Offline
              M Offline
              MatthewFelton
              wrote on last edited by
              #12

              @SGaist it's a Unix executable. Not a bundle. It's designed to be used in the terminal

              SGaistS 1 Reply Last reply
              0
              • M MatthewFelton

                @SGaist it's a Unix executable. Not a bundle. It's designed to be used in the terminal

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #13

                I am talking about your application not the helper.

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

                M 1 Reply Last reply
                0
                • SGaistS SGaist

                  I am talking about your application not the helper.

                  M Offline
                  M Offline
                  MatthewFelton
                  wrote on last edited by
                  #14

                  @SGaist as a complete beginner I don't actually know what that means sorry.

                  SGaistS 1 Reply Last reply
                  0
                  • M MatthewFelton

                    @SGaist as a complete beginner I don't actually know what that means sorry.

                    SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #15

                    Check the macOS deployment chapter in Qt's documentation. It's nicely explained.

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

                    M 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Check the macOS deployment chapter in Qt's documentation. It's nicely explained.

                      M Offline
                      M Offline
                      MatthewFelton
                      wrote on last edited by
                      #16

                      @SGaist ok .. but I'm not deploying yet. I'm still building.

                      SGaistS 1 Reply Last reply
                      0
                      • M MatthewFelton

                        @SGaist ok .. but I'm not deploying yet. I'm still building.

                        SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #17

                        That is clear. However, the build still generates a bundle as described there. Hence my question about where your helper application is stored with regard to where the application executable can actually be found which should be in the generated bundle.

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

                        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