var Viewstring:string;
sbuf:array[1..11] of byte;
Procedure Senddata; //发送函数
var
i:integer; commflg:boolean;
begin
ViewString:='';
Commflg:=true;
for i:=1 to SendTotal do begin
if not DLLForm.Comm1.WriteCommData(@sbuf,1) then begin
Commflg:=false;
Break;
end;
Sleep(200);
viewstring:=viewstring+inttohex(sbuf,2)+' ';
end;
ViewString:='发送'+ viewstring;
if not Commflg then Messagedlg('发送失败 !' ,mterror,[mbyes],0);
end;
Procedure button1click();
begin
sbuf[1]:=byte($ff);
sbuf[2]:=byte($ff);
sbuf[3]:=byte($10);
sbuf[4]:=byte($01);
sbuf[5]:=byte($02);
sbuf[6]:=byte($61);
sbuf[7]:=byte($64);
sbuf[8]:=byte($16);
STotal:=8;
SendTotal:=8;
Sleep(100);
Senddata(); {调用发送函数}
end;