114
W&T
TCP / UDP - Binary
RCounter=packed record
send_sequence:word;
rec_sequence:word;
sruct_type:word;
length:word;
counter_index: word;
counter_value: longword;
end;
The structures must in any case be defined as
packed record
. The
packed addition ensures that the sequence of Low and High byte
is correct when sending (Low-Byte first).
The defined IO structures must be declared as variables:
var
Form1
: TForm1;
ReadCounter : RReadCounter;
Counter
:
RCounter;
The following procedure opens the TCP connection:
procedure TForm1.bConnectClick(Sender: TObject);
begin
ClientSocket1.Host:= ‘172.16.232.17’;
ClientSocket1.Port:= 49153;
ClientSocket1.Open;
end;
Invoking the next procedure sends the
Read Counter
structure to
the Web-IO:
procedure TForm1.bSendClick(Sender: TObject);
begin
// Fill the ReadCounter structure
ReadCounter.send_sequence = 0
ReadCounter.rec_sequence = 0
ReadCounter.struct_type = $B0
ReadCounter.length = 10
ReadCounter.counter_index = 11 ‘// Input-Counter 11
ClientSocket1.Socket.SendBuf(ReadCounter,10);
Содержание 57630
Страница 8: ...8 W T Content...
Страница 22: ...22 W T Assigning the IP address...
Страница 44: ...44 W T configuring the network parameters...
Страница 194: ...194 W T Diacnostics and testing...
Страница 211: ...211 W T Decalration of conformity Subject to errors and modifications 7 9 Declaration of Conformity...