# OS restart while sending/receiving frames

**URL:** https://forum.sierrawireless.com/t/os-restart-while-sending-receiving-frames/4232
**Category:** Open AT
**Created:** [February 24, 2010, 5:40am UTC](https://forum.sierrawireless.com/t/os-restart-while-sending-receiving-frames/4232 "2010-02-24T05:40:20Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![yautran](https://avatars.discourse-cdn.com/v4/letter/y/c57346/32.png) [@yautran](https://forum.sierrawireless.com/u/yautran)
#### Post date: [February 24, 2010, 5:40am UTC](https://forum.sierrawireless.com/t/os-restart-while-sending-receiving-frames/4232/1 "2010-02-24T05:40:20Z")

</div>

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

```auto
#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

---

<div class="post-metadata">

### Author: ![Madouc](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Madouc](https://forum.sierrawireless.com/u/Madouc)
#### Post date: [February 24, 2010, 6:29am UTC](https://forum.sierrawireless.com/t/os-restart-while-sending-receiving-frames/4232/2 "2010-02-24T06:29:00Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![yautran](https://avatars.discourse-cdn.com/v4/letter/y/c57346/32.png) [@yautran](https://forum.sierrawireless.com/u/yautran)
#### Post date: [February 24, 2010, 7:22am UTC](https://forum.sierrawireless.com/t/os-restart-while-sending-receiving-frames/4232/3 "2010-02-24T07:22:08Z")

</div>

> [@Madouc](#):
>
> 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?

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

---

<div class="post-metadata">

### Author: ![yautran](https://avatars.discourse-cdn.com/v4/letter/y/c57346/32.png) [@yautran](https://forum.sierrawireless.com/u/yautran)
#### Post date: [February 25, 2010, 5:08am UTC](https://forum.sierrawireless.com/t/os-restart-while-sending-receiving-frames/4232/4 "2010-02-25T05:08:16Z")

</div>

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

Yves
