Skip to main content

7.15.7 T_RESET

T_RESET (terminate and reconnect the specified connection)

Function

  • T_RESET system library is used to asynchronously reset the current TCP connection

Set up and establish communication connections

  • After the user configures the correct IP address and port number in the connect block, by setting the REQ parameter to true, the reset connection function is enabled, the current communication connection is terminated and the connection request is re-created.

  • The reset connection function only works when the communication connection has been successfully established.

  • Correct reset process: you need to give the req pin a rising edge, you can see the status word in the T_RESET block from 0x7004 (connection has been established) → 0x7003 (is terminating the connection) → 0x7007 (has terminated the connection) → 0x7002 (is establishing a connection), the above state changes indicate that the connection has been reset successfully; to be re-triggered by the opposite end of the connection action. When the other end re-triggers the connection action, the status code of your side can be smoothly updated to 0x7004 (connection established successfully).

  • After the connection is established, if the opposite end takes the initiative to disconnect at this time, the status code will change from 0x7004 (established) to 0x7002 (connection is being established); if the connection is reset at this time, the reconnection operation will not be triggered

LD graphics

alt text

Parameter description

Interface VariablesDeclarationData TypeDescription
REQInputBOOLActively reset the connection only when rising edge is recognized
CONNECTInOutTCP_ConnectConfigExample of function block to configure connection parameters, refer to TCP_Connectconfig
DONEOutputBOOLState parameter with the following possible values:
0: The reset connection has not been started or is still in progress
1: The reset connection has been successfully performed. This status will only show for one cycle
BUSYOutputBOOLState parameter with the following possible values:
0: Resetting the connection has not yet started or has been completed
1: Resetting the connection has not yet completed
ERROROutputBOOLState parameter with the following possible values:
0: No error
1: Error resetting the connection
STATUSOutputWORDThe status of the current function execution process

Status code description

STATUS(WORD 16#)Description
0000Uncalled
7002Establishing communication connection
7004Connection successfully established
8000Resetting connection
The following are exception status codesDescription
8080Failed to create socket, insufficient system socket resources
8081Wrong IP address
8082Reusable error in setting IP address and port number
8083Bind address and port number with socket failure
8084Failed to add server socket to EPoll listening queue
8086Failed to receive new connection
8087Failed to remove the Epoll Event corresponding to the client
80A0Failed client-initiated connection to the server
80A2Active disconnection failed
80A3Failed to reset connection
80ACAsynchronous function enqueue failed

Example

  • LD example is shown in the following animation:

alt text

  • ST example is shown in the following code:
T_RESET_1(
REQ:=RESET,
CONNECT:=TCP_CONNECTCONFIG_1,
DONE=>OUT,
BUSY=>OUT2,
ERROR=>OUT3,
STATUS=>OUT4
);