Yes I have had the need to turn off timer callbacks several times myself. From what you mentioned I assumed that you would like for the timer callback to be called every X seconds if possible, but if the comport is busy to either drop cycles or prolong the current one. You should be able to do this by having the follwing as the first thing in your timer callback.
int CVICALLBACK Timer_Callback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
SetCtrlAttribute (panel, PAN_TIMER, ATTR_ENABLED, 0);
CmtGetLock (com_lock);
ResetTimer (panel, PAN_TIMER);
SetCtrlAttribute (panel, PAN_TIMER, ATTR_ENABLED, 1);
/*... rest of callback ...*/
return 0;
}
Reseting the timer is optional, it jus
t makes the next event happen X seconds after rigth now, as opposed to whenever the next period would have occured.
I also know that you can choose to allow events to be processed while you are waiting in CmtGetLock. If you do this then you could also take an approch of allowing the timer to continue, but bailing out of the callback if another callback is in progress:
int CVICALLBACK Timer_Callback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
static int busy = 0;
if (busy) return 0;
busy = 1;
CmtGetLock (com_lock);
/*... rest of callback*/
busy = 0;
return 0;
}
I hope that one of these solves your problem.
jackson