FB_TlsSocketSetPsk

FB_TlsSocketSetPsk 1:

The function block FB_TlsSocketSetPsk can be used to configure a pre-shared secret for an existing socket handle. Programming samples for using this function block can be found in our samples.

FB_TlsSocketSetPsk 2: Inputs

VAR_INPUT
    sSrvNetId : T_AmsNetId:='';
    hSocket   : T_HSOCKET;
    sIdentity : STRING(TCPADS_TLS_PSK_IDENTITY_SIZE):='';
    pskKey    : PVOID:=0;
    pskKeyLen : UDINT(0..TCPADS_TLS_MAX_PSK_KEY_SIZE):=0;
    bExecute  : BOOL;
    tTimeout  : TIME:=T#5s;
END_VAR

Name

Type

Description

sSrvNetId

T_AmsNetId

String containing the network address of the TwinCAT TCP/IP Connection Server. For the local computer (default) an empty string may be specified.

hSocket

T_HSOCKET

Socket handle.

sIdentity

STRING(TCPADS_TLS_PSK_IDENTITY_SIZE)

A freely selectable identity for the PSK.

pskKey

PVOID

Pointer to a byte array containing the PSK.

pskKeyLen

UDINT(0..TCPADS_TLS_MAX_PSK_KEY_SIZE)

Length of pskKey.

bExecute

BOOL

The function block is enabled by a positive edge at this input.

tTimeout

TIME 

Maximum time allowed for the execution of the function block.

FB_TlsSocketSetPsk 3: Outputs

VAR_OUTPUT
    bBusy  : BOOL;
    bError : BOOL;
    nErrId : UDINT;
END_VAR

Name

Type

Description

bBusy

BOOL

This output is active if the function block is activated. It remains active until acknowledgement.

bError

BOOL

If an error should occur during the transfer of the command, then this output is set once the bBusy output was reset.

nErrId

UDINT

If an bError output is set, this parameter returns the TwinCAT TCP/IP Connection Server error number.

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TF6310 v3.3.15.0 or later

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_TcpIp (Communication)