Home > Back-end >  Delphi xe7 udp receives an array
Delphi xe7 udp receives an array

Time:09-20

Single-chip microcomputer by udp sends the 32 bytes per 1 s to PC, is now receiving data, could you tell me how to use Delphi implementation will receive the data in an array, thus I can for each byte, like the inside of the STM32 definition u8 data [32], and then the data [0] can I assigned to variables,,,

Below is the demo, udp chat microcontroller every time sending a few directly into a question mark, how will receive adata in my definition of 32 bytes in length of an array? The great god give directions, thank you!
The function IdBytesToAnsiString (ParamBytes: TIdBytes) : AnsiString;
Var
I: Integer;
S: AnsiString.
The begin
S:=';
For I:=0 to Length (ParamBytes) - 1 do
The begin
S:=S + AnsiChar (ParamBytes [I]);
end;
Result:=S;
end;
///////////////////////////////////////////////////////////////////////////////////////////
Procedure TForm1. BtnconnectClick (Sender: TObject);
The begin
Idpsrvr1. DefaultPort:=8089;
Idpsrvr1. Active:=True;
Btnconnect. Enabled:=False;
Btndisconnect. Enabled:=True;
end;
///////////////////////////////////////////////////////////////////////////////////////////
Procedure TForm1. Idpsrvr1UDPRead (AThread: TIdUDPListenerThread;
Const AData: TIdBytes; ABinding: TIdSocketHandle);
The begin
Mmo1. Lines. The Add (IdBytesToAnsiString (AData));
end;
///////////////////////////////////////////////////////////////////////////////////////////
  • Related