Tcp_Recv Instruction - Siemens SIMATIC S7 System Manual

Hide thumbs Also See for SIMATIC S7:
Table of Contents

Advertisement

9.4.2.5

TCP_RECV instruction

The TCP_RECV instruction retrieves data over an existing connection. You use this
instruction for both TCP protocol and ISO-on-TCP protocol.
LAD/FBD
STL
TCP_RECV ConnID, MaxLen,
DataPtr, Done, Busy, Er-
ror, Status, Length
The TCP_RECV instruction only has an EN (Enable) input. The TCP_RECV instruction has
no Req (Request) input. After the first execution of the TCP_RECV instruction, the status bits
show the instruction is busy. Subsequent calls to TCP_RECV show a busy status until the
CPU receives data on the specified connection.
After the CPU receives a message on the specified connection, the next execution of the
TCP_RECV instruction performs the following tasks:
● Copies the message data to your program's data area (DataPtr)
● Sets the Length output to the number of bytes received
● Sets the Done output, clears the Busy and Error outputs, and sets the Status output byte
value to zero (no error)
You should assign the receive area/buffer (DataPtr) and the maximum length of the receive
buffer (MaxLen) so there is no possibility of a buffer overrun. If the CPU receives more bytes
than can fit into your program's buffer (as specified by MaxLen), the TCP_RECV instruction
copies MaxLen bytes to your program's data area and discards the rest of the received
bytes. In this situation, the instruction sets the Error output and the Status output byte
displays error code 25, which means the receive buffer is too small.
The maximum amount of data that you can receive in one message is 1024 bytes. The
TCP_RECV instruction always operates in a mode that allows receipt of messages of
varying lengths.
The TCP_RECV instruction operates differently depending on the protocol used. You
selected the protocol for the connection when you called either TCP_CONNECT (TCP
protocol) or ISO_CONNECT (ISO-on-TCP protocol) to create the connection.
Using TCP protocol, the TCP_RECV instruction returns all the bytes received by the
S7-200 SMART CPU on the specified connection since the last time your program called the
TCP_RECV instruction. Your program must call the TCP_RECV instruction often enough to
delineate the messages properly because TCP acts as a "streaming" protocol. There is no
delineation of the messages (no begin or end markers) in TCP protocol. Therefore, the CPU
does not know when messages start or end.
S7-200 SMART
System Manual, V2.3, 07/2017, A5E03822230-AF
Description
The TCP_RECV retrieves data over an existing connection.
9.4 Open user communication library
Libraries
513

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic s7-200 smart

Table of Contents