Program instructions
7.3 Communication
S7-200 SMART
224
System Manual, V2.3, 07/2017, A5E03822230-AF
The maximum amount of data that you can receive in one message is 1024 bytes. Because
TCP acts as a "streaming" protocol, the program can collect multiple messages in one
receive message if the TRECV instruction is not called frequently. The UDP and ISO-on-
TCP protocols guarantee that each message is delineated as a separate message.
For example, let us suppose that there is a TCP client that sends four 20-byte messages to
the S7-200 SMART in rapid succession, and your program is not calling the TRECV
instruction. If your program calls the TRECV instruction after all four messages have been
accepted by the CPU, the program sees this as one receive message of 80 bytes. Your
program is responsible for calling the TRECV instruction as often as needed to receive each
message as it is sent.
Assuming the same client and the same messages as in the above example, ISO-on-TCP
and UDP delivers the four messages during four subsequent calls to the TRECV instruction.
These protocols delineate the messages and keep them separate in the CPU until your
program calls the TRECV instruction to retrieve them.
If the CPU receives more bytes than will fit into the user buffer, the TRECV instruction copies
in the maximum number of bytes allowed (Data Length in the table) and discards the rest of
the received bytes. In this situation, the TRECV instruction completes with an error to tell the
user that bytes were discarded.
TSEND and TRECV instruction tables
The following tables contain the format and definitions for the TSEND and TRECV
instructions. Refer to "OUC instruction error codes" (Page 228) for the error code listing.
Refer to "Ports and TSAPs" (Page 419) for port number restrictions and further information:
●
Status: The first byte of the table returns the status of the operation to the user. The OUC
instructions ignore the value of the status byte as an input. The status byte is valid on the
return of the instruction. These are the status bit definitions:
–
D = Done (Complete)
–
A = Active (In progress, in other words, Busy)
–
E = Error (Complete with error)
–
Error Code
If there is an error, the Done and Error bits are both set. The error codes are listed in
"OUC instruction error codes" (Page 228).
●
REQ: You use the REQ bit to initiate a new operation. The REQ bit is a level-triggered
value. Your program code must provide the one shot operation if required (a positive
edge contact). If the operation is not busy, a REQ value of TRUE initiates a new
operation. For example, if there is not currently a TSEND instruction in progress, a TRUE
value in the REQ bit causes the program to initiate a new TSEND instruction operation.
●
Connection ID: The Connection ID is a 16-bit value that you select to pass into the
function. The range is 0 to 65534 (65535 is reserved). The Connection ID parameter is an
input to the OUC instructions. The TSEND, TRECV, and TDCON instructions use the
Connection ID that you select for the TCON instruction as a reference.