我用你的控件时,发现当波特率小于等于2400时,连续发送就会出现接受不正确问题,我的实验程序是这样的,麻烦版主帮忙看看:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{ YbCommDevice1->PortNo=1;
YbCommDevice2->PortNo=2;
YbCommDevice1->Active=true;
YbCommDevice2->Active=true;
}
void __fastcall TForm1::YbCommDevice1CommNotify(TObject *Sender,
int NotifyType)
{
if(NotifyType&&EV_RXCHAR)
while(YbCommDevice1->InQueue->Count)//收到一个字符就发送两个字符1和10
{ BYTE DD[2];
DD[0]=1;
DD[1]=10;
YbCommDevice1->Write(DD,2);
Edit1->Text=DD[0];
Edit2->Text=DD[1];
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
YbCommDevice1->Active=false;
YbCommDevice2->Active=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::YbCommDevice2CommNotify(TObject *Sender,
int NotifyType)
{ BYTE m[2];
YbCommDevice2->Read(m,2);
Edit3->Text=m[0];
Edit4->Text=m[1];
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
BYTE c=1;
Label1->Caption=i++;
YbCommDevice2->Write(&c,1);
}
//---------------------------------------------------------------------------
--------------------next---------------------
阅读(1178) | 评论(0) | 转发(0) |