Programming - First steps
P.
66 of 349
$ $ : String up to 1400 characters
sendudp: Any arguments,
Not strings only!
sendudp with name resolution
readudp: Port, IP and any
arguments, not strings only!
Readudp and Event:
A message is arrived?
First, we have defined the character string
Title
. In contrast to the data type c14, at this type the
string is up to 1400 characters long. To define this data type, the character string is framed by two
dollar signs and we denote this type as c1400.
$ Text $
is string “ Text “ (With spaces)
This type of data can
not
be written on KNX
TM
display elements and only be converted to a KNX
TM
type by the
convert
-function.
To determine the length of a c1400 string, it is created with a \0 character at the end. This must be considered in the
LAN telegrams.
Next, we make use of
sendudp:
sendudp(
Port {Type u16},IP Address,Any number and types of arguments
)
The
sendudp
function requires a variable or an expression of data type u16 as the first argument.
This argument specifies the port number to which a UDP telegram is to be sent. The IP address
(second argument) is entered in the usual notation and is internally compatible with the type u32. The
actual data starts from the third Argument. These are arbitrary in number and type.
The Enertex
®
EibPC itself always sends from port 4807. This port can not be changed. When sending, the receiver's
port is specified on which the recipient receives the telegram.
If your LAN device can be addressed by a name and DNS, you can also use the function
resolve
(String{c1400}
)
For example in this case, you can also use an expression of the form
sendudp(3807u16,resolve($www.enertex.HomeMusicPlayer.de$),$ Start Music$)
The
sendudp
function can handle arbitrary data formats. Therefore, you are not restricted to the use
of c1400-strings (as in this example). However, more on that later.
The counterpart to the sending of a UDP telegram is its reception. For this purpose, the function
readudp
is available.
readudp(
Port {Type u16},IP Address{u32}, Any arguments
)
Again: The first argument is a variable or an expression of data type u16 and represents the port on
which a UDP telegram was received. The IP address (second argument) is of data type u32. The
actual “user data” start with the 3rd argument. Their number and data type is arbitrary.
The Enertex
®
EibPC always receives on port 4806. This port cannot be changed and must be
considered by the sender of UDP telegrams.
The
readudp
-function verifies in the input buffer of the Enertex
®
EibPC whether there is a UDP
telegram. In this case, the arguments of the
readudp
function are filled with data up to the length of
its arguments. In any case, the variables
port
and
ip
of the function
readudp
are overwritten with the
current data of the transmitter every time a UDP telegram is received.
A special feature is the use of event function: It indicates whether a telegram was read. In this
example, we relied on the fact that the data came from the correct port and sender. In order to
assure this, the following could also be written:
if event(readudp(Port,IP,StringPlayer)) and (Port==808u16) and IP=192.168.22.21) then \\
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]