Help me for serial data processing.

Hello

These are my attempts :slight_smile: At least half works!
It works, but only when first receive data.

Sample for serial test:
0,0.02,-0.01,9.82,2.0,0,1500,1500,1500,1000,1000,2000,0,0, 1000,1000,1000,1000,0,0,0,0,11.3,0,
char inData[140];
byte index;

float datas[24] = {0};
char * val;
int count = 0;

boolean received = false;

void setup(){
  Serial.begin(115200);
}

void loop(){

  while(Serial.available() > 0){	                
    char inChar = Serial.read();
    if(index < 140){
      inData[index] = inChar;
      index++;
      inData[index] = '\0';
    }    
    received = true;    		          
  }

if(received){
  val = strtok (inData,",");		
  datas[count] = atof(val);
		
  while ((val = strtok (NULL, ",")) != NULL){
    datas[++count] = atof(val);
  }
  
  for(int b=0; b<=23; b++){
    Serial.print(b);
    Serial.print(":");
    Serial.println(datas[b],2);
  }  
    
  received = false;
  }    
}