Timer Legato BTA

Hi Everyone,

I have a problem with a timer that does not wake up, could you help me if it pleases.

Best Regards

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_SetInterval(ModeExecTimer, clk) == LE_OK)
{
	std::cout<<"---[Motion] ***success status to set interval ret == LE_OK *** \n"<<std::endl;
}
else
{
	std::cout<<"---[Motion] *** Erreur to set periode status to set interval ret == LE_OK *** \n"<<std::endl;
}

/*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();

}

What is the output when you run your program?
I didn’t see anything wrong with how you set up your timer, other than it being quite verbose.

Hi Shib,

Thank you for your answer.

the problem is that I have to call my function in a thread and that way it works well

Has this issue been resolved.

yes Thank you Vasantha_lax