串口收发数据,结果在读数据的时候卡了,卡在了ComRd处,请问是为什么?
int CVICALLBACK tt (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int Byte_send;
int Strlen;
unsigned char ReadBuf[20]={0};
unsigned char Receive[9]={0};
double weiyi;
int ReceiveData=0;
switch (event)
{
case EVENT_TIMER_TICK:
FlushInQ(6);
FlushOutQ(6);
Byte_send=ComWrt(6,Write,8);
//Strlen=GetInQLen(6);
ComRd(6,ReadBuf,20);
for(int i=0;i<9;i++)
{
Receive[i]=ReadBuf[i+5];
}
sprintf(Receive,"%c%c%c%c%c%c%c",Receive[0],Receive[1],Receive[3],Receive[4],Receive[5],Receive[6],Receive[7]);
weiyi=atof(Receive);
SetCtrlVal(panelHandle,PANEL_NUMERICMETER,weiyi);
FlushInQ(6);
FlushOutQ(6);
break;
}
return 0;
}
定时器设置为1秒,发送正常,接收的时候能卡5-10秒才收到数,函数参考NI的例程,为什么会出现卡的问题?