rfbcRawEventReceive (Function)

Top  Previous  Next

Architecture:

X32 / NX32L

Device support:

AX9 pro, CX1 pro/pro-c/warp/warp-c, SX1, AX9 turbo, NX-900, LX5

Firmware version:

2.86 / 1.51.00


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
 
//-----------------------------------------------------------------------------
// FUNCTION GetRawEvent
//-----------------------------------------------------------------------------
FUNCTION GetRawEvent;
VAR_INPUT
  id       : DINT;
END_VAR;
VAR
  data     : ARRAY[1..100] OF SINT;
  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);
 
DebugFmt(message := "Received a message from \4", v4 := id);
DebugFmt(message := "  Message type   = \1", v1 := type);
DebugFmt(message := "  Message flags  = \1", v1 := flags);
DebugFmt(message := "  Message number = \1", v1 := number);
DebugFmt(message := "  Message length = \1", v1 := length);
DebugFmt(message := "  Message = " + strFromMemory(src := ADDR(data), len := length));
END_FUNCTION;
 
//-----------------------------------------------------------------------------
// THREAD_BLOCK rfbcMonitor
//-----------------------------------------------------------------------------
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;