Libraries
9.4 Open user communication library
S7-200 SMART
System Manual, V2.3, 07/2017, A5E03822230-AF
513
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
Description
TCP_RECV ConnID, MaxLen,
DataPtr, Done, Busy, Er-
ror, Status, Length
The TCP_RECV retrieves data over an existing connection.
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.
Содержание SIMATIC S7-200
Страница 30: ...Product overview 1 7 Programming software S7 200 SMART 30 System Manual V2 3 07 2017 A5E03822230 AF ...
Страница 267: ...Program instructions 7 6 Counters S7 200 SMART System Manual V2 3 07 2017 A5E03822230 AF 267 HSC modes 3 and 4 ...
Страница 394: ...Program instructions 7 18 Subroutine S7 200 SMART 394 System Manual V2 3 07 2017 A5E03822230 AF ...
Страница 425: ...Communication 8 5 PROFIBUS S7 200 SMART System Manual V2 3 07 2017 A5E03822230 AF 425 ...
Страница 786: ...Technical specifications A 11 S7 200 SMART cables S7 200 SMART 786 System Manual V2 3 07 2017 A5E03822230 AF ...
Страница 798: ...Error codes C 4 PLC fatal error codes S7 200 SMART 798 System Manual V2 3 07 2017 A5E03822230 AF ...
Страница 848: ...Ordering information F 6 Human Machine Interface devices S7 200 SMART 848 System Manual V2 3 07 2017 A5E03822230 AF ...