procedure TForm1.Button1Click(Sender: TObject);
begin
Comm1.StartComm;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Comm1.StopComm;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
const
//ff 01 01 00 00 00 00 00 fe
SendBuf:array[1..9] of integer=(255,1,1,0,0,0,0,0,254);
begin
for i:=1 to 9do
Comm1.WriteCommData(@SendBuf,1);
end;
procedure TForm1.Comm1ReceiveData(Sender: TObject;
Buffer: Pointer;
BufferLength: Word);
var
i:integer;
begin
Move(Buffer^,PChar(@RBuf)^,BufferLength);
//获取缓冲数据
for i:=1 to bufferlengthdo
begin
mystr:=mystr+IntToHex(Rbuf,2)+' ';
icoun:=icoun+1;
if icoun=9 then
begin
Memo1.Lines.Add(mystr);
Label1.Caption :=IntToStr(memo1.Lines.Count);
mystr:='';
icoun:=0;
end;
end;
end;