gwPacketMode (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

2.10 / 1.00.00


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

There are two modes:

 

Buffered mode (default)

gwSendPacket 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.

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

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

 

 

gwPacketMode_buffered

 

 

 

Unbuffered mode

 

gwSendPacket 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.

gwReceivePacket will deliver the data packet to the application.

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

 

gwPacketMode_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 gwPacketMode : INT;
VAR_INPUT
  mode : SINT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  incoming : gwReceivePacket;
  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);
gprsOpen();
gwPacketMode(mode := 1);
 
BEGIN
  ...
  // Check for incoming packets
  incoming();
  IF incoming.sender > 0 THEN
     // A packet is received
     ...
    gwReceivePacketDone(reply := 128);
  END_IF;
  ...
END;
END_PROGRAM;