发送程序
procedure senddata;
var
i:integer;
commflg:boolean;
begin
viewstring:='' ;
commflg:=true;
for i:=1 to 6 do
begin
if not form1.comm1.writecommdata(@sbuf,1) then
begin
commflg:=false;
break;
end;
sleep(2);
viewstring:=viewstring+inttohex(sbuf,2)+'' ;
end;
viewstring:='发送'+viewstring+' ';
form1.memo1.lines.add(viewstring);
form1.memo1.lines.add('');
if not commflg then
messagedlg('发送失败!' ,mterror,[mbyes],0);
end;
发送的数
procedure TForm1.Button1Click(Sender: TObject);
begin
sbuf[1]:=byte($f0); //Ö¡Í·
sbuf[2]:=byte($01); //ÃüÁîºÅ
sbuf[3]:=byte($ff);
sbuf[4]:=byte($ff);
sbuf[5]:=byte($01);
sbuf[6]:=byte($f0); //֡β
senddata;//µ÷Ó÷¢Ëͺ¯Êý
end;
接收
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
i:integer;
begin
viewstring:='';
move(buffer^,pchar(@rbuf^),bufferlength);
for i:=1 to bufferlength do
viewstring:=viewstring + inttohex(rbuf,2)+'';
viewstring:='接收'+viewstring;
memo1.lines.add(viewstring);
memo1.lines.add('');
end;
错误提示:[Error] Unit1.pas(95): Pointer type required
就是说它pchar(@rbuf^)指针类型不匹配
是什么原因啊!请大家帮帮忙啊