rfbcRawSend (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Firmware version:

2.86 (3.10: wait) / 1.51.00


This function will send a raw RFBC packet.

If a destination address is given an acknowledgment is expected to be received.

If no destination address is given the function simply returns without waiting for an acknowledge.

 

Input:

id  : DINT [0 .. 16_777_215] (default 0)

ID of the device the request is sent to.

0 = Broadcast notification to all listening devices.

 

number : INT [-1,0 .. 255] (default -1)

This sets the current packet number.

If "-1", then last packet number +1 will be used.

 

flags    : INT [0 .. 255] (default 0)

Packet flags.

 

type     : INT [0 .. 255] (default 0)

Packet message type.

 

datasize : INT [0 .. 54]

Size of data.

 

data : PTR

Address of the memory block that will be sent as a payload.

 

wait : BOOL [TRUE, FALSE] (default TRUE)

Wait for acknowledgment of reception, if set to FALSE then the function will return without waiting for an acknowledgment after transmitting the packet once.

 

Output:

None.

 

Returns: INT

0

-

Success.

-1

-

Interface is not open (see rfbcOpen).

-4

-

RF communication is not available.

-5

-

Communication error - addressed message sent but no acknowledgment received.

-6

-

Error in parameter.

 

Declaration:

FUNCTION rfbcRawSend : INT;
VAR_INPUT
   id        DINT := 0;
   number    : DINT := -1;
   flags     : INT  := 0;
   type      : INT  := 0;
   datasize  INT;
   data      : PTR;
   wait      : BOOL := TRUE;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR_INPUT
   send     : BOOL R_EDGE;
END_VAR;
 
PROGRAM example;
VAR
  data  ARRAY[1..54OF SINT;
  msg   STRING := "Hello world!";
END_VAR;
 
BEGIN
  IF send THEN
    // Copy contents of a string to memory
    strToMemory(dst:=ADDR(data), str:=msglen:=strLen(str:=msg));
    // Broadcast the message as a raw packet
    rfbcRawSend(data:=ADDR(data), datasize:=strLen(str:=msg));
  END_IF;
  ...
END;
END_PROGRAM;