Meine Routine sieht dafür folgendermaßen aus:
Delphi-Quellcode:
procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer); // <-- Im ObjektInspektor von ComPort1 das Ereignis OnRxChar zuweisen
var
i : integer;
r_buff : array[0..1024] of Char;
bCR : boolean;
begin
bCR := False;
ComPort1.Read(r_buff,SizeOf(r_buff));
for i := 1 to Count do
begin
if r_Buff[i-1] > #13 then
sReceive := sReceive+ r_Buff[i-1] else
case r_Buff[i-1] of
#13: bCR := True;
end;
end;
if length(sReceive) > 250 then bCR := True;
if bCR then
begin
Memo1.Lines.Insert(0, 'Empfange: ' + sReceive);
end;
end;