Commands and functions
P.
239 of 349
Readtcp
Sendtcp
Definition
●
Function
readtcp
(
port, ip, arg 1
[
, arg2, ... argN
])
Arguments
●
Argument
port
of data type u16 (the transmitter's outbound port)
●
Argument
ip
of data type u32 (the transmitter's address in the usual notation, e.g.
192.168.22.100)
●
arg2
to
argN
of arbitrary data type
Effect
●
Received “user data” start with the 3rd argument. Their number and data type is arbitrary.
●
If a TCP/IP telegram is sent to the Enertex
®
EibPC, every function
readtcp
updates its
respective arguments. The arguments of the
readtcp
function are filled with data up to the
length of its arguments. In any case, the variables
port
and
ip
of the function
readtcp
are
overwritten with the current data of the transmitter every time a TCP/IP telegram is
received.
●
The IP address (variable
ip
) is defined in the usual notation (xxx.xxx.xxx.xxx with xxx:
number between 0 and 255).
●
If your LAN device can be addressed by a name and DNS, the function
resolve
can
replace an explicit IP address.
●
To detect incoming telegrams, the function
event
can be applied to
readtcp
. This will
become necessary if telegrams with identical content have to be evaluated (see below).
Data type result (Return)
●
none
Definition
●
Function
sendtcp
(
port, ip, arg 1
[
, arg2, ... argN
])
Arguments
●
Argument
port
of data type u16
●
Argument
ip
of data type u32 (the receiver's address in the usual notation, e.g.
192.168.22.100)
●
arg2
to
argN
of arbitrary data type
Effect
●
Argument
port
is the destination port of the data sent by the Enertex
®
EibPC.
●
The “user data” starts with the 3rd argument. Their number and data type is arbitrary.
●
The IP address (variable
ip
) is defined in the usual notation (xxx.xxx.xxx.xxx with xxx:
number between 0 and 255).
●
If your LAN device can be addressed by a name and DNS, the function
resolve
can
replace an explicit IP address.
●
If
arg2
to
argN
are data type c1400, the terminating zero of the string will be transferred,
too.
Data type result (Return)
●
none
Example: Send TCP telegrams
Every 2 minutes, a TCP telegram shall be sent by the Enertex
®
EibPC to the port 5555u16 of
the receiver www.enertex.de. The user data to be transmitted is the string “I'm still alive”.
The socket is already open and ready to send (IP and Port open).
Implementation in the user program:
Count=0u32
if cycle(2,00) then sendtcp(5555u16,resolve($www.enertex.de$),$I'm still alive$) endif
Example: See page 71.
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - mail@enertex.de