gwReceivePacket (Functionblock) |
Top Previous Next |
This function block can be used to check if there is an incoming data packet from the RTCU Communication Hub. Please also see gwPacketMode for the operating mode used when receiving a packet.
Note: if more data is received than the receive buffer can hold, the remaining data is lost.
When Large Packet Support (LPS) is enabled, packets with up to 4064 bytes can be received. (See function overview for more more information about LPS) Use the gwPacketSize function to determine the maximum size of a packet that can be received from a sender.
Input: buffer : PTR The address of the receive buffer.
maxlength : INT (1..4064) Maximum size of the data to be received (max 4064 bytes).
Output: sender : DINT NODE ID of sending node (0=no data available or invalid parameters).
length : INT Length of data received (max 4064 bytes) (0=no data available or invalid parameters).
Declaration: FUNCTION_BLOCK gwReceivePacket;
Example: INCLUDE rtcu.inc incoming : gwReceivePacket; Buf_out : ARRAY [1..4064] OF SINT; size : INT; // 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; ... |