Reading values from string and split in commands

Im not sure what you mean by "thread-safe" version of strtok? Are there any differences?

Sure. The strtok function should not be used, without extreme caution, in a multi-threaded application, while the strtok_r function is safe to use in a multi-threaded application.

If you are not creating a multi-threaded application, you don't need to use the thread-safe version, although, on a PC, it doesn't really hurt. It results in more memory usage, and larger code, though. On the Arduino, it does hurt, since there is little memory available, and code space is limited, too.

Just thought it would be an good idea to clear the serial buffer after the uC got the data.

It's a little like reading to the end of a paragraph and throwing the rest of the book away. How will you ever find out whodunit?

Ok I have to do more reasearch about strings and an array of characters. Is there some good reference in the web?

There's about 42 bazillion references. Some of them are even good.

The difference between an array of characters and a string is that a string is an array of characters that is NULL terminated. It is that NULL terminator that tells string functions (ever wondered what the str in strtok meant?) where the end of the array is.

Im sending something like: "2;90"

If you are sending the data from a program, change what the program sends. If you make the program send "<2;90>" instead, this code can collect it all, as fast as it arrives:

#define SOP '<'
#define EOP '>'

bool started = false;
bool ended = false;

char inData[80];
byte index;

void setup()
{
   Serial.begin(57600);
   // Other stuff...
}

void loop()
{
  // Read all serial data available, as fast as possible
  while(Serial.available() > 0)
  {
    char inChar = Serial.read();
    if(inChar == SOP)
    {
       index = 0;
       inData[index] = '\0';
       started = true;
       ended = false;
    }
    else if(inChar == EOP)
    {
       ended = true;
       break;
    }
    else
    {
      if(index < 79)
      {
        inData[index] = inChar;
        index++;
        inData[index] = '\0';
      }
    }
  }

  // We are here either because all pending serial
  // data has been read OR because an end of
  // packet marker arrived. Which is it?
  if(started && ended)
  {
    // The end of packet marker arrived. Process the packet

    // Reset for the next packet
    started = false;
    ended = false;
    index = 0;
    inData[index] = '\0';
  }
}

Where the process the packet comment is is where you put the code to parse the string and convert the tokens to ints.