LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

problem entering the timer

Hello i send CAN frames with PCAN UDS API.

 need to send a sequence of 16 frames with ID E8 every 10ms. I therefore use a timer but as you can see on my screenshot some frames are not sent. this phenomenon is periodic. I do not understand why.

 

an extract

int main (int argc, char *argv[])
{
int ctrl;

if (InitCVIRTE (0, argv, 0) == 0) /* Needed if linking in external compiler; harmless otherwise */
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "interface_finale.uir", PANEL)) < 0)
return -1;

#ifdef FORD
ctrl = NewCtrl (panelHandle, CTRL_TIMER, "", 1, 1);
SetCtrlAttribute (panelHandle, ctrl, ATTR_INTERVAL,0.100);
SetCtrlAttribute (panelHandle, ctrl, ATTR_ENABLED, 1);
SetCtrlAttribute (panelHandle, ctrl, ATTR_CALLBACK_FUNCTION_POINTER, timerCallback);
#else
#endif

#ifdef FIAT

ctrl = NewCtrl (panelHandle, CTRL_TIMER, "", 1, 1);
SetCtrlAttribute (panelHandle, ctrl, ATTR_INTERVAL,0.010);
SetCtrlAttribute (panelHandle, ctrl, ATTR_ENABLED, 1);
SetCtrlAttribute (panelHandle, ctrl, ATTR_CALLBACK_FUNCTION_POINTER, FIATtimer);

/*ctrl = NewCtrl (panelHandle, CTRL_TIMER, "", 1, 1);
SetCtrlAttribute (panelHandle, ctrl, ATTR_INTERVAL,0.100);
SetCtrlAttribute (panelHandle, ctrl, ATTR_ENABLED, 1);
SetCtrlAttribute (panelHandle, ctrl, ATTR_CALLBACK_FUNCTION_POINTER, FIATtimer2);*/
#else
#endif

DisplayPanel (panelHandle);//display panel on scree

RunUserInterface ();//Runs the user interface and issues events to callback functions
return 0;
}

 

callback timer

 

unsigned char Fiatframe[129]={0x87,0x99,0x00,0x00,0x08,0x00,0x00,0xD1,
0x87,0x99,0x00,0x00,0x08,0x00,0x01,0xCC,
0x87,0x99,0x00,0x00,0x08,0x00,0x02,0xEB,
0x87,0x99,0x00,0x00,0x08,0x00,0x03,0xF6,
0x87,0x99,0x00,0x00,0x08,0x00,0x04,0xA5,
0x87,0x99,0x00,0x00,0x08,0x00,0x05,0xB8,
0x87,0x99,0x00,0x00,0x08,0x00,0x06,0x9F,
0x87,0x99,0x00,0x00,0x08,0x00,0x07,0x82,
0x87,0x99,0x00,0x00,0x08,0x00,0x08,0x39,
0x87,0x99,0x00,0x00,0x08,0x00,0x09,0x24,
0x87,0x99,0x00,0x00,0x08,0x00,0x0A,0x03,
0x87,0x99,0x00,0x00,0x08,0x00,0x0B,0x1E,
0x87,0x99,0x00,0x00,0x08,0x00,0x0C,0x4D,
0x87,0x99,0x00,0x00,0x08,0x00,0x0D,0x50,
0x87,0x99,0x00,0x00,0x08,0x00,0x0E,0x77,
0x87,0x99,0x00,0x00,0x08,0x00,0x0F,0x6A};

int enable_ex8=0;


int CVICALLBACK FIATtimer (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{

if (event != EVENT_TIMER_TICK) return 0;

if(enable_ex8==1)
{
status = UDS_MsgAlloc_2013(&FIAT_msg, config2,8);

for(i=0;i<8;i++)
{
FIAT_msg.msg.msgdata.isotp->data[i]=Fiatframe[j];
j=j+1;

if(j==64)
{
j=0;
}

}

status = UDS_Write_2013(PCANTP_HANDLE_USBBUS1, &FIAT_msg);

UDS_MsgFree_2013(&FIAT_msg);

}


return 0;
}

 

Thank you

0 Kudos
Message 1 of 3
(838 Views)

Hello,

CVI timers are not precise and can be interrupted by many things (like moving a window). At the very least you should be using asynchronous timers (they are almost a drop in replacement in terms of code). Search for asynctmr.fp

0 Kudos
Message 2 of 3
(831 Views)

Merci

0 Kudos
Message 3 of 3
(813 Views)