Help in Read string [SMS string]

Hello Everyone,

I am trying to read sms, but when i send the command(AT+CMGR=1) from hyper terminal that time

+CMGR: “REC READ”,"+918128660422","",“14/06/17,16:36:43+22”

Test sms

But When i tried by the function i only get

+CMGR: “REC READ”,"+918128660422","",“14/06/17,16:36:43+22”

I don’t know why my function skip all values…

char buffer[128]; 
byte buffer2[128];
uint16_t count=0;     
void setup()
{
  pinMode(13,OUTPUT);
  Serial.begin(9600);                
  Serial1.begin(9600);             
  delay(500);
  Sim900_Inti();
}
 
void loop()
{
  if (Serial.available())
  {
    switch(Serial.read())
    {
      case 's' :
      Cmd_Read_Act();
      break;
    }
    Serial.write(buffer2,count);
    /*Serial.write(buffer2,128);
    Serial.write(buffer2,128);
    Serial.write(buffer2,128);*/
    //clearBufferArray();
    count = 0;         
  }
}
void clearBufferArray()
{
  for (int i=0; i<128;i++)
    { buffer[i]=0;} 
}
void Sim900_Inti()
{
  Serial1.println("ATE0");
  delay(500); 
  Serial1.println("AT+CMGF=1");
  delay(500);
  Serial1.println("AT+CNMI=2,1");
  delay(500);
  Serial.print("GSM Init");
}
void Cmd_Read_Act()
{ 
  Serial1.println("AT+CMGR=1");
  /*Serial1.print(char(34));
  Serial1.print("ALL");
  Serial1.println(char(34));*/
  if (Serial1.available()> 0)
  {
    while(Serial1.available()>0) 
    {
      buffer[count]=Serial1.read(); 
      buffer2[count] = buffer[count];
      char temp = buffer2[count];
      
      count = count+1;
      if (temp == 'K')
      {
        Serial.println("0K Recived");
        break;
      }
     }
  }
}

Anyone has idea then tell me why this is happening
Thanks in advance

Are you using the Serial instance to talk to the PC or to talk to the phone? Both is the wrong answer. So is yes.

What hardware are you using? Which Arduino?

In this rare instance ignore what PaulS has written, you are writing to the different serial ports correctly on the assumption you are using a Mega.

Having had a play you are filling up your buffer with the responses from the AT commands issued in Sim900_Inti(). Don't forget non visible characters. Then it appends what it can from your message which is what you see.

@Pauls :- Thanks for reply, I am using MEGA Serial0 which i am using to connect with hyper-terminal(to PC).

Serial1 is connected with GSM modem (Sim900).

What i am trying :- when i send "S" on serial0 via hyper-terminal then, serial1 has to read the sms which i alredy store in sim. what is going there :- when i send read the serial1 then it we ll skip the values.

@dannable :- Arduino MEGA, SIM 900 as modem