GPRS shield returns HTTP & TCP garbage

Hi friends,
I cannot figure this one out. I've got the Uno and v1.4 of the Seeed Studio GPRS shield.

I've put together 2 different examples, one with TCP and the other HTTP... no success. I get garbage data like this: Serctpn3c-;8P T>eeru>d2eedh

AT+CIPSTART="TCP","google.com","80"
CONNECT OK

AT+CIPSEND=20
>GET / HTTP/1.1
Host: google.com
Connection: close



SEND OK

HTTP/1.1 400 Bad Request
Date: Sat, 10 Aug 2013 16:23:01 GMT
Serctpn3c-;8P T<lue>>eeru>d2eedh
CLOSED

AT+CIPCLOSE
ERROR

AT+CIPSHUT
SHUT OK

Don't mind that it says "400 Bad Request" this is just an example. My main problem is that I dont receive the entire payload because of this gibberish:
"Serctpn3c-;8P T>eeru>d2eedh"

My HTTP one does similar things. Is this a hardware issue?

My code is below:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8);

int8_t answer;
int onModulePin= 2;
char aux_str[50];

char ip_data[]="GET / HTTP/1.1\r\nHost: google.com\r\nConnection: close\r\n\r\n";

void setup(){

  mySerial.begin(19200);  // SOFTWARE COM   
  Serial.begin(19200);    // HUMAN COM
  delay(500);
  
    pinMode(onModulePin, OUTPUT);
    mySerial.begin(19200);    
    
    Serial.println("Starting...");
    power_on();
    
    delay(3000);
    
    Serial.println("Connecting to the network...");

    while( sendATcommand2("AT+CREG?", "+CREG: 0,1", "+CREG: 0,5", 1000)== 0 ){
      
    }

}

void loop()
{
 
  if (Serial.available())
    switch(Serial.read())
    {
      case 'h':
        SubmitHttpRequest();
        break;
      case 'i':
        // Closes the socket
        sendATcommand2("AT+CIPCLOSE", "CLOSE OK", "ERROR", 10000);
        sendATcommand2("AT+CIPSHUT", "OK", "ERROR", 10000);
        delay(10000);
        break;
    } 
    if (mySerial.available()) {
      Serial.write(mySerial.read());
    }
    
    
}

void SubmitHttpRequest() {
    
 
    // Selects Single-connection mode
    if (sendATcommand2("AT+CIPMUX=0", "OK", "ERROR", 1000) == 1)
    {
        // Waits for status IP INITIAL
        while(sendATcommand2("AT+CIPSTATUS", "INITIAL", "", 500)  == 0 );
        delay(5000);
        
        // Sets the APN, user name and password
        if (sendATcommand2("AT+CSTT=\"fast.tmobile.com\",\"user_name\",\"password\"", "OK",  "ERROR", 30000) == 1)
        {            
            // Waits for status IP START
            while(sendATcommand2("AT+CIPSTATUS", "START", "", 500)  == 0 );
            delay(5000);
            
            // Brings Up Wireless Connection
            if (sendATcommand2("AT+CIICR", "OK", "ERROR", 30000) == 1)
            {
                // Waits for status IP GPRSACT
                while(sendATcommand2("AT+CIPSTATUS", "GPRSACT", "", 500)  == 0 );
                delay(5000);
                
                // Gets Local IP Address
                if (sendATcommand2("AT+CIFSR", ".", "ERROR", 10000) == 1)
                {
                    // Waits for status IP STATUS
                    while(sendATcommand2("AT+CIPSTATUS", "IP STATUS", "", 500)  == 0 );
                    delay(5000);
                    Serial.println("Openning TCP");
                    
                    // Opens a TCP socket
                    if (sendATcommand2("AT+CIPSTART=\"TCP\",\"google.com\",\"80\"", "CONNECT OK", "CONNECT FAIL", 30000) == 1)
                    {
                        Serial.println("Connected");
                        
                        // Sends some data to the TCP socket
                        sprintf(aux_str,"AT+CIPSEND=%d", strlen(ip_data));
                        if (sendATcommand2(aux_str, ">", "ERROR", 10000) == 1)    
                        {
                            sendATcommand2(ip_data, "OK", "ERROR", 10000);
                        }
                        

                    }
                    else
                    {
                        Serial.println("Error openning the connection");
                    }  
                }
                else
                {
                    Serial.println("Error getting the IP address");
                }  
            }
            else
            {
                Serial.println("Error bring up wireless connection");
            }
        }
        else
        {
            Serial.println("Error setting the APN");
        } 
    }
    else
    {
        Serial.println("Error setting the single connection");
    }
    
}

void power_on() {
    uint8_t answer=0;

    // checks if the module is started
    answer = sendATcommand2("AT", "OK", "OK", 2000);
    if (answer == 0) {
      Serial.println("Powering up...");
      
      pinMode(9, OUTPUT); 
      digitalWrite(9,LOW);
      delay(1000);
      digitalWrite(9,HIGH);
      delay(2000);
      digitalWrite(9,LOW);
      delay(3000);

      Serial.println("Waiting...");
        // waits for an answer from the module
        while(answer == 0){  
            // Send AT every two seconds and wait for the answer
            answer = sendATcommand2("AT", "OK", "OK", 2000);
            mySerial.println(answer);
          }
    }
}

int8_t sendATcommand2(char* ATcommand, char* expected_answer1, char* expected_answer2, unsigned int timeout){

    //Serial.print("Sending: ");
    //Serial.println(ATcommand);
  
    uint8_t x=0,  answer=0;
    char response[100];
    unsigned long previous;

    memset(response, '\0', 100);    // Initialize the string

    delay(100);

    while( mySerial.available() > 0) mySerial.read();    // Clean the input buffer

    mySerial.println(ATcommand);    // Send the AT command 

    x = 0;
    previous = millis();

    // this loop waits for the answer
    do{
        // if there are data in the UART input buffer, reads it and checks for the asnwer
        if(mySerial.available() != 0){    
            response[x] = mySerial.read();
            x++;
            // check if the desired answer 1  is in the response of the module
            if (strstr(response, expected_answer1) != NULL)    
            {
                answer = 1;
            }
            // check if the desired answer 2 is in the response of the module
            else if (strstr(response, expected_answer2) != NULL)    
            {
                answer = 2;
            }
        }
    }
    // Waits for the asnwer with time out
    while((answer == 0) && ((millis() - previous) < timeout));    

    Serial.print("Received--: ");
    Serial.println(response);
    return answer;
}

Don't mind that it says "400 Bad Request" this is just an example.

So it doesn't say that all the time? Even though I see it is in fact a bad request?

edit: This would be correct for HTTP/1.1. You need to send a host and connection parameter.

char ip_data[]="GET / HTTP/1.1\r\nHost: google.com\r\nConnection: close\r\n\r\n";

Hi SurferTim,
Thanks for your reply

I dont care what response I get (200, 301, 400), just as long as the response isn't gibberish. That's why i said, "Don't mind" it, this is just an example. Adding the correct connection parms doesn't make the gibberish disappear. I've modified my original post to reflect those changes so we don't get hung-up on that issue again.

So, any ideas about the protocol trash that's appearing?

That looks like it downloads Google's home page. How big is the response from the server? Is it larger than 99 characters? If so, you overflowed an array in the sendATcommand2() function.

    char response[100];

// then later...
    // this loop waits for the answer
    do{
        // if there are data in the UART input buffer, reads it and checks for the asnwer
        if(mySerial.available() != 0){    

// I inserted buffer overflow prevention here. 
// Otherwise, you will get garbage after the first 99 characters.
            if(x<99) {
               response[x] = mySerial.read();
               x++;
             }
             else Serial.println("OVERFLOW!");

            // check if the desired answer 1  is in the response of the module
            if (strstr(response, expected_answer1) != NULL)    
            {
                answer = 1;
            }
            // check if the desired answer 2 is in the response of the module
            else if (strstr(response, expected_answer2) != NULL)    
            {
                answer = 2;
            }
        }
    }
    // Waits for the asnwer with time out
    while((answer == 0) && ((millis() - previous) < timeout));

Do you ever see "OVERFLOW!" on the serial monitor?

... testing...

yeah... you got it. that's the issue.