2 Replies Latest reply on Jul 6, 2015 12:07 AM by Ashish9433

    How to Run Sketches from Linux Terminal

    Ashish9433

      Hi,

       

      I have been using Arduino IDE to run sketches on Intel Galileo board, Now i have connected it via LAN and i wish to perform those task via Linux Terminal. Can any one guide me how can i do it?

       

      Examples like blinking LED is working on Arduino IDE via sketches, I wish to do this via Linux Terminal.

       

      Is there a way by which i can invoke/run sketches from Linux Terminal or via C/python code i can achieve this?

        • 1. Re: How to Run Sketches from Linux Terminal
          DiegoV_Intel

          Hi Ashish9433,

           

          The sketches you upload through the Arduino IDE are stored in the Edison and they start running each time the Edison boots, so there is no need to run them manually from the terminal.

           

          On the other hand, you can write scripts directly in the terminal using the Vi text editor. This way allows you to write Python or C/C++ scripts. For example to create a Python script you should do the following:

           

          1. Create the script: You have to create a .py file, which is the Python script. You can write it using the Vi text editor. The Vi text editor can be opened with the following command:

           

          vi <script_name.py>

           

          You will enter into the Vi environment so you can start writing your script. I recommend you to check the following site to get more details about the Vi text editor: A Beginner’s Guide to Editing Text Files With Vi

           

          2. Run the script: Once you have your script ready, you can run it with the following command:

           

          python <script_name.py>

           

           

          That is what you have to do to create and run Python scripts. In case of C/C++ the process is a little different. As you may know, Python is an interpreter so you can run Python scripts using the way I described above; however in C/C++ you have to compile the script before you can run it. For C/C++ scripts you have to do the following:

           

          1. Create the script: Just like in the previous description, you can use Vi to write the .c or .cpp file.

          2. Compile the script: Once the .c (.cpp) file is ready you have to compile it. In order to compile a C/C++ script you can use the following command for each case:

           

          • For C scripts: gcc <script_name.c> -o script_name
          • For C++ scripts: g++ <script_name.cpp> -o script_name

           

          3. Run the program: Once the script is compiled you can run the program with the following command:

           

          ./script_name

           

          I hope this information has answered your question. Additionally, I recommend you to check the following site to find some Python examples for Edison: MakersTeam/Edison · GitHub. You might find them helpful to start creating your own scripts.

           

          Regards,

          Diego.

          • 2. Re: How to Run Sketches from Linux Terminal
            Ashish9433

            Thanks a lot @DiegoV_Intel,  You gave me description more than i had expected.

             

            I really appreciate your effort!!