5 Replies Latest reply on Jul 30, 2015 3:29 PM by andreeap

    Compiling c file through Arduino sketch - Galileo gen 2

    andreeap

      Hello, all!

       

      I am facing an issue with compiling a c file through Arduino sketch. More specifically, this is my situation: I have a c file that grabs pictures via a USB webcam, I moved the c file on the board and compiled it using this command:

       

      gcc picture_grab.c -lv4l2 -o picture_grab

       

      I run " ./picture_grab -W 325 -H 288 -c 5 Encode RGB24 " and the code does what it's supposed to, it takes some pictures via the webcam.

      What I am trying to do is to create an Arduino sketch that would launch the terminal commands for compiling and executing the code.

       

      I tried a simple sketch :

       

      void setup() {

       

        Serial.begin(9600);

        system("date > /home/root/date2.txt");

        system("gcc /home/root/picture_grab.c -lv4l2 -o /home/root/picture_grab");

        system("./home/root/picture_grab -W 325 -H 288 -c 5 Encode RGB24");

      }

       

      void loop() {

      }

       

      The "date > /home/root/date.txt" command is getting executed, I can see the new file on the Galileo. However, the other two commands are not being executed, there are no new pictures grabbed through the webcam.

       

      Do you know what I might be doing wrong here? What should I know about executing object files through system calls? Is it not possible?

       

      Thank you very much in advance.

        • 1. Re: Compiling c file through Arduino sketch - Galileo gen 2
          PabloM_Intel

          Hi andreeap,

           

          After you upload the sketch in the Arduino IDE, are you able to see the processes using the “ps” command? Are those the exact commands you are using to run your code in Linux side?

           

          Also, have you tried adding a delay between the system calls in the Arduino aketch?

           

          Regards,

          PabloM_Intel

          • 2. Re: Compiling c file through Arduino sketch - Galileo gen 2
            andreeap

            Hello, PabloM_Intel !

            Do you have any other suggestions? What else could I check?

            • 3. Re: Compiling c file through Arduino sketch - Galileo gen 2
              PabloM_Intel

              Hi andreeap,

               

              I apologize for the late reply.

              Regarding your issue, how much time did you add to the delay? Did you try something similar to this?

              void setup() {
                   Serial.begin(9600);
                   system("date > /home/root/date2.txt");
                   system("gcc /home/root/picture_grab.c -lv4l2 -o /home/root/picture_grab");
                   delay (10000);       // In 10 seconds the compilation should be completed.
                   system("./home/root/picture_grab -W 325 -H 288 -c 5 Encode RGB24");
              }
              
              void loop() {
              }
              

               

              I believe the problem is that the last system call is being run before the .c file is done compiling.                                                                                                                                                               

              Regards,

              PabloM_Intel

              • 4. Re: Compiling c file through Arduino sketch - Galileo gen 2
                CMata_Intel

                Hi andreeap,

                 

                Did you try with a longer delay? Do you have updates in this?

                 

                Regards,

                Charlie

                • 5. Re: Compiling c file through Arduino sketch - Galileo gen 2
                  andreeap

                  Hello, all!

                   

                  My answer comes very late, but I thought maybe I should end this thread.

                   

                  As this was part of my bachelor thesis, I was kinda on a tight schedule so I had to find a solution fast. Unfortunately, the solution was to use another board

                   

                  I tried adding a delay as you suggested, first a reasonable one, then a more ridiculous one and it still did not work. And even if I had the already compiled file on the board and would just call the

                   

                  system("./home/root/picture_grab -W 325 -H 288 -c 5 Encode RGB24");

                   

                  command, it still would not work. No idea what was happening and I guess I will never find out, I had to return the board a few days ago.

                   

                  Thank you for trying to help and I'm sorry my problem did not bring anything constructive to the community wish I was able to fix it...

                   

                  Have a nice day everybody!