Commands and functions
P.
230 of 349
KNX-Telegram-Routing
Address
Readknx
With help of the functions
address
and
readknx
the Enertex® EibPC can used as an free
programmable router for KNX
TM
telegrams. If e.g. the group address is sent (as number) to the
Enertex® EibPC via TCP/IP client, it is possible to write via the function
address
to this group
address a given value, without any additional program code. Similar an incoming KNX
TM
telegram will
be signaled by the
readknx
function to the TCP/IP client. The Opensource project "EibPC-
Homecontrol" uses this functionality. The function
address
can be used as first argument instead of
the group address in the functions:
event
,
write
,
scene
et cetera.
This function generates a group address from a u16 number to be used when accessing the bus.
Definition
●
Function
address
(
variable
)
Arguments
●
1 argument of data type u16
Effect
●
Return value: A group address as it can be used with
write
,
read
etc..
Data type result (Return)
●
Data type group address
As a particular feature of the bus access functions, they expect group addresses as arguments.
E.g. the 1st argument of
write
(
'5/3/11'b01, ON
) has to be a group address. The function
address
converts a u16
number into a group address. This number is calculated as address= [main group] x 2048+[middle group] x 256 +
[subgroup], with [main group]=5, [middle group]=3 and [subgroup]=11 for the example
'5/3/11'
. You have to calculate
this number by yourself or you can use the function
getaddress.
Example: address
You want to write ON to group address
'5/3/11'b01
at system startup.
Implementation in the user program:
if systemstart() then write(address(11019u16),ON) endif
Definition
●
Function
readknx
(
Number
,
Output
)
Arguments
●
Number
of data type u16
●
Output
of data type c1400
Effect
●
An incoming KNX
TM
telegram will make the function wriingt the group address of the
telegram in the variable named
Number
. The binary data of the telegram is stored in the
variable named
Output
.
Output
is changing its type to that of the last incoming telegramm
To convert it back, use
convert
as shown in the example.
Data type result (Return)
●
Result of the conversion of the KNX
TM
telegrams binary data
Note:
The function
event
can used with
readknx
function (see example).
Example: Sending all incoming KNX
TM
telegrams via UDP:
Following code will send all telegrams received from the KNX
TM
bus via UDP to the client with
the IP 192.168.22.199. The group address of the telegram is sent in u16 format and the
information as a string in the format GA:XXXXX INF:YYYYYYY .
adr=0u16
info=$$
if event(readknx(adr,info)) then {
sendudp (5000u16, 192.168.22.199,$GA:$+convert(adr,$$)+$INF:$+info)
}endif
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]