Need help with a split function

Hey guys,

I'm all confused on how to do that on the Yun. Right now I have this post : http://forum.arduino.cc/index.php/topic,41215.0.html but I can't figure out how to client.read to a char so I can use the function.

The string my Yun receive is something like that : C/L/25/100 or it could be F/F/100/25 you get the idea

Thank you for the help

May Stream.readStringUntil() help? Stream.readStringUntil() - Arduino Reference

Yeah I was looking into that but I was wondering if I get a string with multiple terminator char what does it do ?

Ex: My received string is "C/L/120"

I would do something like command = client.readStringUntil('/'); what command is going to have inside only C or it's going to give me and array of everything?

Thank you.

I'm not completely sure of it (can't test it ATM) but it should return C, you call it again and it returns L

Oh ok, that would work then. I’ll give it a try maybe tonight. If ever you test it before I did let me know.

Thank you Frederico.

Still haven't tested it, but the source code confirms it

Ok I'm no expert here and far from there but I tried something like

command[0] = client.readStringUntil('/'):
command[1] = client.readStringUntil('/'):

and the output comes out like

Command[0]: C
Command[1]: C

and I tried sending C/L

Thank you for the help

For anyone who is interested I figured out how to do it. Here is my test code

#include <Bridge.h>
#include <Console.h>
#include <YunServer.h>
#include <YunClient.h>

// The pin that the LED is attached to
const int ledPin = 13;

// We open the socket 5678 to communicate.
YunServer server(5555);

void setup() {
  Serial.begin(9600);

  // Attach the LED to pin 13 as output
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);

  // Bridge startup
  Bridge.begin();

  server.noListenOnLocalhost();
  server.begin();
}

void loop() {
  YunClient client = server.accept();

  // There is a new client
  if (client) {
    client.setTimeout(5);

    String command = "none";

    digitalWrite(ledPin, LOW);
    
    String test[2];

    while (!command.equals("stop")) {
      if (client.available() > 0) {
        command = client.readStringUntil('/');
        

        Serial.println("Reading Command :" + command);
        if (command != "") {
          // trim off any whitespace:
          command.trim();
          test[0] = command.substring(0);
          // convert to an int and map to the screen height:
          Serial.println("Command 1: " + test[0]);
        }
        command = client.readStringUntil('/');
        if (command != "") {
          // trim off any whitespace:
          command.trim();
          test[1] = command.substring(0);
          // convert to an int and map to the screen height:
          Serial.println("Command 2: " + test[1]);
        }
      }
    }
  }
}

Have fun