4 Replies Latest reply on Nov 17, 2015 9:59 AM by DiegoV_Intel

    System Calls c_str and other String related stuff in ARDUINO IDE

    crmakers

      I need to make a system call from ARUDINO sketch; that system call needs to be "crafted" by concatenating different values coming from sensors.

       

      I see the "simplest" solution would be to craft the system command string using an String object (as String object supports a number of concatenation mechanisms) and then porting it to char array using c_str() function.

       

      For instance...

       

      Here is some code I am trying to run...

       

      /*
        Blink
        Turns on an LED on for one second, then off for one second, repeatedly.
       
        This example code is in the public domain.
       */
       
      // Pin 13 has an LED connected on most Arduino boards.
      // give it a name:
      int led = 13;
      
      // the setup routine runs once when you press reset:
      void setup() {                
        // initialize the digital pin as an output.
        pinMode(led, OUTPUT);    
       Serial.begin(9600);
       Serial.println("TEST FOR STRING CONCATENATION"); 
      }
      
      // the loop routine runs over and over again forever:
      void loop() {
        String fakeCommand = "ping ";
        fakeCommand += "google.com";
        Serial.println(fakeCommand);
        //system(fakeCommand.c_str());
          Serial.println("What happened!!!???");
        digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
        delay(1000);               // wait for a second
        digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
        delay(1000);               // wait for a second
      }
      

       

      But it seems that Edison does not support such thing just now. At compile time it returns this:

       

      Blink.ino: In function 'void loop()':

      Blink.ino:25:23: error: 'class String' has no member named 'c_str'

       

      Any idea?