4 Replies Latest reply on Dec 25, 2014 3:39 AM by AlphaCHarly

    ARDUINO IDE distinction between GALILEO and EDISON

    AlphaCHarly

      Folks,

      Do you know in your Arduino code how to distinguish between the code for the Galileo and the code for the Edison ???

      Something like:

      #ifdef __AVR__

      ...

      #else

      ...

      #endif

       

      that we do to distinguish the different boards of Arduino UNO, ...

       

      Thanks in advance.

       

      AC/.

        • 1. Re: ARDUINO IDE distinction between GALILEO and EDISON
          DiegoV_Intel

          Hi AlphaCHarly,

           

          I have defined a tag in the Arduino.h file like this:

          #define __X86__
          

           

          and then I used that tag in the libraries like this:

          #if defined(__AVR__) || defined(__X86__)
          ...
          #elif defined(CORE_TEENSY) // Teensy boards
          ...
          #else 
          ...
          #endif
          

           

          You have to add the define tag in the Arduino.h file for the Galileo and for the Edison (they use different Arduino.h files). So you could use for the Edison something like:

          #define __EDISON__
          

           

          and for Galileo something like:

          #define __GALILEO__
          

           

          However I haven't tested them. I have tested only the #define __X86__ tag, but they should work in the same way.

           

          I hope you find it useful. If you are able to test it, please share your results with the Community.

           

          Regards,

          Diego.

          • 2. Re: ARDUINO IDE distinction between GALILEO and EDISON
            AlphaCHarly

            Gracias Diego.

            I was expecting something built by the compiler, however I will try your suggestion for the time being.

            I was exploring the define PLATFORM_NAME that I found on the variants file, but did not find the Edison one.

            I will report my progress.

            Cheers and Feliz Navidad.

            AC/.

            • 3. Re: ARDUINO IDE distinction between GALILEO and EDISON
              KurtE

              For what it is worth, currently in my sketches to detect Edison (may also be set for Galileo), I have code like:

              #ifndef __ARDUINO_X86__

               

              I believe the IDE is supposed to generate some defines depending on the architecture and variant... Would need to google to see the exact thing that this is supposed to be...

               

              Could also search for something different in headers...

              1 of 1 people found this helpful
              • 4. Re: ARDUINO IDE distinction between GALILEO and EDISON
                AlphaCHarly

                Folks,

                In a deeper research I found that the PLATFORM_NAME or PLATFORM_ID can be used, it is set to other "Galileo" or "Edison" by the compiler thru the variants.h include file, it is also very nice to print the debug information you can use it as:   Serial.print(PLATFORM_NAME);

                It is very handy to handle the differences between both libraries sets, like the function gettimeofday() is available on the Edison version, but not on the Galileo version, etc, ...

                Thanks for your suggestions.

                AC/.