//ComRev.cpp  这里中断接收
VOID CALLBACK CntIrq1(int port)
{
    if(MoxaInitGood == false)  return;
nLength1_temp = sio_read(port,abIn1,MAXBLOCK); //读取串口数据,MAXBLOCK=540
if(nLength1_temp>0)
{
memcpy(Rbuff1_temp,abIn1,nLength1_temp);//将数据暂存到Rbuff1_temp数组中
TRACE(" nLength1 %d  %f\n",nLength0,nLength1_temp,GetCurrentSecond());//GetCurrentSecond()得到当前时间,精确到毫秒 HANDLE hEvent;
hEvent = OpenEvent(SYNCHRONIZE|EVENT_MODIFY_STATE,NULL,"SONAR2BATTLE");  //打开信号
SetEvent(hEvent);
CloseHandle(hEvent);
}
}//ProcessData.cpp  线程处理数据
UINT ProcessData(LPVOID pParam)
{ while(1)
{
wbSuccess = WaitForMultipleObjects(nSize,hFlag,false,INFINITE);
eEvent =  EEvent(wbSuccess - WAIT_OBJECT_0);
switch(eEvent)
{

case SONAR2BATTLE:   
{
nLength1 = nLength1_temp; //将数组长度赋给nLength1 ,怕又来一个中断是将先前的数组长度冲掉
memcpy(Rbuff1,Rbuff1_temp,nLength1_temp);//同上
if(flag&&nLength1>0)//先处理else,每个周期开始flag=false;
{
memcpy(Rbuff0+temp,Rbuff1,nLength1);  //如果没有收齐,则把新来的数据拼接在Rbuff0后面
TRACE("if nLength%d  time %f\n",nLength1,GetCurrentSecond());
nLength1 = temp + nLength1;
int j=1;
while(j<=nLength1)  //判断数据有没有收齐
{
if((Rbuff0[j] == 0xb0)&&(Rbuff0[j+2]==0xaa))
{
j = j+7;
}
else if((Rbuff0[j] == 0x02)&&(Rbuff0[j+2] == 0x70))
{
j = j+6;
}
else if((Rbuff0[j] == 0x0a)&&(Rbuff0[j+2] == 0x70))
{
j = j+14;
}
else 
break;

if(j-1 == nLength1)
{
full = true;
flag = false;
temp =0;
break;
}
if(j > nLength1 +1)
{
flag = true;
temp = nLength1;
full =false;
break;
}

}


}
else if(nLength1>0)
{
memcpy(Rbuff0,Rbuff1,nLength1);
int j = 1;
TRACE("else nLength%d  time %f\n",nLength1,GetCurrentSecond());
while(j<=nLength1)
{

TRACE("%d\t",j);
//因为每进行一个for循环就发送一个报文,所以接收的数据可能包括好几个报文,
//这样做的目的是判断接收的串口数据有没有收齐。
if((Rbuff0[j] == 0xb0)&&(Rbuff0[j+2]==0xaa)) 
{
j = j+7;
}
else if((Rbuff0[j] == 0x02)&&(Rbuff0[j+2] == 0x70)) 
{
j = j+6;
}
else if((Rbuff0[j] == 0x0a)&&(Rbuff0[j+2] == 0x70))
{
j = j+14;
}
else 
break;

if(j-1 == nLength1)
{
full = true;  //表示收齐了一个周期的报文数据。

}
if(j > nLength1 +1)
{
flag = true;   //表示还有部分数据没有收齐
temp = nLength1;
full =false;
break;
}

}
}
if(full)  //数据收齐,就进行报文解析工作
{
TRACE("message process\n");
Sonar2Battle();
}
}//最多有124个字节,串口是分几批发数据过来的,下面是TRACE的结果:
//这是正常的
nLength1 124  79094.984000          <---这是数据接收的TRACE结果
else nLength124  time 79094.984000  <---这是数据处理的TRACE结果
1 7 21 35 49 63 69 83 97 111 message processnLength1 120  79130.968000
else nLength120  time 79130.968000
1 7 21 35 49 63 69 83 97 111 nLength1 4  79130.984000
if nLength4  time 79130.984000
message process6  nLength1 6  79162.906000
else nLength6  time 79162.906000
1 message process
nLength1 118  79162.984000
else nLength118  time 79162.984000
1 15 29 43 57 63 77 91 105 message process//但十次有一次不正常
nLength1 120  40129.171000             <---这是数据接收的TRACE结果
nLength1 4  40129.171000               <---这里还没有进行数据处理,中断又来了。
else nLength4  time 40129.171000
1 message process
。。
怎么办,再一个礼拜要交差了,不然工作就丢了,请高手帮我费点时间,看看。