Are legato's timers affected by system clock changes?


#1

Hello everyone,

in previous projects I experienced that running timers can be sensitive to system clock changes.

How do the legato timers behave in case of a system clock change while they are running? Will they just fire based on the specified delay? Or are they somehow based on the system clock and I need to adapt my running timers whenever the system clock changes?

Cheers
Florian


#2

Hi,

I tried on WP8548 Legato version 17.08.1.
If I run the following code:


#include “legato.h”

#define TIMER_INTERVAL_SEC 3
#define TIMER_INTERVAL_uSEC 100000
static void tmrHandler(le_timer_Ref_t timerRef) {
LE_INFO(“INSIDE TIMER”);

}
COMPONENT_INIT
{
LE_INFO(“Hello, world.”);
le_clk_Time_t clk = { .sec = TIMER_INTERVAL_SEC, .usec = TIMER_INTERVAL_uSEC };
le_timer_Ref_t adxlPollingTimer = le_timer_Create(“ADXL_TIMER”);
le_timer_SetRepeat(adxlPollingTimer, 1000);
le_timer_SetInterval(adxlPollingTimer, clk);
le_timer_SetHandler(adxlPollingTimer, tmrHandler);
le_timer_Start(adxlPollingTimer);
}


And keep on running the command "date +%T -s “01:50:00"” in console, I can still see the timer callback message.

Apr 12 01:50:00 | hello1[7119]/hello1Component T=main | hello1Component.c tmrHandler() 6 | INSIDE TIMER
Apr 12 01:50:00 | hello1[7119]/hello1Component T=main | hello1Component.c tmrHandler() 6 | INSIDE TIMER
Apr 12 01:50:00 | hello1[7119]/hello1Component T=main | hello1Component.c tmrHandler() 6 | INSIDE TIMER
Apr 12 01:50:00 | hello1[7119]/hello1Component T=main | hello1Component.c tmrHandler() 6 | INSIDE TIMER
Apr 12 01:50:00 | hello1[7119]/hello1Component T=main | hello1Component.c tmrHandler() 6 | INSIDE TIMER
Apr 12 01:50:00 | hello1[7119]/hello1Component T=main | hello1Component.c tmrHandler() 6 | INSIDE TIMER


#3

Hi jyijyi,

excellent! Thank you very much!

Florian