Saving serial information into an array

I am working on an RFID reader program and I am receiving this tag information at the serial monitor

+ 0.start look for tag:
--------------
command return: 32121E3002A0AA085150251190A538
--------------

How do I save it into an array ? This is the code I wrote but I got many errors in the information saved at the tag array.

 while(mySerial.available())
  {    
      Serial.print(mySerial.read(),HEX);
      delay(2);

     for (int i=0; i<=29; i++)
         {tag[i]=mySerial.read();
           Serial.print(tag[i],HEX);
           delay(2); }
  }

This is what is the tag array display.

command return: 32121E3002FFFFFFA0FFFFFFAA0FFFFFF851502511FFFFFF90FFFFFFA538FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Please advise

while(mySerial.available())
  {    
      Serial.print(mySerial.read(),HEX);
      delay(2);

     for (int i=0; i<=29; i++)
         {tag[i]=mySerial.read();

Check to see if you've got at least one character to read, then read all 30 of them.
No.

AWOL:

while(mySerial.available())

{   
      Serial.print(mySerial.read(),HEX);
      delay(2);

for (int i=0; i<=29; i++)
        {tag[i]=mySerial.read();



Check to see if you've got at least one character to read, then read all 30 of them.
No.

How do I do this in the code ?

See if there's a character to read, then read it.

See Robin2's serial handling basics thread.

I am not sure how to modify the Serial Input Basics Tutorial from Robin2,

this is what I have so far. Please advise

const byte numChars=30;
char receivedChars[numChars];
boolean newData=false;
static byte ndx=0;
char rc;


 while(mySerial.available() >0 && newData ==false)
  {    
      

      rc=mySerial.read();
      receivedChars[ndx]=rc;
      Serial.print(receivedChars[ndx]);
      ndx++;
      if(ndx>=numChars)
         {ndx=numChars-1;
         }



This is what is saved at the receivedChars



-------------
+ 0.start look for tag:
--------------
command return: 20

Your code doesn't compile because it is incomplete, so I can't test it.

AWOL:
Your code doesn't compile because it is incomplete, so I can't test it.

The code compile but it does not display the correct information.

you should, sometimes must, allow for the fact that your system might 'come alive' right in the middle of a data block transmission. so it's best to not process a block unless and until you have the right number of elements and the last or first datum received is provably the end or start of the block. if the data block does NOT have a specific start or end marker/character you can usually use time to determine the blocks. ASCII characters SOH .. EOT exist for good reason. I admit they don't get much use nowadays.

Delta_G:
No, the code you posted will not compile because it is not complete. You are missing loop and setup functions at the very least. Your while loop isn't in a function.

I did not post that part of the code because it's very long. I thought this is trivial.

I only posted the part where I need to save the serial data into the array.

Delta_G:
Don't copy the code from that thread. It probably won't work if you just copy it exactly. Instead, spend a few hours reading carefully through that thread until you understand the code in it. Then it will be trivial to do what you want.

If you really do what you should here then we shouldn't hear from you for a day or so. At least a few hours. If you come back from that thread in just a half an hour it makes it look like you're not trying very hard and that makes the help dry up.

The example you referred too is simple and it's different than the my problem. In the Robin example there is start and end characters.

Delta_G:
So you only posted part of the code. Now that severely limits those trying to help. They've either got to figure out what going on without any possibility to test or they have to write those sections and add to what you've given and what if they write something different from what you have?

If you have any any technical advices to solve the issue, you are most welcome to share. Otherwise, spare your lectures for yourself. Thanks.