我在做一个采集直流电参数仪的测量器的程序,是用rs232c口的,我用spcomm...
我在做一个采集直流电参数仪的测量器的程序,是用rs232c口的,我用spcomm, 但是就是得不到传过来的数据,帮看看有什么错误了:>
//传20H
procedure Tform3.getData() ;
var i:integer;
sbuf:array of byte;
sendstr:string;
begin
sendstr:='20h';
setlength(sbuf,Length(sendstr));
for i:= 1 to Length(sendstr) do
begin
try
sbuf[i]:=Byte(sendstr[i]);
except
Beep;
end;
end;
end;
procedure TForm3.Button1Click(Sender: TObject);
begin
getdata();
end;
// 得到传回参数
procedure TForm3.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
StrReceive:string;
begin
SetLength(StrReceive,BufferLength);
Move(Buffer^,PChar(StrReceive)^,BufferLength);
Memo1.Lines.Add(StrReceive); //把接收到的数据显示到一个Memo里
Memo1.Invalidate;
end;