大家看看使用spcom这样写行不行!
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var i:integer;
begin
viewstring:='';
move(buffer^,(pchar(@rbuf))^,bufferlength);
new(buffer);
for i:=1 to bufferlength do
if chr(rbuf)='cb' then comm1.StopComm;
viewstring:=viewstring+chr(rbuf);
memo1.Text:=viewstring;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
self.Comm1.StartComm;
if not comm1.WriteCommData('3a',1) then
begin
showmessage('');
comm1.StopComm;
end;
end;