Overall the project can receive data from an XBee on Serial3 or from an ethernet shield. There are two functions that parse the received data and act on it. The parsed data can cause parts of the graphical display to be updated. All this works fine.
Today I just added a new data handler - it's the same function in both of the parse routines, literally copied & pasted then changed one variable - but when the function call is in one of the routines, it crashes the arduino bootloader so that avrdude never finishes the upload. With the preferences set to verbose upload, I can see the data coming back from the Arduino looks like the bootloader has dropped into its monitor routine, where it's waiting for direct debugging commands.
Code: Select all
} else if(message.startsWith("outdoorTemp=")) {
String buffer = message.substring(12);
int tt = stringToNumber(buffer);
outdoorTemp = tt;
outdoorTempTime = now.secondstime() + 900;
// updateOutdoor();
}
Yet this code snippit works fine:
Code: Select all
} else if(command.startsWith("outdoorTemp=")) {
String buffer = command.substring(12);
int tt = stringToNumber(buffer);
outdoorTemp = tt;
outdoorTempTime = now.secondstime() + 900;
updateOutdoor();
}
Code: Select all
void updateOutdoor() {
if(initialized) {
GLCD.DrawBitmap(GoL, 5, 43, BLACK);
GLCD.SelectFont(System5x7);
GLCD.GotoXY(22, 43);
if(golState) {
GLCD.Puts("On ");
} else {
GLCD.Puts("Off");
}
GLCD.GotoXY(52, 43);
GLCD.Puts("Outside ");
if(outdoorTemp == 127) {
GLCD.Puts("??\\");
} else {
GLCD.PrintNumber(outdoorTemp);
GLCD.Puts("\\");
}
}
}
I've tested this on two Arduino Megas and verified that both Megas work just fine with other sketches, and this sketch works fine with that one line commented. If i uncomment the line however, then boom the sketch compiles but the upload fails.
The exact failure, as best I can see, is that partway through loading the sketch, the bootloader on the Arduino Mega is dropping into serial monitor mode, then the monitor gets confused by avrdude which is still trying to send the compiled sketch. So the arduino keeps responding over and over "Arduino Bootloader. Huh?" and avrdude keeps trying, and the two end up hung and I have to force-quit avrdude.
Any suggestions would be most appreciated!