Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using String Buffer Y lost data after #0 character #9

Open
xenergy1974 opened this issue Sep 7, 2022 · 1 comment
Open

using String Buffer Y lost data after #0 character #9

xenergy1974 opened this issue Sep 7, 2022 · 1 comment

Comments

@xenergy1974
Copy link

xenergy1974 commented Sep 7, 2022

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;

@nopikus
Copy link

nopikus commented Sep 12, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants