07-15-2011 11:02 PM
Hi,
I was wondering: I have a timer. Inside the timer callback I have a function that should be running once the timer is ON. but I notice that this function is beeing executed 5 times before exit. any explaination?
07-16-2011 06:43 AM
Are you filtering events inside the callback? You should execute the code only for EVENT_TIMER_TICK event, otherwise the callback could be executed for other events like EVENT_DISCARD and so on.
07-16-2011 01:02 PM
Here is what I have:
int CVICALLBACK timer3 (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_TIMER_TICK:
enablingTest();
break;
}
return 0;
}
enablingTest() function is just a function executing without any delay or sleep inside.
Some variable in this functions will be used by other. Which seems to create a delay of about 4 sec as this function is executing about 4 times before exit.
also to mention, in my application I have 2 other timers but they running other functions independant to this.
07-16-2011 05:20 PM
Which is the timer interval? And how long takes the function to execute?
Could you print some debug informations to help discriminating how it is working? Something like that:
int CVICALLBACK timer3 (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double tini; switch (event) { case EVENT_TIMER_TICK: tini = Timer (); enablingTest(); DebugPrintf ("%s Inside the switch. Time taken: %.2f\n", TimeStr (), Timer () - tini); break; } DebugPrintf (%s Out of the switch. Event %d\n" TimeStr (), event); return 0; }