Resolving S7-300 TCON Error 877F: Open TCP with CP343-1

David Krause13 min read
S7-300SiemensTroubleshooting
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

Resolving S7-300 TCON Error 877F: Open TCP Communication with CP343-1

Field engineers commissioning Open TCP between a CPU315-2PN/DP and a CPU314 (paired with a CP343-1) frequently hit a hard stop at the CONNECT input of the S7-300 Open Communication FBs. The most common symptom is status code W#16#877F at FB65 TCON, followed (once the pointer is corrected) by W#16#80C4 at FB63 TSEND on the active side and W#16#8183 at FC5 AG_SEND on the CP side. This reference documents the root cause of 877F, the correct 64-byte CONNECT ANY-pointer layout, the active/passive connection-establishment rules, the NetPro/Open Communication Wizard parameter mapping, and the diagnostic ladder to clear the cascading 80C4/8183 status codes once the connection is initiated.

Applies to: CPU315-2PN/DP (6ES7315-2EH13-0AB0, firmware V2.6) and CPU314 (6ES7314-1AG13-0AB0, firmware V2.6.4) with CP343-1 (6GK7343-1EX21-0XE0, firmware V1.2) configured with STEP 7 V5.5 and the "Open Communication Wizard" (OCWizard). The same 877F root cause and ANY-pointer fix apply to ISO-on-TCP (connection type 12) and UDP (connection type 17) variants on the same hardware.

Problem Overview

The reported fault pattern is reproducible:

  • Hardware: CPU315-2PN/DP (2EH13, FW V2.6) running FB65 TCON, FB63 TSEND, FB64 TRCV.
  • Hardware: CPU314-DP (1AG13, FW V2.6) with CP343-1 (1EX21, FW V1.2) in Rack 0 Slot 4 running FC5 AG_SEND / FC6 AG_RECV.
  • Initial fault: TCON returns W#16#877F immediately on first call.
  • After pointer correction: TCON = W#16#7000 (idle, awaiting connection), but TSEND returns W#16#80C4 and CP343-1 AG_SEND/AG_RECV returns W#16#8183.

The two errors have distinct root causes: 877F is a local parameter problem (ANY pointer), while 80C4/8183 is a connection establishment problem (active/passive pairing, TSAP, or port range). Both must be resolved for the channel to pass data.

Affected Hardware and Firmware

Component Order Number (MLFB) Firmware Role
CPU315-2PN/DP 6ES7315-2EH13-0AB0 V2.6 Active partner; runs TCON/TSEND/TRCV
CPU314-DP 6ES7314-1AG13-0AB0 V2.6.4 Passive partner (via CP)
CP343-1 6GK7343-1EX21-0XE0 V1.2 Industrial Ethernet interface; AG_SEND/AG_RECV
STEP 7 6ES7810-4CC10-0YA5 V5.5 + SP4 Engineering; NetPro, OCWizard, HW Config

CP343-1 (1EX21) supports Open TCP/IP communication via FC5 AG_SEND / FC6 AG_RECV. Connection types 01/11 (TCP), 0B/12 (ISO-on-TCP), and 13/17 (UDP) are supported. Connection establishment can be either active or passive, and the port range accepted by the CP's send buffer is 2000-5000 by default in firmware V1.x; ports outside this range are silently dropped at the CP and surface as 8183h on the partner side.

Error Code 877F: Root Cause Analysis

W#16#877F at FB65 TCON maps in the Open Communication library to: "Internal error such as an invalid ANY reference." The diagnostic manual is explicit: parameter 7 of the TCON call (the CONNECT ANY pointer) is rejected by the FB. Three frequent causes are seen in the field:

  1. The pointer is not a fully-qualified 64-bit ANY reference. TCON requires the exact form P#<DB>.DBX<byte>.<bit> BYTE 64 (or word 32 for ISO-on-TCP) — the BYTE 64 length element is mandatory.
  2. The pointer is correct, but the target data block has been deleted, renamed, or had its length shortened below 64 bytes by a subsequent compiler pass. The ANY check verifies the data block actually exists at the referenced offset for the declared length.
  3. The pointer points to a local stack area, an instance DB bit, or a non-DB source — Open Communication FBs only accept DB-anchored ANY pointers.

After correcting the pointer to P#DB100.DBX0.0 BYTE 64 (or equivalent), the 877F code is cleared and TCON transitions to W#16#7000 ("Connection not yet established; idle"). This is the expected steady state for a TCON whose partner has not yet completed the TCP handshake.

Rule of thumb: If TCON still returns 877F after a clean recompile of the calling OB, dump STW (status word) and CONNECT ANY pointer with the STEP 7 Monitor/Modify tool in the STL view. The standard 64-byte UDT is created by the Open Communication Wizard — do not hand-author it unless you are reproducing the OCWizard output byte-for-byte.

Step 1: Correct the CONNECT ANY Pointer

Declare the connection description in a dedicated DB, sized to a multiple of 64 bytes (one connection block per channel):

DATA_BLOCK "DB_Conn_DB"
  STRUCT
    Conn01 : UDT 65;   // 64-byte UDT generated by OCWizard
    Conn02 : UDT 65;
    ...
  END_STRUCT
END_DATA_BLOCK

Call FB65 TCON with the qualified pointer, not a symbolic name:

CALL FB65, DB100
      REQ    := TRUE
      ID     := 1                // connection ID 1..4095
      DONE   := M100.0
      BUSY   := M100.1
      ERROR  := M100.2
      STATUS := MW102
      CONNECT:= P#DB100.DBX0.0 BYTE 64   // <-- mandatory, exact form

Verify that DB100 exists, has length >= 64 bytes, and is not used as a "non-optimized" or "optimized" access conflict. S7-300 Open Communication FBs require non-optimized (standard) DBs. Optimized DBs (introduced with S7-1500) are not supported by FB65/FB63/FB64 on S7-300.

Step 2: Active vs Passive Connection Establishment

On a CP343-1 (1EX21) controlled by an S7-300 CPU, the recommended pattern is:

Station Connection Establishment Reason
CPU315-2PN/DP (PN interface) Active Integrated PN port supports TCON active establishment; opens the TCP socket from a dynamic local port.
CP343-1 (1EX21) Passive CP waits for the partner; local TSAP/Port is fixed, remote IP/Port can be left as 0/"unspecified" during initial commissioning.

Setting the CP to passive (NetPro: "Connection establishment: passive") and the CPU to active avoids dynamic-port negotiation issues where the CP cannot predict which local port the partner CPU will use. It also lets the active partner be reconfigured (CPU swapped, IP changed) without touching the CP configuration.

The "unspecified partner" option in NetPro is intentional during the bring-up phase — it accepts an inbound TCP connection from any IP. Lock down the remote IP and Port only after data is moving.

Field tip: If the PN port on the CPU315-2PN/DP cannot establish the connection (e.g., firewall or routing), reverse the roles — set the CP343-1 to active and the CPU315-2PN/DP to passive — to bisect the problem. With both ends passive, no socket is ever opened.

Step 3: NetPro and Open Communication Wizard Configuration

The Open Communication Wizard (OCWizard) is the documented path for generating the 64-byte connection description UDT and the FB65/FB63/FB64 instance DBs. The Wizard is launched from SIMATIC Manager → CPU → "Open Communication Wizard".

  1. Block selection: Generate FB65 TCON, FB66 TDISCON, FB63 TSEND, FB64 TRCV as multi-instance-capable FBs. The Wizard can also generate FB67 TUSEND/FB68 TURCV for UDP, but for the 80C4/8183 case we are concerned with TCP.
  2. Connection type: Select TCP (type 11) for raw TCP, or ISO-on-TCP (type 12) if you require RFC 1006 length-prefix framing. The 877F error is independent of connection type; it is a pointer-validation error.
  3. Partner type: Leave the box "Communication partner B is not an S7 CPU" unchecked. Ticking it forces the Wizard to inject R0S2/R0S3 (Rack 0 Slot 2 / Rack 0 Slot 3) defaults for the partner station. The CP343-1 is at Rack 0 Slot 4 in this hardware, so the R0S2/R0S3 default points at the CPU rather than the CP and breaks NetPro's view of the connection endpoint.
  4. Local TSAP/Port: For the CP343-1 (passive side), enter a port in the 2000-5000 range (e.g., 2001). For the active CPU315-2PN/DP side, leave the local TSAP as empty (the system assigns a dynamic port).
  5. Remote TSAP/Port: Enter the CP's port (2001) on the active CPU side. Enter the CPU315-2PN/DP's IP address as the partner IP.
  6. Connection name: Up to 32 chars; informational only.

Recompile and download the generated DBs (typically DB100-DB103) to both stations. The Wizard's generated UDT is the only safe way to build the 64-byte block — hand-edited UDTs that pass 877F still fail later with 80C4/8183 because of subtle field ordering issues.

Step 4: TSAP and Port Configuration (2000-5000 Range)

CP343-1 firmware V1.2 imposes a default send buffer port range of 2000-5000. Ports outside this range are accepted in the UDT and TCON accepts them, but the CP's internal send buffer rejects the frame and the partner observes a 8183h (or 80C4h on the S7-300 side). Documented in the CP343-1 (1EX21) manual section on "Allowed Port Range".

Parameter CP343-1 (Passive) CPU315-2PN/DP (Active)
Local TSAP / Port 2001 (fixed) Empty (OS assigns)
Remote TSAP / Port Empty / 0 (unspecified) 2001
Remote IP Empty (any) 192.168.0.10 (CP IP)
Local IP 192.168.0.10 192.168.0.11

Verify the IP addresses from the station's "PLC → Ethernet Address" S7 properties tab, not from STEP 7's project view — they must match. An IP mismatch surfaces as 8183h on the CP and 80C4h on the active CPU, identical to a port-range error.

Step 5: Resolving 80C4 and 8183 Status After CONNECT

Once the CONNECT ANY pointer is valid, the second fault pair is at the data transfer FBs:

Status Block Typical Meaning Direction
W#16#7000 FB65 TCON Idle; connection not yet established Idle/awaiting
W#16#7002 FB65 TCON DONE — connection established Success
W#16#80C4 FB63 TSEND Temporary communication error / connection aborted by remote or local Active → passive
W#16#8183 FC5 AG_SEND Connection terminated or rejected (port out of range, IP mismatch, partner not listening) Passive side
W#16#80A1 FB63 TSEND Connection or port already in use by another FB Local resource conflict

The 80C4/8183 pair is typically caused by one of:

  1. Port outside 2000-5000 range on either end.
  2. TSAP length > 16 bytes (TSAP must be a 1-16 byte ASCII string for ISO-on-TCP, or a 2-byte port for TCP).
  3. Active/passive pairing reversed (both ends active = no listener; both ends passive = no connector).
  4. NetPro connection not downloaded, or downloaded only to one station.
  5. CP343-1 in "STOP" or pending firmware update.
  6. Firewall / managed switch blocking the TCP SYN. Confirm with Wireshark on the same segment.

For the TCON handshake error class more broadly, the S7-1200/1500 manual describes "Error during the handshake. Possible causes: Abort by the user. Security not high enough. The instruction does not support renewed negotiation." The same root cause tree applies to S7-300 FB65: a TLS/active-establishment abort typically surfaces as 80C4 on the S7-300 side and 8183 on the CP side. See the TCON / TDISCON / TSEND / TRCV instruction reference at Siemens TIA Portal documentation: TCON / TDISCON / TSEND / TRCV TCP communication.

Status Code Reference Table

Status (hex) Block(s) Description Recommended Action
7000 TCON / TSEND / TRCV / TDISCON Idle / awaiting job None (normal pending state)
7001 TSEND / TRCV Job started, processing None
7002 TCON Connection established (DONE) None
80C3 TSEND / TRCV Connection not yet established Wait for TCON DONE; check pairing
80C4 TSEND / TRCV Temporary error / aborted Check TCON STATUS; restart TCON sequence
80A1 TSEND / TRCV Port/ID already in use Reassign connection ID; check duplicates
8183 FC5 AG_SEND / FC6 AG_RECV Connection terminated / rejected Check port range, IP, active/passive, NetPro download
877F FB65 TCON Invalid ANY reference (CONNECT) Re-set CONNECT to P#DBx.DBXy.z BYTE 64
8E25 FC5/FC6 CP error: send buffer not ready Check CP mode; reduce send rate
8E26 FC5/FC6 CP error: parameter assignment error Recompile UDT; check FB65 instance

Verification Procedure

  1. Compile & download HW Config (with the new IP addresses) and NetPro to both stations. NetPro must be downloaded to both ends — the CP343-1 in particular must receive the new connection configuration.
  2. Reset both CPUs to RUN. Watch the CP343-1 "RUN/STOP" and "SF/BF" LEDs — a steady "BF" indicates no link or IP misconfiguration.
  3. Trigger the first TCON call in OB1. Confirm BUSY=1 immediately, then DONE=1 with STATUS=7002h once the partner is reached.
  4. Watch FB63 TSEND status. If 7002 is seen after 1-2 scan cycles, the handshake completed. If 80C4 persists, capture STATUS on the rising edge of ERROR and look up the table above.
  5. Cross-check with the CP343-1 diagnostic buffer: PLC → Diagnostic Buffer → filter "Communication". An "Open TCP/IP: Connection X established" entry confirms the passive side accepted the active SYN.
  6. Sniff the segment with Wireshark (filter tcp.port == 2001) to confirm the three-way handshake and the first data segment.
  7. Read back data at the receiving FB64/FC6 instance; confirm length and content. Capture a second TSEND with LEN := 0 to verify the channel can be closed gracefully via TDISCON.
Roll-back strategy: If 80C4/8183 reappears after a firmware update of the CP343-1, revert the CP firmware and confirm the S7-300 Open Communication Wizard was regenerated for the new firmware. Firmware V1.x of the CP and STEP 7 V5.5 SP4 OCWizard output are not always compatible with the OCWizard output generated for the original V1.0 CP firmware.

Common Pitfalls and Field Notes

  • ANY pointer symbolic form. Calling TCON with CONNECT := "DB_Conn".Conn01 passes the symbolic UDT pointer, not the qualified ANY form. Force the absolute pointer: P#DB100.DBX0.0 BYTE 64. Symbolic UDT pointers fail the ANY validation and surface as 877F.
  • Optimized DB access. If DB100 is later changed to "optimized block access" (an S7-1500 feature accidentally enabled in mixed projects), the ANY length element is stripped and TCON errors out with 877F. Lock the DB to standard access.
  • DB length. A 64-byte UDT packed into a 60-byte DB by an earlier edit will pass the pointer check (the ANY says 64) but fail the runtime check with 877F or with a CPU STOP. Recompile after any length change.
  • OCWizard regeneration. Re-running the Open Communication Wizard and not downloading the regenerated DBs leaves a stale UDT on the CPU. The first 877F after a Wizard re-run is almost always "stale DB" — do a full DB delete + reload.
  • Both stations in the same STEP 7 project: For NetPro to link the two connections, the two stations must be in the same S7 project. Cross-project Open TCP is not represented in NetPro and forces you to author the connection description UDT by hand on the remote side.
  • CP343-1 send buffer: If multiple AG_SEND calls are queued faster than the CP can drain, the buffer overruns and AG_SEND returns 8183h transiently. Insert a wait/poll on DONE or BUSY before the next call.
  • Active on the wrong side. If the CP343-1 is set to active in NetPro and the CPU315-2PN/DP is also set to active, the SYN goes nowhere. Set exactly one side active; the other passive. This is the most common cause of 8183h/80C4h once the pointer is correct.

What does TCON status 877F mean on a Siemens S7-300 FB65?

Status 877F is an internal error from the Open Communication FB, almost always caused by an invalid CONNECT ANY reference. The pointer must be in the exact form P#<DB>.DBX<byte>.<bit> BYTE 64, with the DB actually existing and being at least 64 bytes long. Re-run the Open Communication Wizard and copy the qualified pointer from the generated UDT instance.

How do I fix a TCON handshake error (80C4 / 8183) after fixing 877F?

Confirm exactly one side is "active" and one is "passive" in NetPro, with the active side being the CPU315-2PN/DP integrated PN port and the CP343-1 set to passive. Verify the passive side's port lies in 2000-5000 (CP343-1 V1.2 default range) and that the IP addresses in the station's Ethernet properties match the values in the connection description UDT. Re-download NetPro to both stations and re-trigger TCON.

Is the "Communication partner B is not an S7 CPU" checkbox relevant when using a CP343-1?

It is irrelevant for Open TCP and should be left unchecked. Ticking it forces the Wizard to default the partner Rack/Slot to R0S2/R0S3, which points at the CPU on the partner station, not at the CP343-1. With the box unchecked, the Wizard lets you bind the connection to the actual CP at R0S4 in this hardware.

Can I use ISO-on-TCP instead of raw TCP between the CPU315-2PN/DP and the CP343-1?

Yes. ISO-on-TCP (connection type 12) uses the same FB65/FB63/FB64 FBs and the same CONNECT ANY pointer form, but the UDT is 64 bytes with RFC 1006 length-prefix framing. The 877F root cause and fix are identical; the only differences are the connection type byte in the UDT and a TSAP string instead of a port number for the local/remote endpoint.

Why does the CP343-1 keep returning 8183h on AG_SEND even though TCON shows 7002h?

AG_SEND/AG_RECV errors of 8183h on a CP343-1 are nearly always a connection-acceptance or port-range problem on the CP side, not a problem with the active CPU. Check (1) the CP's port is in 2000-5000, (2) the active partner's IP is reachable from the CP's IP stack, (3) the NetPro connection has been downloaded to the CP, and (4) the CPU is in RUN. A Wireshark capture of the segment will show whether the SYN is even reaching the CP.

Back to blog