//串口接收,只有串口接收到数据帧才会触发此事件,可对数据帧进行协议判断和相应的处理
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var i:integer;
rxbuf:array of byte;
s:string;
begin
setlength(rxbuf,bufferlength);
move(buffer^,rxbuf[0],bufferlength);//接收数据装入数组
//ASC显示
s:='';
for i:=0 to bufferlength-1 do s:=s+Char(rxbuf); //接收数据转为字符串形式
Memo2.Lines.Add(s);//显示字符串
END;