while (Uart.available() > 0) { incomingByte = (Uart.read()); reply = reply + char(incomingByte); } This expects all the data to have arrived by the time that the function is called. There is no guarantee that this will happen.

There is some end-of-message marker that signifies that the complete message has been received. You need to wait, in the send_command function, until that end character is received.

If you don't know what they mean, how do you know that they are useless? What if one of the numbers indicated the message length? Wouldn't that be useful information?

No because, the project is:Some codes to see the serial connection with the phone, another command to change the memory to read (AT+CPMS="ME"), after I read the first message. If the message have the word "Ligar" but in PDU format (in PDU format the message content is the end of the line), the code turn a port HIGH. Else, do nothing.If the message have the word "Desligar" but in PDU format, the code turn this same port, LOW.

because, I said this answer were useless for me. The line of the message is always with the same end for the messages I want to parse.

AT +CMGR - http://www.developershome.com/sms/cmgrCommand.asp - The AT command +CMGR (command name in text: Read Message) is used to read a message from a message storage area. The location of the message to be read from the message storage area is specified by an index number. The message to be retrieved by the AT command +CMGR does not necessarily have to be an SMS message. It can be of other message types such as status reports and cell broadcast messages

AT +CPMS - http://www.developershome.com/sms/cpmsCommand.asp -The AT command +CPMS (command name in text: Preferred Message Storage) serves several purposes. It can be used to:

1. Select the message storage area that will be used when sending, receiving, reading, writing or deleting SMS messages.

2. Find the number of messages that are currently stored in the message storage area.

3. Find the maximum number of messages that can be stored in the message storage area.

AT +CMGR - http://www.developershome.com/sms/cmgrCommand.asp - The AT command +CMGR (command name in text: Read Message) is used to read a message from a message storage area. The location of the message to be read from the message storage area is specified by an index number. The message to be retrieved by the AT command +CMGR does not necessarily have to be an SMS message. It can be of other message types such as status reports and cell broadcast messages

AT +CPMS - http://www.developershome.com/sms/cpmsCommand.asp -The AT command +CPMS (command name in text: Preferred Message Storage) serves several purposes. It can be used to:

1. Select the message storage area that will be used when sending, receiving, reading, writing or deleting SMS messages.

2. Find the number of messages that are currently stored in the message storage area.

3. Find the maximum number of messages that can be stored in the message storage area.