FB_NLinkOpen
This function block (actively) establishes a network connection to the third-party system. If successful, the internal parameters of the hLink variable are initialised. The same instance of the hLink variable must then be transferred to the other instances of the communication blocks FB_NLinkFetch, FB_NLinkWrite or FB_NLinkClose. In a PLC application one instance of this variables is required for each network connection (TwinCAT system<->Ethernet LAN adapter<->external controller).
VAR_IN_OUT
VAR_IN_OUT
hLink : T_HNLINK;
END_VAR
hLink : Network connection handle. The instance of this variable is required by the other communication blocks and is transferred to them via VAR_IN_OUT.
VAR_INPUT
VAR_INPUT
stSettings : ST_NLinkSettings := ( sHost := '127.0.0.1', nPort := 2002 );(* Link/connection parameter/settings *)
nOpt : DWORD := 0; (* Additional options (reserved) *)
bExecute : BOOL; (* Rising edge at this input starts command execution *)
tTimeout : TIME := T#45s;(* Maximum time allowed for the execution of the command *)
END_VAR
stSettings: Structure with configuration settings for the communication connection. The member variables of this structure should contain parameters such as port number, host name, etc.
nOpt: Reserved for future applications.
bExecute: The block is activated by a rising edge at this input.
tTimeout: Specifies the timeout that must not be exceeded on receipt of the command.
VAR_OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrID : UDINT;
END_VAR
bBusy: When the function block is activated this output is set. It remains set until feedback is received. While Busy = TRUE, no new command will be accepted at the inputs. Please note that it is not the command execution but the receipt of the command that is monitored.
bError: In the event of an error during the command transfer, this output is set once the bBusy output has been reset.
nErrID: Supplies the error number when the bError output is set.
Example:
See examples.
Requirements
Development environment | Target platform | PLC libraries to be linked |
---|---|---|
TwinCAT v2.11.0 Build > 1536 | PC or CX (x86, ARM) | TcS5S7Comm.Lib |