DUE: Reading Serial data into two dimensional array, it skips every other index.

As the title says I have a two dimensional array that I am attempting to read data into.
byte serialData[6][6]

If you look at the code below the idea is that I'm trying to take this

123456B789012C345678D012345E555555F666666

data and parse it. What I am doing appears to work great,
I use the SPACE char at the beginning to start the parse and then the B-F char to split the 6 bytes of data. Each time I get a new alpha char I am incrementing the first index of the array and then taking the data chars into the 2nd index.

When I print the values of serialData[i] I get the below results
[0]   = 111111
[0][1][2][3][4][5]
[1] = NULL
[0][1][2][3][4][5]
[2] = 222222
[0][1][2][3][4][5]
[3] = NULL
[0][1][2][3][4][5]
[4] = 333333
[0][1][2][3][4][5]
[5] = NULL
[0][1][2][3][4][5]

If I print even farther than I am even defining in the array...

serialData[6] = 444444
serialData[7] = NULL
serialData[8] = 555555

What the heck am I doing wrong? Why is it incrementing twice?!?

Thank you!

// State machine values
int state =0;

byte serialData[6][6] = {0};

//serial data
byte serialChar =0;
boolean newData =0;
byte i2 = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Serial 1 Good Morning");
  Serial1.begin(115200);
  Serial1.println("Serial 2 Good Morning");
}

void loop() {
  
          if (Serial1.available() > 42) {
            newData = true;
            Serial.write("***** BEGIN DATA state = ");
            if (state == 0){
              for(i=0;i<43;i++)
              {
                serialChar = Serial1.read();
                if (serialChar == 32){
                  state = 1;
                  serialProcess(state); 
                  break;
                }
              } 
                       
            }            
          }


          delay(250);
  
  if (newData){
    Serial.write("{t1:");
    Serial.print(serialData[0]);
    
    Serial.write(",t2:");
    Serial.print(serialData[1]);
    
    Serial.write(",t3:");
    Serial.print(serialData[2]);
    
    Serial.write(",lat:");
    Serial.print(serialData[3]);
    
    Serial.write(",lon:");
    Serial.print(serialData[4]);
  
    Serial.write(",rpm:");
    Serial.print(serialData[5]);
  
    Serial.write("}");
    Serial.println("");
    
    newData =false;
  }

}
          
void serialProcess(int st){
      Serial.println("");
      Serial.print("State of: ");
      Serial.println(state);
      for (byte i=0; i<7; i++) {
                serialChar = Serial1.read();

                
                if ((serialChar > 65) && (serialChar < 71)){
                  if (serialChar == 66){state = 2;}
                  if (serialChar == 67){state = 3;}
                  if (serialChar == 68){state = 4;}
                  if (serialChar == 69){state = 5;}
                  if (serialChar == 70){state = 6;}
                  serialProcess(state);
                  i2=0;
                  break;
                }
                else if ((serialChar != 32) && (serialChar !=255))
                {
					Serial.print("Echoing State before print state: ");					
					Serial.println(state);
					Serial.print("Char: ");
					Serial.write(serialChar);
                    Serial.print("");
                    serialData[(state-1)][i2] = serialChar;
                    i2++;
                }
                else if (serialChar == 13){
                  i2=0;
                  state=0;
                  Serial.println("");
                  Serial.println("***END OF DATA***");
                  break;
                }
      }
      
}

Moderator edit: [code] ... [/code] tags added to debug output. (Nick Gammon)

  if (Serial1.available() > 42) {
    newData = true;
    Serial.write("***** BEGIN DATA state = ");
    if (state == 0){
      for(i=0;i<43;i++)
      {
        serialChar = Serial1.read();
        if (serialChar == 32){
          state = 1;
          serialProcess(state); 
          break;
        }
      } 

    }

If you have more than 42 bytes of serial data you are reading it 43 times.

void serialProcess(int st){
  Serial.println("");
  Serial.print("State of: ");
  Serial.println(state);
  for (byte i=0; i<7; i++) {
    serialChar = Serial1.read();

Then you are reading another 7.


      if (serialChar == 66){

What's with all the numbers? Why not:

      if (serialChar == 'B'){

Maybe read this:

        if (serialChar == 32){

Make that:

        if (serialChar == ' '){

Readable code is nice.

Dang, I knew there was a way to get the code to interpret the data for you. I will use the ' ' for sure.

With regard to the looping 42 times, I have a break when it detects my "start" char, basically a way to ensure that I am starting at a known point, I realize now though that since I am reading through the data with different letters to index, I can really start anywhere one of those chars exist. Thanks for the pointer there.

    if (state == 0){
      for(i=0;i<43;i++)
      {
        serialChar = Serial1.read();
        if (serialChar == 32){
          state = 1;
          serialProcess(state); 
          break;

Anyway, I am still having the problem here

                else if ((serialChar != 32) && (serialChar !=255))
                {
					Serial.print("Echoing State before print state: ");					
					Serial.println(state);
					Serial.print("Char: ");
					Serial.write(serialChar);
                    Serial.print("");
                    serialData[(state-1)][i2] = serialChar;
                    i2++;
                }

This line
serialData[(state-1)][i2] = serialChar;
Is supposed to put the currently read char at the [state-1][increment] of the char array, but for some reason [state] is doing weird things and data is only getting stored in the 0,2,4 arrays of the the first dimension.
When I do

Serial.print("Echoing State before print state: ");	
Serial.println(state);

I get matching states with the data they belong to.

With respect, your code is very confusing.

I suggest you read the linked page (http://www.gammon.com.au/serial) and see simpler ways of parsing incoming serial data.

No offense taken. Reading it now, I will try to make it more understandable before resubmitting.

    Serial.print(serialData[0]);

does not seem to be very close to a compilable statement...