Break out the data and read certain bytes of it, How?

Hi there.

i have on Serial port data with 17bytes long... it 17 bytes long constantly.... But i need to get last 4 of those 17 in do some work on it.... They are always difrent each time you read...
Like i understand it has to be assighned by arrays. But i can't get it how it happans at all.

This is some one else code it doesn't work for me but explains a lot of im trying to work on..

inChar=Serial1.read();
rxData[rxIndex]='\0';

Seems like it is assignment but it so stuped way and don't get it how thought it's assighns..

Again the inChar contains the answer from device which is 17 characters long always
but 4 of those alwaus difrent each time you read and those 4 needs to be a variables for some more code...

So how i breake the Serial read basicly in bytes and assign them by numbers???

char rxData[20];
char rxIndex=0;



void getResponse(void){
  char inChar=0;
  //Keep reading characters until we get a carriage return
  while(inChar != '\r'){
    //If a character comes in on the serial port, we need to act on it.
    if(Serial1.available() > 0){
      //Start by checking if we've received the end of message character ('\r').
      if(Serial1.peek() == '\r'){
        //Clear the Serial buffer
        inChar=Serial1.read();
        //Put the end of string character on our data string
        rxData[rxIndex]='\0';
        //Reset the buffer index so that the next character goes back at the beginning of the string.
        rxIndex=0;
      }
      //If we didn't get the end of message character, just add the new character to the string.
      else{
        //Get the new character from the Serial port.
        inChar = Serial1.read();
        //Add the new character to the string, and increment the index variable.
        rxData[rxIndex++]=inChar;
      }
    }
  }
}

This is some one else code it doesn't work for me but explains a lot of im trying to work on..

inChar=Serial1.read();
rxData[rxIndex]='\0';

You need to actually store the value you read in the array before you NULL terminate the array:

  inChar=Serial1.read();
                        rxData[rxIndex++] = inChar;
        rxData[rxIndex]='\0';

You should give some serious thought to using Tools + Auto Format, too.

Once you have the data in the array, you can pick put the characters/bytes of interest.

ok looks like i got some charaters on on serila print... But it's kinda of mess now it's not geting the right ones and puts so much spases betwen the charaters:

for examle if i want to print them then i use this function right?

Serial.print(rxData[13]);
Serial.print(rxData[14]);
Serial.print(rxData[15]);
Serial.print(rxData[16]);
Serial.print(rxData[17]);

char rxData[20]; this guy how much it has to be?

for examle if i want to print them then i use this function right?

That's one way. Since it's a NULL terminated array of chars, you can print the whole array:

Serial.print(rxData;

char rxData[20]; this guy how much it has to be?

Enough to hold all the data. If the packet is 17 bytes, 18 elements should be enough.