gwPacketSize (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

4.40 / 1.00.00


This function is a part of the Large Packet Support (LPS), and will return the maximum size of a packet that can be sent/received from a peer node connected to the RTCU Communication Hub.

 
Using this function it is possible to determine the maximum size of data that can be sent/received using gwSendPacket and gwReceivePacket.

 
Calling this function may submit a request to the RTCU Communication Hub to get the information on the peer node data size.

It is therefore recommended that this function is only called once for each peer node.

 

The function requires that the device is connected to the RTCU Communication Hub.

 

 

Input:        

nodeid : DINT

The NODE ID of the node.

 

Returns: INT

The maximum number of bytes that can be send to, or received from, the specified node.

 

Declaration:

FUNCTION gwPacketSize : INT;
VAR_INPUT
  nodeid : DINT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR

  incoming : gwReceivePacket;
  Buf_in : ARRAY [1..4064] OF SINT;

  Buf_out : ARRAY [1..4064] OF SINT;

  size     : INT;
END_VAR;
 
gsmPower(power := TRUE);
gprsOpen();
 

// Wait for hub connection

WHILE NOT gwConnected() DO

  Sleep(delay := 2000);

END_WHILE;

 

// Determine the maximum size to send

size := gwPacketSize(nodeid := 2000);

IF size = 0 THEN

  size := 480;

END_IF;

 
// Set address BEFORE the 'incoming' is called the first time!
incoming.buffer   := ADDR(Buf_in);
incoming.maxlength := size;

 
BEGIN

  ...
  // Check for incoming packets
  incoming();
  IF incoming.sender > 0 THEN
     // A packet is received
     ...
  END_IF;
  ...
  gwSendPacket(receiver := 2000, buffer := ADDR(Buf_out), length := size);
  ...
END;
END_PROGRAM;