Functional Description

Use the CLOSE_TCP_CNX elementary function block to close open TCP connections.

NOTE:
  • With a BMX NOE 01•0 communication module in the local rack:

    • The CLOSE_TCP_CNX function block is compatible with firmware greater than V3.20 only.

    • If the module uses firmware equal to or less than V3.20, a 16#3104 error code appears, which means the firmware of the module is not up-to-date and is not compatible with the CLOSE_TCP_CNX function block.

  • The CLOSE_TCP_CNX function block is not compatible with BMX P34 •0•0• M340 processors.

EFB Representation

This is the CLOSE_TCP_CNX elementary function block:

Parameter Description

The following tables describe the parameters in the CLOSE_TCP_CNX elementary function block.

Input parameters:

Parameter

Data Type

Description

ADR

ANY_ARRAY_INT

This array contains the address of the destination entity of the data exchange as a result of the ADDM function. It indicates the module and channel that manage the connection. For example, ADDM(0.3.0) represents channel 0 of the module in slot 3 in rack 0.

TCPIP

STRING

This string identifies the TCP/IP connection that is closed in this format: ip1.ip2.ip3.ip4:port, where port identifies the port in the remote target. (It does not correspond with the local port used for the connection). If several connections are open with same remote IP:port, all connections are closed. If port is not specified, Modbus port 502 is used. NB: connection opened by Modbus IO scanner component are not impacted and cannot be closed by the user.

Input/output parameters:

Parameter

Data Type

Description

GEST

ARRAY [0..3] OF INT

Exchange management table consisting of these words:

  • Rank 1 word: a word managed by the system and consisting of two bytes:

    • Most significant byte: exchange number

    • Least significant byte: activity bit (rank 0) and cancel bit (rank 1)

      NOTE: The cancel bit is only available for Modicon M340 and M580 PLCs.
  • Rank 2 word: a word managed by the system and consisting of two bytes:

    • Most significant byte: operation report

    • Least significant byte: communication report

  • Rank 3 word: a word managed by the user that defines the maximum response time using a time base of 100 ms

  • Rank 4 word: a word (managed by the system to suppress) that defines the length of the exchange (For more information, refer to description of the management parameter structure.)

    NOTE: For CLOSE_TCP_CNX, the length parameter in rank 4 is not specified by the user. Immediately after the execution of the logic, the activity bit is set to 0 and the length is assigned a value of 2 (to correspond to the length of the returned CNX_STATUS value) if no error is detected for the rank 2 word. Otherwise, the length value is set to an additional status code in the case of operation report 16#01 (request not processed) or 16#02 (incorrect response). Status codes in this field correspond to a subrange of possible STATUS parameter codes for communication EFBs with the STATUS parameter. Possible values for CLOSE_TCP_CNX include 0x30ss, 0x31ss, 0x4001, and 0x4002. Refer to the descriptions of detected error codes for the STATUS parameter.

Output parameters:

Parameter

Data Type

Description

CNX_STATUS

word

This word provides a detailed status of the service after it executes:

  • 16#0000: The TCP connection successfully closed.

  • 16#0001: The TCP connection is not valid (invalid IP/port parameters).

  • 16#0002: The TCP connection does not exist or the TCP connection is already closed.

  • 16#FFFF: The service did not execute. Refer to the status code reported in the report word of management table (GEST[1]).

Using the EFB

Use the CLOSE_TCP_CNX elementary function block:

Step

Action

1

Set the address of the communication channel that manages the connection in ADR. (Use the ADDM block to specify this address in an explicit string format.)

2

Specify the connection to close in the TCPIP parameter.

3

Call the function to launch the communication (with the EN input pin set to 1, if configured).

4

Monitor the activity bit (in the GEST parameter) until the communication is completed (the activity bit is set to 0 by the system). Execute this function only once to retain the status values. The function is not called when the activity bit is set to 0 (by setting EN pin to 0 for instance).

5

Check the CNX_STATUS word. If CNX_STATUS = 16#FFFF, check the report parameter in GEST[1].