FP_ETHERNET_CONNECTION_CLOSE

Close an Ethernet connection

This FP instruction closes an open Ethernet connection on the port specified by nPort. Please ensure the suitable parameters are also set in the project navigator under “System registers” > “Ethernet” > “User connections”.

Parameters

Input

nPort (WORD, INT, UINT)

Ethernet port on CPU (FP7 E types):

SYS_ETHERNET_USER_CONNECTION_1SYS_ETHERNET_USER_CONNECTION_216

Output

bError (BOOL)
  • if a timeout of the connection is exceeded

  • if an IP address is invalid

When an error occurs, check the system variable sys_iEthernetConnectionErrorCode for the error code number.

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		bSetConnection: BOOL:=FALSE;
		bOpenConnection: BOOL:=FALSE;
		bCloseConnection: BOOL:=FALSE;
	END_VAR

POU body

When the variable bCloseConnection changes from FALSE to TRUE and the system variable sys_bIsEthernetIPAddressAssigned is set to TRUE, the function is carried out.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 4 ;
        NETWORK_BODY
B(B_VARIN,,SYS_ETHERNET_USER_CONNECTION_1,30,2,32,4,);
B(B_CONTACT,,bCloseConnection,5,1,7,3,R);
B(B_CONTACT,,sys_bIsEthernetIPAddressAssigned,17,1,19,3,N);
B(B_VAROUT,,bError,49,2,51,4,);
B(B_F,FP_ETHERNET_CONNECTION_CLOSE!,,32,0,49,4,,?DEN?DnPort?AENO?CbError);
L(1,2,5,2);
L(19,2,32,2);
L(7,2,17,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

If DF(bCloseConnection) AND sys_bIsEthernetIPAddressAssigned then
    FP_ETHERNET_CONNECTION_CLOSE(nPort := SYS_ETHERNET_USER_CONNECTION_1);
END_IF;

Modified on: 2022-03-02Feedback on this pagePanasonic hotline