|
我用编写了下面代码,程序没有语法错误,但在定时器下(设到0.5秒了)运行速度很慢,甚至死面,请问是什么缘故,请高手指点!!!
/*--------------------------------------------------------------*/
/* 发送数据代码1函数 */
/*--------------------------------------------------------------*/
void fashongdaima1(void)
{
if (ComWrt (comport,"@00RD0101002551*\r", 18) != 13)
inqlen = GetInQLen (comport);
if (inqlen>100)
read_data[0] = '\0';
bytes_read = ComRdTerm (comport, read_data, 500,13);
CopyString (tbox_read_data, 0, read_data, 0, bytes_read);
// SetCtrlVal (panelHandle,PANEL_TEXTBOX ,tbox_read_data);
}
/*--------------------------------------------------------------*/
/* 发送数据代码2函数 */
/*--------------------------------------------------------------*/
void fashongdaima2(void)
{
if (ComWrt (comport,"@00RD0126002554*\r", 18) != 13)
inqlen = GetInQLen (comport);
if (inqlen>100)
read_data[0] = '\0';
bytes_read = ComRdTerm (comport, read_data, 500,13);
CopyString (tbox_read_data, 0, read_data, 0, bytes_read);
// SetCtrlVal (panelHandle,PANEL_TEXTBOX ,tbox_read_data);
}
/*--------------------------------------------------------------*/
/* 发送数据代码1函数 */
/*--------------------------------------------------------------*/
void fashongdaima3(void)
{
if (ComWrt (comport,"@00RD0151002554*\r", 18) != 13)
inqlen = GetInQLen (comport);
if (inqlen>100)
read_data[0] = '\0';
bytes_read = ComRdTerm (comport, read_data, 500,13);
CopyString (tbox_read_data, 0, read_data, 0, bytes_read);
// SetCtrlVal (panelHandle,PANEL_TEXTBOX ,tbox_read_data);
}
/*--------------------------------------------------------------*/
/* 发送数据代码1函数 */
/*--------------------------------------------------------------*/
void fashongdaima4(void)
{
if (ComWrt (comport,"@00RD0176002551*\r", 18) != 13)
inqlen = GetInQLen (comport);
if (inqlen>100)
read_data[0] = '\0';
bytes_read = ComRdTerm (comport, read_data, 500,13);
CopyString (tbox_read_data, 0, read_data, 0, bytes_read);
// SetCtrlVal (panelHandle,PANEL_TEXTBOX ,tbox_read_data);
}
/*--------------------------------------------------------------*/
/* 接收数据定时器程序 */
/*--------------------------------------------------------------*/
int CVICALLBACK jieshouzhihuDSQ (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int a;
switch (event)
{
case EVENT_TIMER_TICK:
a=1;
while (a<=4)
{
a++;
switch (a)
{
case 1:fashongdaima1();break;
case 2:fashongdaima2();break;
case 3:fashongdaima3();break;
case 4:fashongdaima4();break;
}
}
break;
}
return 0;
}
是不是 “发送数据代码1函数 ”代码下的 if 函数运用出了问题还是其它的。 |
|