I have a very very strange problem, and my program is thousands of lines long so I am just going to throw out what is happening and ask for general ideas.
A function that is not being called is running and locking itself into an infinite loop. I get rid of the function and a different function again not called by anything starts running and looping. I have rolled back the software to an earlier version of the code that didn't have the issue and it persists and continues to do it. Does anyone have any ideas any thoughts at all as to how I can address this. It is in arduino so there is no way for me to see what is telling the assembly code to jump there and to keep going back to that same location.
Please any theories or advice would be much appreciated
Uncalled function loop repeatedly
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: Uncalled function loop repeatedly
How did you conclude that this (uncalled loop being called and halting) is what's happening?
Re: Uncalled function loop repeatedly
Fair point I have reached no definitive conclusions about what is happening.
The evidence I have at the moment is a series of serial prints coming from inside the function that is looping, I arrive at it not being called because there are also some serial prints that occur just before the looping function would be called. The looping function is only called once ever and that is from when the system starts up. There is no code that directs it to try over and over again.
The evidence I have at the moment is a series of serial prints coming from inside the function that is looping, I arrive at it not being called because there are also some serial prints that occur just before the looping function would be called. The looping function is only called once ever and that is from when the system starts up. There is no code that directs it to try over and over again.
Re: Uncalled function loop repeatedly
I added a debug macro and a lot of serial prints and have found this interesting little piece of information
here is the debug macro and code
Here is the one and only place in the code where the CellSetAPN() function is called:
and interestingly here is the debugging print from that
here is the debug macro and code
Code: Select all
#define BUG_HUNTER
#ifdef BUG_HUNTER
char FunctionTracker[1024];
char PreviousFunction[1024];
char PrePreviousFunction[1024];
#define BugHunt() \
sprintf(PrePreviousFunction,"%s",PreviousFunction);\
sprintf(PreviousFunction,"%s",FunctionTracker);\
sprintf(FunctionTracker,"function = %s",__func__);
#endif
void PrintBugHunt(){
#ifdef BUG_HUNTER
Serial.printf("1st location: %s\r\n",PrePreviousFunction);
Serial.printf("2nd location: %s\r\n",PreviousFunction);
Serial.printf("3rd location: %s\r\n",FunctionTracker);
#endif
}
Code: Select all
void CellSettings(){
BugHunt();
char cmd[64];memset(cmd,'\0',64);
//sprintf(cmd,"%sE0",AT);
//Cell_SendCMD_WaitResp(cmd, OK, 250);
Serial.println("Inside CellSettings function 0");
PrintBugHunt();
sprintf(cmd,"%s+%s",AT,THERMAL_PROTECTION);
Cell_SendCMD_WaitResp(cmd, OK, 250);
Serial.println("Inside CellSettings function 1");
PrintBugHunt();
sprintf(cmd,"%s+%s",AT,UART_OUTPUT);
Cell_SendCMD_WaitResp(cmd, OK, 250);
Serial.println("Inside CellSettings function 2");
PrintBugHunt();
sprintf(cmd,"%s+%s",AT,AUTO_TIMEZONE);
Cell_SendCMD_WaitResp(cmd, OK, 250);
Serial.println("Inside CellSettings function 3");
BugHunt();
CellSetAPN(); // SET THE APN FOR THE SIM CARD
}
void CellSetAPN(){
BugHunt();
Serial.println("Inside CellSetAPN function 0");
PrintBugHunt();
char cmd[300];memset(cmd,'\0',300);
sprintf(cmd,"%s+%s\"%s\"",AT,APN_PREFIX,APN);
Cell_SendCMD_WaitResp(cmd, OK, 500);
Serial.println("Inside CellSetAPN function 1");
PrintBugHunt();
if(APN_Auth[0]==AUTH_TYPE_NONE[0]){
sprintf(cmd,"%s+%s%s",AT,APN_AUTH_PREFIX,APN_Auth);
}
else{
sprintf(cmd,"%s+%s%s,\"%s\",\"%s\"",AT,APN_AUTH_PREFIX,APN_Auth,APN_PW,APN_UN);
}
Cell_SendCMD_WaitResp(cmd, OK, 500);
Serial.println("Inside CellSetAPN function 2");
PrintBugHunt();
}
and interestingly here is the debugging print from that
Code: Select all
11:46:03.958 -> Inside CellSetAPN function 0
11:46:03.958 -> 1st location: function = wdt_reset
11:46:03.958 -> 2nd location: function = Cell_Wait_Response
11:46:03.958 -> 3rd location: function = CellSetAPN
11:46:03.958 -> Command to cell = AT+CGSOCKCONT=1,"IP","data.mono"
11:46:04.011 -> Expected Response length = 4
11:46:04.513 -> No return
11:46:04.513 -> Inside CellSetAPN function 1
11:46:04.513 -> 1st location: function = Cell_Wait_Response
11:46:04.513 -> 2nd location: function = wdt_reset
11:46:04.513 -> 3rd location: function = Cell_Wait_Response
11:46:04.513 -> Command to cell = AT+CGAUTH=1,0
11:46:04.513 -> Expected Response length = 4
11:46:05.008 -> No return
11:46:05.008 -> Inside CellSetAPN function 2
11:46:05.008 -> 1st location: function = Cell_Wait_Response
11:46:05.008 -> 2nd location: function = wdt_reset
11:46:05.008 -> 3rd location: function = Cell_Wait_Response
Who is online
Users browsing this forum: No registered users and 43 guests