Serial Port Synchronization in Delphi

后端 未结 5 428
不知归路
不知归路 2021-01-15 07:59

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:38

    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;
    

提交回复
热议问题