This function will return details about the last raw event received which matches the filter set by rfbcRawFilter.
To get the ID of the sender related to the event, please call rfbcWaitEvent before this function.
Input:
datasize : INT [0 .. 54]
Maximum size to load into "data".
data : ADR
Address of the memory block that receives the payload.
Output:
length : INT;
Length of payload loaded into "data".
number : INT;
Packet count number.
flags : INT;
Packet flags.
type : INT;
Packet message type.
Returns: INT
0
|
-
|
Ok. Event cleared.
|
-1
|
-
|
Interface is not open (see rfbcOpen).
|
-4
|
-
|
RF is communication not available.
|
-5
|
-
|
Event is not present.
|
Declaration:
FUNCTION rfbcRawEventReceive : INT;
VAR_INPUT
datasize : INT;
data : PTR;
length : ACCESS INT;
number : ACCESS INT;
flags : ACCESS INT;
type : ACCESS INT;
END_VAR;
Example:
INCLUDE rtcu.inc
FUNCTIONGetRawEvent;
VAR_INPUT
id:DINT;
END_VAR
VAR
data:ARRAY[1..100]OFSINT;
length:INT;
number:INT;
flags:INT;
type:INT;
rc:INT;
END_VAR
rfbcRawEventReceive(
datasize:= SIZEOF(data),
data:=ADDR(data),
length:=length,
number:=number,
flags:=flags,
type:=type);
DebugFmtmessage:= "Received a message from \4", v4:=id);
DebugFmtmessage:= " Message type = \1", v1:=type);
DebugFmtmessage:= " Message flags = \1", v1 :=flags);
DebugFmtmessage:= " Message number = \1", v1 :=number);
DebugFmtmessage:= " Message length = \1", v1:=length);
DebugFmtmessage:= " Message = " + strFromMemory(src:=ADDR(data),len:=length));
END_FUNCTION
THREAD_BLOCK rfbcMonitor;
VAR
event : INT := 0;
hisId : DINT;
broadcast : BOOL;
END_VAR;
WHILE event <> -1 DO
event := rfbcWaitEvent(timeout := -1, id := hisId, broadcast := broadcast);
CASE event OF
...
100 :
IF NOT broadcast THEN rfbcSendAck(); END_IF;
GetRawEvent(id := hisId);
...
ELSE
DebugFmt(message := "rfbcWaitEvent - event=\1", v1 := event);
END_CASE;
END_WHILE;
END_THREAD_BLOCK;
|