AG_LRECV FC60 Maximum Buffer Size for S7-300/S7-400 Industrial

David Krause12 min read
Industrial NetworkingSiemensTechnical Reference
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

AG_LRECV (FC60) on SIMATIC S7-300/S7-400: Maximum Receive Buffer Size, Protocols, and Status Codes

The AG_LRECV function block, implemented as FC60 in the SIMATIC S7-300 / S7-400 library for SIMATIC NET Industrial Ethernet CPs, is the standard open-communication receive interface for jobs routed through CP 343-1 / CP 443-1 modules. Engineers who integrate legacy hosts (VAX, RS/6000, AS/400, custom Unix servers) frequently exceed the receive buffer because the limit is protocol-dependent, not block-dependent. This reference consolidates the protocol-specific maximum payload, buffer transfer semantics, the FC50/FC60 pairing, status-code matrix, and configuration paths in STEP 7 V5.x and TIA Portal V21.

1. AG_LRECV Function Block Overview

AG_LRECV is part of the SIMATIC NET "Open Communication Services" block family for the SIMATIC S7-300 and S7-400 PLC families. It is delivered in the standard library and operates in conjunction with an Industrial Ethernet CP (e.g. CP 343-1, CP 343-1 Lean, CP 343-1 Advanced, CP 443-1, CP 443-1 Advanced). The CPU calls FC60 in the user program (OB1 cycle or a dedicated watchdog OB), and the CP returns the received data through the configured job interface.

AG_LRECV supports three transport protocols on Industrial Ethernet:

  • TCP (native RFC 793, raw socket)
  • ISO Transport (ISO 8073 / TP4 over Ethernet, OSI layer 4)
  • ISO-on-TCP (RFC 1006, the SIMATIC default for S7 communication)
  • UDP (RFC 768, connectionless datagrams)

Refer to the official TIA Portal V21 documentation for the AG_LRECV parameter description.

2. Protocol-Specific Maximum Buffer Limits

The maximum number of bytes that can be passed through the RECV parameter of AG_LRECV depends entirely on the transport protocol negotiated at the configured connection. The limits are not enforced by the FC60 block itself but by the CP firmware when the receive job is dispatched.

Protocol Max RECV bytes (decimal) Max RECV bytes (hex) Connection Type
ISO Transport 8192 0x2000 Connection-oriented, OSI layer 4
TCP 8192 0x2000 Stream-oriented, RFC 793
ISO-on-TCP (RFC 1006) 8192 0x2000 Default S7 open comms
UDP 2048 0x0800 Connectionless datagram
Engineering implication: If the configured connection uses UDP and the user passes a RECV length greater than 2048 bytes, the CP will truncate, return a status error (typically 0x8085 / 0x8187 depending on firmware), or reject the job entirely. If the connection uses TCP/ISO/ISO-on-TCP, the limit is 8192 bytes per receive call. A user value of 2602 bytes is valid only on a TCP-family connection; on UDP the maximum must be reduced to 2048.

For Profibus variants of AG_LRECV (FC60 over a Profibus CP), the limits are tighter and depend on the Profibus CP used; the Industrial Ethernet numbers above do not apply to Profibus. Always verify against the Profibus CP-specific indications when deploying over PB.

3. FC50 (AG_SEND) vs FC60 (AG_LRECV) Pairing

Open Communication Services on S7-300/S7-400 are symmetric: FC50 (AG_SEND) transmits a buffer to the partner, and FC60 (AG_LRECV) accepts the partner's transmission. Both blocks are tied to the same configured connection ID. The relevant Siemens KB article for programming the pair is "How do you program the communication blocks FC50 and FC60?".

Property FC50 AG_SEND FC60 AG_LRECV
Direction PLC → Partner Partner → PLC
Data parameter SEND (any) RECV (any)
Length parameter LEN LEN
Job status output DONE, ERROR, STATUS DONE, ERROR, STATUS, LEN
CP type Ind. Ethernet, Profibus Ind. Ethernet, Profibus
Library SIMATIC NET CP → "Open Communication" SIMATIC NET CP → "Open Communication"

Both blocks must use the same ID and LADDR (logical base address of the CP). Mismatching these two parameters is the most common source of 0x8180 ("no data yet available") status returns on otherwise-healthy connections.

4. Industrial Ethernet CP Compatibility

AG_LRECV (FC60) is supported on the following CP families as of firmware listed:

CP Module Family Min. firmware for full 8 KB RECV
CP 343-1 (6GK7 343-1EX30) S7-300 V2.0 (8192 byte cap; older V1.x = 4000)
CP 343-1 Lean (6GK7 343-1CX10) S7-300 V1.0 (240 byte hard cap on Lean!)
CP 343-1 Advanced (6GK7 343-1GX31) S7-300 V3.0 (8192 bytes)
CP 443-1 (6GK7 443-1EX30) S7-400 V2.0 (8192 bytes)
CP 443-1 Advanced (6GK7 443-1GX31) S7-400 V3.0 (8192 bytes)
CP 443-1 IT S7-400 Limited; consult firmware release notes
Hard cap on CP 343-1 Lean: The Lean variant has a 240-byte upper limit on SEND/RECV regardless of the protocol, even though the open-communication architecture is identical to the full CP 343-1. Plan payload sizing accordingly; if the VAX host pushes 2602 bytes the Lean CP will reject the job.

5. TCP Buffer Transfer Behavior

A critical field-engineering detail is that for TCP (and ISO-on-TCP) connections, the receive buffer is only delivered to the CPU when the buffer is completely filled. This is a direct consequence of how the CP implements TCP framing: the CP cannot know whether the partner has finished transmitting until either the partner closes the segment or the configured receive buffer reaches its length limit.

Practical consequences:

  1. If the partner sends fewer bytes than the configured LEN, AG_LRECV will remain in the "waiting" state (status 0x8180 "no data yet available") until either the buffer fills or a partner-initiated close is detected.
  2. If variable-length messages are expected, size the buffer for the largest expected message — or switch to UDP and rebuild framing at the application layer.
  3. If the partner always closes the segment after writing (graceful shutdown of each TCP send), the partial buffer is delivered immediately.
  4. Streaming payloads (e.g. 16 KB split across many smaller bursts) will not deliver until either the configured LEN is reached or a segment FIN is observed.

UDP does not have this behavior — every datagram is delivered as soon as it arrives, regardless of length. UDP's only constraint is the 2048-byte datagram ceiling.

6. AG_LRECV Interface Definition

The formal interface of FC60 in STEP 7 V5.x and TIA Portal V21 (industrial Ethernet variant):

Parameter Declaration Type Description
ID INPUT INT Connection ID from NetPro / "Connections" editor
LADDR INPUT WORD Logical base address of the CP (e.g. W#16#0100)
RECV IN_OUT ANY Pointer to receive buffer (DB or bit-memory area)
NDR OUTPUT BOOL TRUE = new data received (single-cycle pulse)
ERROR OUTPUT BOOL TRUE = error occurred
STATUS OUTPUT WORD Detailed status / error code
LEN OUTPUT INT Length of data actually received (bytes)

The RECV ANY pointer must reference an area large enough to hold the configured LEN; if the ANY pointer specifies a smaller area, the CP will report a length-mismatch error. For example, with a TCP connection and a 8192-byte buffer, declare RECV as P#DB100.DBX0.0 BYTE 8192.

7. Status and Error Codes

The STATUS output of FC60 follows the standard SIMATIC NET error class scheme. Common values:

STATUS (hex) Meaning Recommended action
0x0000 No error, no new data Continue polling
0x0001 NDR implicit — new data received, see LEN Process LEN bytes
0x7000 Job active, no completion yet Continue polling
0x8180 No data yet available (connection not yet set up OR no data on wire) Verify NetPro connection; check CP online diagnostics
0x8183 Connection not configured / wrong ID-LADDR pair Re-check NetPro / TIA connection table
0x8184 Connection being established Wait for establishment
0x8185 Connection already being terminated Reset job and reconnect
0x8187 Resources exhausted (job busy) Wait for previous job completion
0x8188 LEN exceeds protocol maximum (e.g. UDP > 2048) Reduce LEN to protocol cap
0x8085 RECV buffer too small for received data Increase ANY length
0x80A3 Connection terminated by partner Re-establish via AG_CONNECT or CP

Siemens KB article "Possible status value of the block FC 60 (AG_LRECV) in the S7-300 with connection not set up" documents the special case where 0x8180 is returned when the CP has no active connection for the configured ID. This is distinguishable from "no data on wire" only by examining CP online diagnostics (NCM diagnostics > "Connections").

8. STEP 7 Classic Configuration (V5.x)

For S7-300 / S7-400 deployments on STEP 7 V5.5 / V5.6:

  1. Insert the SIMATIC NET CP into the hardware configuration (e.g. CP 343-1 / 6GK7 343-1EX30-0XE0). Note the CP's logical base address (default W#16#0100 on slot 4 for S7-300).
  2. Open NetPro and add a new "Open Communication" connection on the CP. Choose the transport protocol (TCP / ISO Transport / ISO-on-TCP / UDP).
  3. For TCP/ISO-on-TCP, configure the partner IP address and port. For UDP, configure the partner IP/port pair but note the connection is still "configured" in NetPro (it just uses datagrams).
  4. Save and download the connection configuration to the CP.
  5. Insert FC60 (AG_LRECV) from the library: Standard Library > Communication Blocks > Open Communication (or the renamed "SIMATIC NET CP" library depending on installation).
  6. Wire the ID and LADDR parameters from NetPro into the FC60 instance.
  7. Call FC60 in OB1 (or a faster OB for low-latency polling).

9. TIA Portal Configuration (V21)

On TIA Portal V21, the equivalent procedure:

  1. Add the CP in the Device Configuration; configure its Ethernet port and assign an IP address.
  2. Open Devices & Networks and switch to the "Connections" view.
  3. Right-click the CP → "New Connection" → choose "Open User Communication" → TCP / ISO-on-TCP / UDP / ISO Transport as required.
  4. Set the connection name, partner IP, and partner port. Save and download.
  5. Drag the AG_LRECV (FC60) instance from the Open Communication program blocks into the user code; assign ID and LADDR from the connection properties.

Refer to the official TIA Portal V21 AG_LRECV documentation for the V21-specific behavior and parameter mapping.

10. STL and SCL Programming Examples

STL (Statement List) for OB1 cycle call

// AG_LRECV (FC60) call example — TCP, 8192-byte max
// Inputs prepared from NetPro connection
      CALL FC60
       ID     := 1                 // Connection ID from NetPro
       LADDR  := W#16#0100         // CP logical base address
       RECV   := P#DB100.DBX0.0 BYTE 8192  // Receive buffer
       NDR    := M100.0            // New-data-received pulse
       ERROR  := M100.1            // Error flag
       STATUS := MW102             // Status word
       LEN    := MW104             // Actual received length

// Edge evaluation
      A   M 100.0
      JCN no_new
      // Process LEN bytes from DB100 starting at offset 0
no_new: NOP 0

SCL (Structured Control Language)

// AG_LRECV call in SCL
IF "first_scan" THEN
  // Initialize trigger
  recv_trigger := TRUE;
END_IF;

IF recv_trigger THEN
  AG_LRECV(
    ID     := 1,
    LADDR  := W#16#0100,
    RECV   := P#DB100.DBX0.0 BYTE 8192,
    NDR    => ndr_flag,
    ERROR  => err_flag,
    STATUS => status_word,
    LEN    => recv_len
  );
END_IF;

IF ndr_flag THEN
  // Process recv_len bytes in DB100
  "ProcessBuffer"(len := recv_len);
END_IF;

IF err_flag THEN
  "LogStatus"(code := status_word);
END_IF;

11. Troubleshooting Matrix

Symptom STATUS Likely root cause Remediation
No data ever delivered, NDR never true 0x8180 Connection not established OR partner not transmitting Verify NetPro connection, CP online diagnostics, partner firewall
No data delivered, NDR true occasionally but LEN < expected 0x0001 / 0x8180 toggling TCP buffer-not-full behavior Increase LEN to expected message max, or switch to UDP
No data delivered, partner writes 2602 bytes 0x8188 UDP connection with LEN > 2048 Reduce LEN to 2048 or migrate to TCP/ISO-on-TCP
ERROR = TRUE immediately 0x8183 ID-LADDR mismatch Re-check NetPro IDs and CP base address
First call works, second call hangs 0x8187 Job never re-triggered AG_LRECV must be called continuously; not edge-triggered
CP reports resource error 0x8187 Multiple parallel jobs on same ID Use one AG_LRECV per connection, sequential
VAX / third-party sends, FC60 never fires 0x8184 Connection establishment pending Establish via partner connect first
Data arrives but truncated 0x8085 RECV ANY length < actual data Increase ANY length to ≥ LEN
Intermittent 0x80A3 0x80A3 Partner keeps closing TCP Disable keepalive on partner, or implement keepalive on CP

12. Best Practices for Third-Party Hosts (VAX, RS/6000, Legacy Unix)

Integrating Siemens AG_LRECV with non-Siemens partners such as a VAX/VMS host requires strict attention to protocol semantics:

  1. Prefer ISO-on-TCP (RFC 1006) over native TCP for legacy hosts. ISO-on-TCP carries explicit length prefixes that eliminate the "TCP buffer-not-full" stall documented in Section 5. Configure the partner to write TSAP + data + length per the SIMATIC framing rules.
  2. If native TCP must be used, size the buffer to the largest possible message and configure the partner to close the write side after each message (TCP half-close / shutdown(SHUT_WR)). Otherwise data will sit in the CP until either the partner closes the entire socket or the buffer overflows.
  3. For UDP integrations, keep each datagram ≤ 2048 bytes. Fragment larger messages at the application layer using an explicit sequence-number header.
  4. Validate RECV ANY size at compile time — declare the receive buffer DB with sufficient length before downloading; a runtime ANY-mismatch surfaces only when the first long message arrives.
  5. Poll continuously. AG_LRECV is not edge-triggered; the same call must execute every OB1 cycle (or every cycle of the chosen watchdog OB) for the CP to deliver data promptly.
  6. Use connection diagnostics in NCM Diagnostics (STEP 7 V5) or Online & Diagnostics (TIA Portal) to distinguish "no data on wire" from "connection not established."
  7. Watch the CP firmware version. Pre-V2.0 CP 343-1 modules cap at 4000 bytes; CP 343-1 Lean caps at 240 bytes. If the VAX side sends 2602 bytes the Lean CP is incapable regardless of protocol choice.
Safety note: For safety-related communication (PROFIsafe, F-CPU), AG_LRECV / AG_SEND are not permitted. Use PROFIsafe over PROFINET or PROFIBUS only.

Frequently Asked Questions

What is the maximum number of bytes AG_LRECV can receive on a TCP / ISO Transport / ISO-on-TCP connection?

Up to 8192 bytes per call on CP 343-1 (firmware V2.0 or later), CP 343-1 Advanced, CP 443-1, and CP 443-1 Advanced. Older CP 343-1 V1.x firmware caps at 4000 bytes; CP 343-1 Lean caps at 240 bytes regardless of firmware.

What is the maximum AG_LRECV buffer size for UDP?

2048 bytes. Larger RECV pointers will return STATUS = 0x8188 on most CP firmware versions. UDP also delivers datagrams immediately upon arrival, unlike TCP.

Why does AG_LRECV never trigger NDR even though the partner is sending data?

On TCP/ISO-on-TCP the CP only delivers the buffer once it is fully filled or the partner half-closes the connection. Either increase the configured LEN to the largest expected message, switch to ISO-on-TCP with explicit framing, or have the partner call shutdown(SHUT_WR) after each write. Status 0x8180 in this case means "no data yet available," not "connection failed."

Can I use AG_LRECV on Profibus CPs with the same 8192-byte limit?

No. Profibus CPs use a different FC60 variant with protocol-specific limits that are smaller and depend on the Profibus CP type. Always consult the Profibus CP AG_LRECV documentation for your specific CP.

What does STATUS 0x8180 mean and how do I differentiate "no data" from "no connection"?

STATUS 0x8180 means "no data yet available." If the connection is not yet established (e.g. partner has not connected or NetPro download is missing), the same code is returned. To differentiate, open CP Online & Diagnostics and inspect the connection state; an unestablished connection will show no active link under the configured ID. See the Siemens KB 2539712 for details.

Is AG_LRECV polled or edge-triggered?

AG_LRECV (FC60) must be called continuously every cycle of OB1 or the chosen watchdog OB. It is not edge-triggered. Calling it on a rising edge of a flag will cause the first call to start the job and the subsequent calls to issue no new jobs — the partner's data will then sit in the CP buffer until the next edge fires. Continuous polling is required.

Back to blog