请斑竹和高手们帮帮忙
我做一个上位机的通讯程序是遇到一个很怪的问题,做了好长时间也没解决,请斑竹和高手们帮忙
看看,问题出在哪?谢谢!
发送程序没问题,接收程序是这样的:
unsigned char rbuffer[23];
unsigned char *bufx;
tagVARIANT buffer;
unsigned int k;
if(MSComm1->CommEvent==2)
{
delay(80);
k=MSComm1->InBufferCount;
if((k>=5) && (k<24))
{
MSComm1->InputLen=(short)k;
buffer=MSComm1->Input; //读进数据
bufx=(unsigned char*)buffer.parray->pvData;
for(unsigned int i=0;i<k;i++) //将数据传递给buf数组
{
rbuffer[i]=bufx[i];//**********************
if (xie_form->rxbuffer[i]==0x0d)
break;
}
MSComm1->InBufferCount=0; //清空接收缓冲区
MSComm1->InputLen=2;
}
}
每次运行到 rbuffer[i]=bufx[i];//**********************时就会出问题:
Project Project1.exe raised exception class EAccessViolation with message "Access violation at address 0040A72C in module 'Project1.exe'.Read of address FEEEFEEE".Process stopped.Use Step or Run to continue.
希望大家不吝赐教,谢谢!