Issues on loading Sw on Arduino Mega 2560

Hello to everybody. I am new on this forum and hope someone can have experience on what I am reporting.
I am working with my board Arduino Mega 2560. No problem to upload the software after the compilation on the board until soke days ago. But, after the introdution of a particular function that helps me to find a certain substring on a bigger string and relevant indexes, I started to have loadiing problems on the board, even though the compilation is OK.

The introduced function is:

void analyzeStr (String SString, EthernetClient client){

char load[512];
char pC;
String bString ="";
int loadindex = 0; // reset load

if(SString.substring(0,SString.indexOf(' ')) == "GET"){
Serial.println("GET");

}

if(SString.substring(0,SString.indexOf(' ')) == "POST"){
Serial.println("POST");

memset(load,0,512);

for (loadindex = 0; loadindex <512; loadindex++){
pC = client.read(); Serial.print(pC);
load[loadindex] = pC;
}

loadindex = 0;
while ((loadindex < 512) && (bString.substring(0,16) != "Content-Length: ")) {

for (int k = 0; k < 16; k++ )
bString += load[loadindex + k];
delay(10);
Serial.println(bString);
loadindex++;
bString = "";
}
Serial.print("!!!!!!!!!!!!!TROVATO !!!! LoadIndex = ");Serial.println(loadindex);
}
}

The result of compilation is OK, but after awhile that the software is in proress to be loaded on the board, the process stops and shows the following lines:
avrdude: Recv: l [6c]
avrdude: Recv: o [6f]
avrdude: Recv: a [61]
avrdude: Recv: d [64]
avrdude: Recv: e [65]
avrdude: Recv: r [72]
avrdude: Recv: > [3e]
avrdude: Recv: H [48]
avrdude: Recv: u [75]
avrdude: Recv: h [68]
avrdude: Recv: ? [3f]
avrdude: Recv: . [0d]
avrdude: Recv: . [0a]
avrdude: Recv: B [42]
avrdude: Recv: o [6f]
avrdude: Recv: o [6f]
avrdude: Recv: t [74]
avrdude: Recv: l [6c]
avrdude: Recv: o [6f]
avrdude: Recv: a [61]
avrdude: Recv: d [64]
avrdude: Recv: e [65]
avrdude: Recv: r [72]
avrdude: Recv: > [3e]
avrdude: stk500v2_ReceiveMessage(): timeout

The messages are updated every 3-4 seconds, all the times the same and the program neer starts.
Do you know the kind of issue? I again remark that at same connection conditions, without the introduced routine, the software is normally loaded.

Thnak you in advance, Domenico, ITALY.

You need to either update your 2560 to the latest bootloader, or remove any occurrence of three or more exclamation points in a row.

see Google Code Archive - Long-term storage for Google Code Project Hosting.

YEs, Thats' right. Thank you, I did not know about this issue. I have eliminated a string containing the " !!! " and now it is working perfectly. Thank you very much for help :slight_smile: