rchPacketMode (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Firmware version:

2.10 / 1.00.00


This function changes the mode for handling data packets received with rchReceivePacket.

This function works similarly to gwPacketMode.

There are two modes:

 

Buffered mode (default)

rchSendPacket sends the data and waits for a reply from the receiver.

The data packet received is placed into an internal buffer in control of the firmware. A reply is automatically returned to the sender.

rchReceivePacket will fetch the data from the internal buffer and release it for new packets.

rchReceivePacketDone will do nothing and is therefore not necessary to call.

 

 

rchPacketMode_buffered

 

 

 

Unbuffered mode

 

rchSendPacket sends the data and waits for a reply from the receiver.

The data packet is placed directly into the applications buffer, and a reply is not automatically sent back to the sender.

rchReceivePacket will deliver the data packet to the application.

rchReceivePacketDone will send a user-defined reply back to the sender.

 

rchPacketMode_unbuffered

 

 

Input:

mode : SINT (0/1) (Default 0)

The data packet receiver mode.

0

- Buffered mode.

1

- Unbuffered mode.

 

Returns: INT

0

- Success.

1

- Invalid parameter.

 

Declaration:

FUNCTION rchPacketMode : INT;
VAR_INPUT
   mode : SINT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
   incoming : rchReceivePacket;
   buffer   : ARRAY[1..480] OF SINT;
END_VAR;
 
// Set address BEFORE the 'incoming' is called the first time!
incoming.buffer    := ADDR(buffer);
incoming.maxlength := SIZEOF(buffer);
 
// Turn on power to the GSM module
gsmPower(power := TRUE);
netOpen(iface:=1);
rchPacketMode(mode := 1);
 
BEGIN
   ...
   // Check for incoming packets
   incoming();
   IF incoming.sender > 0 THEN
      // A packet is received
      ...
      rchReceivePacketDone(reply := 128);
   END_IF;
   ...
END;
END_PROGRAM;