Open an Ethernet connection
This FP instruction opens an Ethernet connection on the port specified by nPort. Please ensure the suitable parameters are also set in the project navigator under .
Input
Ethernet port on CPU (FP7 E types):
SYS_ETHERNET_USER_CONNECTION_1–SYS_ETHERNET_USER_CONNECTION_216
Output
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.
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
When the variable bOpenConnection changes from FALSE to TRUE and the system variable sys_bIsEthernetIPAddressAssigned is set to TRUE, the function is carried out.
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_CONTACT,,bOpenConnection,5,1,7,3,R);
B(B_CONTACT,,sys_bIsEthernetIPAddressAssigned,17,1,19,3,N);
B(B_VARIN,,SYS_ETHERNET_USER_CONNECTION_1,30,2,32,4,);
B(B_VAROUT,,bError,49,2,51,4,);
B(B_F,FP_ETHERNET_CONNECTION_OPEN!,,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
If DF(bOpenConnection) AND sys_bIsEthernetIPAddressAssigned then
FP_ETHERNET_CONNECTION_OPEN(nPort := SYS_ETHERNET_USER_CONNECTION_1);
END_IF;