OS restart while sending/receiving frames


#1

I am experiencing some problems, the OS retart while running my application, The application subscribe to uart2, install an event handler and a receiver, then install a timer which does a fcmSendData at regular interval, on the other side of the serial line is a C program that upon receiving a request sends back an answer.
Could someone tell me what I am doing wrong?

Thanks a lot

here are the hardware and software revision.
AT+WHWV Hardware Version 4.23
AT+CGMR R74a00gg.FSU004 2106632 102809 12:57

#include "adl_global.h"

u32 wm_apmCustomStack [ 256 ];
const u16 wm_apmCustomStackSize = sizeof ( wm_apmCustomStack );

s8 	Receive, Send;
u32 	frame_number = 1;

/***************************************************************************************/
bool Display_std( u8 *data, u16 len, u32 num){
u8 buffer[256];

	 memset(buffer,0,sizeof(buffer));
      sprintf ((char *)buffer,"(%d) %s",num,data);
	 adl_atSendResponse(ADL_AT_RSP,(ascii *) buffer);
	 return TRUE;
}

/*****************************************************************************************/
bool rcvCtrlHandler ( u8 Event ){
char  buf[128];
    switch ( Event )    {
			case ADL_FCM_EVENT_FLOW_OPENNED :
				adl_atSendResponse(ADL_AT_RSP,"\r\nRcv Opened\r\n");
				adl_fcmSwitchV24State ( Receive, ADL_FCM_V24_STATE_DATA );
				break;
			case ADL_FCM_EVENT_FLOW_CLOSED:
				adl_atSendResponse(ADL_AT_RSP,"\r\nFlow event CLOSED\r\n");
				break;
			case ADL_FCM_EVENT_V24_DATA_MODE :
				adl_atSendResponse(ADL_AT_RSP,"\r\nFlow event Data mode\r\n");
				break;
			default :
    }
    return FALSE;
}

/********************************************************************************************/
bool ReceiveData ( u16 Length, u8 * Data ){
  u8 buffer[256];

	  wm_memset(buffer,0,sizeof(buffer));
	  wm_memcpy (buffer, Data, Length );

	  Display_std(buffer,Length,frame_number++);

 return TRUE;
}

/**********************************************************************************************/
void  SendRequest(u8 ID, void *context){
	u16 len;
	u8 text[] = "REQUEST\n";
	len = wm_strlen((char  *)text);

	if (adl_fcmGetStatus(Send,ADL_FCM_WAY_FROM_EMBEDDED) ==   ADL_FCM_RET_BUFFER_EMPTY) {
		adl_fcmSendData ( Send, text,len);
	} else{
		adl_atSendResponse(ADL_AT_RSP,"\r\nWaiting for buffer to be freed\r\n");
	}
}

/***********************************************************************************************/
void adl_main ( adl_InitType_e InitType ){

	//adl_atCmdSubscribe(  "AT+MEMSTAT",memStat , ADL_CMD_TYPE_ACT);
     Receive = adl_fcmSubscribe ( ADL_FCM_FLOW_V24_UART2,rcvCtrlHandler, ReceiveData );
     adl_tmrSubscribe ( TRUE, 40, ADL_TMR_TYPE_100MS , SendRequest);

}

and here is the log file that shows the restart :
Note : the first number in () is the sequence number on Fastrack, the second number in () is the sequnece number in the C Program

(1653) (11570) 0123456789
(1654) (11571) 0123456789
(1655) (11572) 0123456789
Start Application
Flow Open
Flow event Data mode
(1) (11574) 0123456789
(2) (11575) 0123456789
(3) (11576) 0123456789


#2

have you tried increasing your stack size?

default size for the stack with firmware 7.x upward is 4096 your’s is 16 times smaller (256)

also, does the restart occur at random times or does is always occur at the same time?


#3

I will increase the stack size to 4096 amd let you know.
the restart occurs randomly, once after 300 or so at other time after more than 4000 loops.

Yves


#4

Thanks for yoour help Madouc, increasing the stack size fixed the problem, no more restart after more than 20 000 loop.

Yves