sscanf crashing Mod5234

Discussion to talk about software related topics only.
Post Reply
BryanJS
Posts: 7
Joined: Sun Jun 03, 2018 10:14 am

sscanf crashing Mod5234

Post by BryanJS »

I am having problem with the sscanf function.

It works in debug mode but as soon as I run the program it crashes. I am probably doing something fundamentally wrong.

I am trying to extract the time integers from a string I receive from the serial port 0. The string is in the format "SYNC<hh:mm:ss MM-dd-yy>" and the sscanf works well when debugging but crashes in run mode.

Any help would be appreciated.




void SyncTime(char * buffer)
{
int iHours = 0 ;
int iMinutes = 0 ;
int iSeconds = 0 ;
int iDate = 0 ;
int iMonth= 0 ;
int iYear = 0 ;

bool blnOK = true;

if(blnOK )
{
// buffer format = "SYNC<hh:mm:ss mm-dd-yy>"
sscanf(&buffer[5], "%d:%d:%d %d-%d-%d", &iHours, &iMinutes , &iSeconds, &iMonth, &iDate, &iYear);
iprintf("SYNC<OK>\n\r");
}
else
{
iprintf("SYNC<FAIL>\r\n");
}
}
BryanJS
Posts: 7
Joined: Sun Jun 03, 2018 10:14 am

Re: sscanf crashing Mod5234

Post by BryanJS »

It could be something related to the RTO task - I am using the console task skeleton to talk to serially on Port 0. From tests I think it could be related to the RTO scheduling as it seems to crash if I use on other functions as well.

Could it be a memory or task scheduling problem.



// Service Entry point
void ConsoleService(void *)
{
iprintf("\n\n---------------STC Control System--------------\n\n\n\n");
iprintf("Enter ? - for Main Menu \n\n");



//SerialClose(0);
//OpenSerial(PC_PORT, BAUD_RATE,1,8,eParityNone);


while(1)
{
if ( charavail() )
{
osCritObj.Enter( 0 );
char buffer[RX_BUF_SIZE];
gets(buffer );
ProcessCommand(buffer );
osCritObj.Leave();

}

OSTimeDly(DELAY_100MS);
}
}

void SyncProcess(char * buffer)
{
int iHours = 0 ;
int iMinutes = 0 ;
int iSeconds = 0;
int iDate = 0;;
int iMonth= 0;
int iYear = 0;

bool blnOK = true;

if(blnOK )
{

iHours = atoi(&buffer[5]);
iMinutes = atoi(&buffer[8]);
iSeconds = atoi(&buffer[11]);

iMonth = atoi(&buffer[14]);
iDate = atoi(&buffer[17]);
iYear = atoi(&buffer[20]);


// Crashes on either line - when running
// printf("Hours:%2d , Minutes:%2d , Seconds:%2d\n", iHours, iMinutes, iSeconds);
// int n = sscanf(str, "SYNC<%2d:%2d:%2d %2d-%2d-%2d>" , &iHours, &iMinutes , &iSeconds, &iMonth, &iDate, &iYear);



iprintf("SYNC<OK>\n");
}
else
{
iprintf("SYNC<FAIL>\r\n");
}


}
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: sscanf crashing Mod5234

Post by pbreed »

What NNDK version, we saw this bug, and its releated to the malign-in setting...
TYhe Jsut released 2.8.X and soon as in any day now 2.9.1 will fix this.
Post Reply