Next, I commented out all the code in 'UploadProblem.ino', leaving empty setup() and loop() functions. this uploads correctly, and I have attached the verbose build output as 190220_EmptyUploadProblemSuccess.txt
Then I added all the setup code back in, plus whatever support functions the setup() routines need to function. Compiles and uploads successfully. File attached as 190220_SetupOnlyUploadProblemSuccess.txt
Next I added back most of my loop() code, plus some needed support functions. Compiles and uploads successfully. 190220_SetupandLoopUploadProblemSuccess.txt
Next I added back some more support functions. Compiles and uploads successfully. See 190220_MoreLoop1UploadProblemSuccess.txt
Next I added back almost everything. Compiles and uploads successfully. See 190220_AlmostEverythingUploadProblemSuccess.txt
Next I added the rest of the code, and this time the upload failed! I was SURE I had nailed the problem down to some settings issue that got reset to a default value when I uploaded an empty project file. Now it is back to failing again
Closed and reopened VS/VM, and now I can upload successfully, with the last two additions commented back out.
Put the two additions in, and it failed to upload again. Commented them back out (and closed/reopened VS/VM, and also disconnected/reconnected the physical USB cable), and now it uploads successfully.
The two functions that I'm commenting in/out to make this happen seem to be pretty simple:
In the main program:
//mode string
char modestr[20];
memset(modestr, 0, sizeof(modestr));
//GetModeString(pkt.mode, modestr);
//submode (wall tracking) string
char trkstr[20];
memset(trkstr, 0, sizeof(trkstr));
//GetWallTrackString(pkt.submode, trkstr);
Uncommenting GetWallTrackString(pkt.submode, trkstr) and GetModeString(pkt.mode, modestr) causes the upload to fail. These functions are shown below
void GetModeString(int mode, char* bufptr)
{
sprintf(bufptr, "%s", ModeStrArray[mode]);
}
void GetWallTrackString(int mode, char* bufptr)
{
sprintf(bufptr, "%s", TrkStrArray[mode]);
}
ModeStrArray and TrkStrArray are defined as
const char* ModeStrArray[] = { "None", "Charge", "Home", "Wall", "DeadBatt" };
const char* TrkStrArray[] = { "None", "Left", "Right", "Neither" };
This has me completely mystified. ALL this code has been in my project for weeks if not months, and has been uploaded to the robot multiple times. In addition, I can upload to the Mega from the Arduino IDE with no problem, with or without these function calls present. It's hard for me to believe there can be anything in the source code that compiles OK, but causes problems on upload in VS/VM, but not in the Arduino IDE - how does that happen?
I wonder if this is yet another manifestation of an earlier problem I reported - that VS/VM insists on using the 5.40 compiler with it's known problems, while I have the Arduino IDE configured to use an earlier version of the compiler. Is that even possible?
As an end-cap to this whole discussion, I have included the verbose compile/upload output for the project, with the offending code still commented out. See 190220_VerboseCompileUploadAtEnd.txt and 190220_IDEVerboseCompileUploadAtEnd.txt
Out to lunch in Ohio
Frank
Frank