我都快疯了,怎么会这样!
用的控件是MSComm32.OCX 6.0 version 1.1
代码如下
long int num=0;
byte i_data[20000];
void __fastcall TForm1::Button1Click(TObject *Sender)
{
MSComm1->InBufferCount=0;//初始化端口配置
MSComm1->OutBufferCount=0;
MSComm1->RThreshold=0;
MSComm1->SThreshold=0;
MSComm1->InputMode=1;
MSComm1->Settings="115200,n,8,1";
MSComm1->InBufferSize=8192;
MSComm1->OutBufferSize=8192;
MSComm1->DTREnable=true;
MSComm1->RTSEnable=true;
MSComm1->CommPort=3;
MSComm1->PortOpen=true;
MSComm1->InputLen=1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::MSComm1Comm(TObject *Sender)//响应函数
{
while (MSComm1->InBufferCount>0)
{
//untempt=i_pMsComm->InBufferCount;
i_data[num++]=(byte)MSComm1->Input.GetElement(0);// <----- L1
//untempt=i_pMsComm->InBufferCount;
}
//if(num>10000)
//{//
// ShowMessage("ok");
// }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)//发送指令
{
MSComm1->InBufferCount=0;
MSComm1->OutBufferCount=0;
AnsiString s="AT………………/video.jpg\"\r\n";//命令是将该文件上传
MSComm1->RThreshold=1;
MSComm1->Output=s;
//MSComm1->Output="AT$…………/12.jpg\"\r\n";
}
在Window2000 perfessional版本中,不能传比缓冲区大的文件。在L1处报错"variant array index out of bound。有时候只是报错,但不指定位置,说STACK OVERFLOW.
在一台XP上,可以比缓冲区大的文件,完全正常
在另一台XP上,也不能传。报同样的错。
都是BCB6.0,控件一样,搞了几天了都不知道原因
请大家帮我想想是什么原因。最好不是硬件原因,因为这个程序必须在所有机子上通用。