Serial Port Synchronization in Delphi

后端 未结 5 2092
醉酒成梦
醉酒成梦 2021-01-15 08:18

I am still having issues with the TComPort component but this time is not the component itself is the logic behind it. I have a device witch sends some ascii strings via ser

5条回答
  •  不知归路
    2021-01-15 08:41

    Typical handler for OnRXChar event:

    procedure XXX.RXChar(Sender: TObject; Count: Integer);
    begin
      ComPort.ReadStr(s, Count);
      Accumulator := Accumulator + s;
      if not AccumContainsPacketStart then
        Accumulator := ''
      else if AccumContainsPacketEndAfterStart then begin
        ExtractFullStringFromAccum;
        ParseIt;
      end;
    end;
    

提交回复
热议问题