ComPort-Library icon indicating copy to clipboard operation
ComPort-Library copied to clipboard

using String Buffer Y lost data after #0 character

Open xenergy1974 opened this issue 2 years ago • 1 comments

String converting lost data after #0 symbol You can't get #0 from port....

property Buffer: string read FBuffer write FBuffer; <<<<<<<<<<<< Here!

procedure TComDataPacket.RxBuf(Sender: TObject; const Buffer; Count: Integer); var sa:AnsiString; Str: string; i:Integer; begin SetLength(Str, Count); SetLength(Sa, Count); Move(Buffer, Sa[1], Count); {$IFDEF Unicode} if Length(sa)>0 then for i := 1 to Length(sa) do Str[i] := char(Byte(sa[i])); {$ELSE} Str := sa; {$ENDIF} <<<<<<<<<<<< Here! AddData(Str); end;

// add custom data to packet buffer procedure TComDataPacket.AddData(const Str: string); begin if ValidStop then begin Buffer := Buffer + Str; <<<<<<<<<<<< Here! HandleBuffer; end else DoPacket(Str); end;

xenergy1974 avatar Sep 07 '22 20:09 xenergy1974

Yep it has string everywhere instead of AnsiString And what the ... this {IFDEF Unicode} section???

nopikus avatar Sep 12 '22 05:09 nopikus