高手进!急!----谢!(200分)

  • 主题发起人 ANTIDEAD
  • 开始时间
A

ANTIDEAD

Unregistered / Unconfirmed
GUEST, unregistred user!

我使用"串口精灵"从com1向com2口(我的程序)单个字符A/1000毫秒,程序受到的字符个数不稳定(应该是一个一个的接收,但有时是2~7个),代码如下,请高手指点:
procedure Tform1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);

var
i:integer;
strsouc: PChar;
strdesc:array[0..128] of char;
tempint:integer;
begin
strsouc:= Buffer;
//tempint:=strlen(str);


tempint:=0;
for i:=0 to bufferlength-1 do
begin
if strsouc=char(65) then
strdesc:=strsouc;
end;

tempint:=strlen(str
desc);
edit1.text:=inttostr(tempint);//tempint应为1,单有时是2~7之间的数.
if tempint<>0 then
intcontrol:=tempint;





end;
 
另:使用的是spcomm控件.我不知道是不是控件的问题.
大家快来帮忙呀!分不够,可以再加,不能不帮我啊!
 
会不会是设置异步那里的问题,我上次就碰过。。。
看看控件的设置!
 
to mikegong 我的参数:baudrate:1200;bytesiez:_8;readintervaltimeout:25;stopbit:_1;其余为默认设置;
问题可能处在那里,请告之!
 
to mikegong:在那里设置异步!
 
hi,help me!
斑竹快来呀!
 
接受答案了.
 

Similar threads

S
回复
0
查看
956
SUNSTONE的Delphi笔记
S
S
回复
0
查看
779
SUNSTONE的Delphi笔记
S
I
回复
0
查看
758
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
679
import
I
顶部