# BTA timer configuration

**URL:** https://forum.legato.io/t/bta-timer-configuration/3789
**Category:** Legato Application Framework
**Created:** [October 18, 2018, 3:11pm UTC](https://forum.legato.io/t/bta-timer-configuration/3789 "2018-10-18T15:11:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Hassan91](https://avatars.discourse-cdn.com/v4/letter/h/a698b9/32.png) [@Hassan91](https://forum.legato.io/u/Hassan91)
#### Post date: [October 18, 2018, 3:11pm UTC](https://forum.legato.io/t/bta-timer-configuration/3789/1 "2018-10-18T15:11:38Z")

</div>

Hello everyone,

Can you help me, I have a problem with a timer that don’t woke up and I have a period of 1 minutes.

thank you,

le\_result\_t Motion::StartTimer()  
{  
le\_result\_t ret = LE\_FAULT;  
static size\_t PeriodetosendP = 0;

```
puts(" ---[Motion] ***Start timer*** \n");

/*mutexPeriod.lock();
PeriodetosendP = Alert_Motion_Period;
mutexPeriod.unlock();*/

//std::cout<<"---[Motion] ***periode = "<<PeriodetosendP <<"***"<<std::endl;

if((ModeExecTimer = le_timer_Create("ModeExecTimer")) == NULL)
{
	std::cout<<"---[Motion] *** Could not create the ModeExecTimer"<<std::endl;

}
le_clk_Time_t clk = { .sec = 60, .usec = 1000000 };
std::cout<<"clk sec = "<<clk.sec<<"clk usec "<<clk.usec<<std::endl;
le_timer_SetInterval(ModeExecTimer, clk);

/*if(le_timer_SetMsInterval(ModeExecTimer, PeriodetosendP*1000) == LE_OK)
{
	std::cout<<"---[Motion] ***success status to set interval ret == LE_OK*** \n"<<std::endl;
}
else
{

}*/

if(le_timer_SetRepeat(ModeExecTimer, 0) == LE_OK)
{
	std::cout<<"---[Motion] success to repeat Timer"<<std::endl;
}
else
{
	std::cout<<"---[Motion] this timer is currently running echeck to repeat timer "<<std::endl;
}

if(le_timer_SetHandler(ModeExecTimer, SetHundler) != LE_OK)
{
	std::cout<<"---[Motion] ***Could not set the handler for ModeExecTimer***"<<std::endl;
}

if( le_timer_Start(ModeExecTimer) == LE_OK)
{
	printf("---[Motion] ***timer start*** \n");
}
else
{
	printf("---[Motion] ***timer start = LE_BUSY the timer is already running*** \n");

}

if(le_timer_IsRunning(ModeExecTimer))
{
	std::cout<<"---[Motion] *** is running status le_timer_IsRunning = LE_OK "<<std::endl;
}
else
{
	std::cout<<"---[Motion] ***this timer object currently running*** \n"<<std::endl;

	if(le_timer_SetMsInterval(ModeExecTimer, PeriodetosendP*1000) != LE_OK)
	{
		std::cout<<"---[Motion] ****Cannot set Interval timer!***"<<std::endl;
	}
	else
	{
		le_timer_Start(ModeExecTimer);

	}
}
le_timer_GetContextPtr(ModeExecTimer);
NumrExpTimer = le_timer_GetExpiryCount(ModeExecTimer);
std::cout<<"---[Motion] ****Expiry Count***" << NumrExpTimer <<std::endl;

return ret;

```

}

void SetHundler(le\_timer\_Ref\_t timerRef)  
{  
timerRef = NULL;  
Motion motion;

```
std::cout <<"---[Motion] ****hello*** \n"<< " ***"<< __func__ <<"***"<<std::endl;

if(ModeExecTimer != NULL)
{
	le_timer_Stop(ModeExecTimer);
	std::cout<<"---[Motion] ***Timer != NULL*** \n"<<std::endl;
}
else
{
	std::cout<<"---[Motion] ***Timer == NULL*** \n "<<std::endl;
}

//std::cout<<"---[Motion] ***Set Period*** \n"<<std::endl;
//motion.SetPeriod();

std::cout<<"---[Motion] ***Start Timer*** \n"<<std::endl;
motion.StartTimer();

```

}

---

<div class="post-metadata">

### Author: ![JayM2M](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@JayM2M](https://forum.legato.io/u/JayM2M)
#### Post date: [October 18, 2018, 3:24pm UTC](https://forum.legato.io/t/bta-timer-configuration/3789/2 "2018-10-18T15:24:45Z")

</div>

Hi,

What happens if your timer handler just do the following?

```
void SetHundler(le_timer_Ref_t timerRef)
{
   std::cout <<"---[Motion] ****hello*** \n"<< " ***"<< __func__ <<"***"<<std::endl;
}

```

---

<div class="post-metadata">

### Author: ![Hassan91](https://avatars.discourse-cdn.com/v4/letter/h/a698b9/32.png) [@Hassan91](https://forum.legato.io/u/Hassan91)
#### Post date: [October 19, 2018, 12:03pm UTC](https://forum.legato.io/t/bta-timer-configuration/3789/3 "2018-10-19T12:03:20Z")

</div>

Hi,

thank you for answering my question.  
when I call it right, that’s what like result,

void SetHundler(le\_timer\_Ref\_t timerRef)  
{  
timerRef = NULL;  
Motion motion;

```
std::cout <<"---[Motion] ****hello*** \n"<< " ***"<< __func__ <<"***"<<std::endl;

/*if(ModeExecTimer != NULL)
{
	le_timer_Stop(ModeExecTimer);
	std::cout<<"---[Motion] ***Timer != NULL*** \n"<<std::endl;
}
else
{
	std::cout<<"---[Motion] ***Timer == NULL*** \n "<<std::endl;
}

//std::cout<<"---[Motion] ***Set Period*** \n"<<std::endl;
//motion.SetPeriod();

std::cout<<"---[Motion] ***Start Timer*** \n"<<std::endl;
motion.StartTimer();

*/

```

}

application is blocked completely:

Oct 12 16:29:41 (none) user.emerg Legato: _EMR_ | PsaServices[1459]/framework T=MgrLifecycle\_task | timer.c le\_timer\_SetRepeat() 805 | Assert Failed: ‘timerRef != NULL’  
Oct 12 16:29:41 (none) user.info Legato: INFO | PsaServices[1459] | coucou je suis dans la case IPC\_ID\_DR\_VEHICLE\_POSITION\_INFO

thanks you,

---

<div class="post-metadata">

### Author: ![Vasantha\_lax](https://avatars.discourse-cdn.com/v4/letter/v/5f9b8f/32.png) [@Vasantha\_lax](https://forum.legato.io/u/Vasantha_lax)
#### Post date: [October 31, 2018, 7:01am UTC](https://forum.legato.io/t/bta-timer-configuration/3789/4 "2018-10-31T07:01:19Z")

</div>

Hi,

Has this issue been resolved? If not can you shared the completed application package with source file and adef and cdef files.

Regards,  
Vasantha
