Programming for experts
P.
124 of 349
Writing to internal queues
Write a telegram
Write to RS232 or UDP
Write to the flash
Asynchronous processing
If the internal queues are used ,e.g. if writing to the bus, the validation scheme is handling these quees at the end of
a complete data processing for the desired output:
[EibPC]
c='1/2/3'u08
b=1
if systemstart() then {
write('1/2/3'u08,b);
b=2
} endif
In this example
write
is executed . The data is processed in the queue after all other objects are valid. This means,
b
equals to 2. Therefore the value 2 is sent to 1/2/3.
The same holds true for a queue to IP telegrams (UDP, TCP/IP) and RS232 telegrams:
[EibPC]
b=1
s=$Hello$
if systemstart() then {
if b==1 then {
sendudp(4809u16,192.168.22.1,s);
s=$World$;
b=2
} else {
sendudp(4809u16,192.168.22.1,s)
} endif
} endif
In this case (see the examples before) the string
World
is sent twice. Again, the queue is processed after all objects
are valid.
The same holds true for reading and writing to the flash and writng to strings with
stringset
.
[EibPC]
b=1
s=$$
if systemstart() then {
stringset(s,b,0u16);
writeflash(b,0u16);
b=b+1
} endif
First,
b
is incremented by 1, and therefore both
s
and the writeflash-queue both work with b equals 2.
For some function calls (such as creating a TCP connection) it can not be guaranteed that they will update their
return value within a processing loop of the EibPC. Therefore, these functions were implemented as separate threads
within the firmware. These threads update their return values according to their own processing and is asynchronous
to the main development loop. Consider the following example:
[EibPC]
// TCP off == 5
TCP=5
if after(systemstart(),2000u64) then {
TCP=connecttcp(233u16,192.168.2.100)
} endif
2 seconds after start-up,
connectcp
is called. Since the processing now starts the appropriate thread, the return value
is initially 0 (connection is set up) and leaves the if-Statement. Some time after the connection initializing, the
connecttcp
will update the variable TCP - regardless of the if statement - to 1 (connected).
Similarly, the return values of functions
resolve
,
readflash, ping, writeflash
and
sendmail
are asynchronous
processing functions.
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]