F_iecChangeLinkLayerMode

F_iecChangeLinkLayerMode 1:

With this function the default behavior of each individual ASDU frame at the Link-Layer level in the primary station can be set or changed. The ASDU frame to be sent can be marked as a SEND/NO REPLY frame (function 4) or as a broadcast frame. The frames are marked before depositing the frame in the TX buffer. I.e. before calling the FB_IEC870_5_101TBufferCtrl.TxAddObj action.

If you do not use the function, then all frames in the primary station are sent as SEND/CONFIRM frames (function 3). In this case the configured station address is used as the link address.

F_iecChangeLinkLayerMode 2:
  • In unbalanced mode the use of this function has no meaning in the substation. The substation never acts as a primary station in this mode.
  • The function has no meaning when using the IEC 6087-5-104 protocol.
  • This functionality is supported only when using the ‘low level’ interface.

Syntax

FUNCTION F_iecChangeLinkLayerMode: BOOL
VAR_INPUT
    sendNoReplay   : BOOL;
    globalLinkAddr : BOOL;
END_VAR
VAR_IN_OUT
    asdu           : ST_IEC870_5_101AOGen;
END_VAR

F_iecChangeLinkLayerMode 3: Inputs

sendNoReplay: This parameter specifies whether the Link-Layer function SEND/NO REPLY (TRUE = function 4) or SEND/CONFIRM (FALSE = function 3) is to be used when sending the frame;

globalLinkAddr: This parameter specifies whether a global (broadcast) address is to be used instead of the configured station link address when sending the frame. If the value is TRUE, 16#FF or 16#FFFF (one octet size, two octets size link address) is used as the link address in the sent frame;

Inputs/outputs

asdu: The data unit to be sent as VAR_IN_OUT variable;

F_iecChangeLinkLayerMode 4: Return value

Return parameter

Description

FALSE

Function failed.

TRUE

No error.

Sample 1 in ST (extract)

The spontaneous data of a bit string are to be sent to the central station with the aid of the SEND/NO REPLY function (balanced mode).

...

(* Send spontanous bitstring data *)
IF ( txQDS <> BITSTRING_QUALITY_100 ) OR ( txBSI <> BITSTRING_100 ) THEN

    txBSI                   := BITSTRING_100;
    txQDS                   := BITSTRING_QUALITY_100;(* Get quality *)
    txTT                    := SYSTEMTIME_TO_CP56Time2a( fbRTC.CDT, TRUE );(* Get current time stamp *)(* create asdu *)
    txAsdu.ident.eType      := M_BO_TB_1;  (* Bit string with time tag *)
    txAsdu.ident.bSQ        := FALSE;
    txAsdu.ident.nObj       := 1;
    txAsdu.ident.eCOT       := eIEC870_COT_SPONTAN;
    txAsdu.ident.nORG       := sysPara.nOrg;(* Set originator address *)
    txAsdu.ident.bPN        := FALSE;
    txAsdu.ident.bT         := FALSE;
    txAsdu.ident.eClass     := eIEC870_Class_1;(* Put to the high priority tx buffer *)
    txAsdu.ident.asduAddr   := sysPara.asduAddr;(* Set common asdu address *)
    txAsdu.info.objAddr     := 100;(* Set information object address *)
    F_iecResetStream( 0, txAsdu.info.stream ); (* clear previous data (this sets the stream length = 0 *)
    F_iecCopyBufferToStream( ADR( txBSI ), SIZEOF( txBSI ), txAsdu.info.stream ); (* put BSI to stream *)
    F_iecCopyBufferToStream( ADR( txQDS ), SIZEOF( txQDS ), txAsdu.info.stream ); (* put QDS to stream *)
    F_iecCopyBufferToStream( ADR( txTT ), 7 (*SIZEOF( txTT )-1*), txAsdu.info.stream ); (* put time tag to stream *)F_iecChangeLinkLayerMode( TRUE, FALSE, txAsdu );

    fbBuffer.TxAddObj( putObj := txAsdu, buffer := buffer ); (* put asdu to the TX fifo *)F_iecChangeLinkLayerMode( FALSE, FALSE, txAsdu );

    IF fbBuffer.bOk THEN
        fbLog( put := CONCAT( '<=', IEC101ASDU_TO_STRING(txAsdu) ) );
    ELSE(* Report send buffer overflow error *)
        fbLog( put := 'TX buffer overflow (spontanous bitstring data)!' );
    END_IF
END_IF

...

The txAsdu variable is used to send further data points. The default configuration of the txAsdu frame is produced by a further F_iecChangeLinkLayerMode (FALSE, FALSE,…) function call. Other ASDUs are not to be sent as SEND/NO REPLY telegrams.

Sample 2 in ST (extract)

A single command is to be sent to the substation with the aid of the SEND/NO REPLY function (unbalanced mode).

...

(* Send one single command *)
IF SND_SCS_2100 THEN 
    SND_SCS_2100 := FALSE; (* Reset flag *)

    txAsdu.ident.eType      := C_SC_NA_1; (* Single command *)
    txAsdu.ident.bSQ        := FALSE;
    txAsdu.ident.nObj       := 1;
    txAsdu.ident.eCOT       := eIEC870_COT_ACT; (* Command activation *)
    txAsdu.ident.nORG       := sysPara.nOrg;(* Set originator address *)
    txAsdu.ident.bPN        := FALSE;
    txAsdu.ident.bT         := FALSE;
    txAsdu.ident.eClass     := eIEC870_Class_1;(* Put to the high priority tx buffer *)
    txAsdu.ident.asduAddr   := sysPara.asduAddr;(* Set common asdu address *)
    txAsdu.info.objAddr     := 2100;(* Set information object address *)
    tmpByte                 := INT_TO_BYTE(SCS_2100);(* Set single command state *)
    tmpByte.7               := 0;(* Set select/execute bit *)

    F_iecResetStream( 0, txAsdu.info.stream ); (* Clear previous data (this sets the stream length = 0 *)
    F_iecCopyBufferToStream( ADR( tmpByte ), SIZEOF( tmpByte ), txAsdu.info.stream ); (* put QCC to stream *)     F_iecChangeLinkLayerMode( TRUE, FALSE, txAsdu );

    fbBuffer.TxAddObj( putObj := txAsdu, buffer := buffer ); (* put asdu to the TX fifo *)
     F_iecChangeLinkLayerMode( FALSE, FALSE, txAsdu );

    IF fbBuffer.bOk THEN
        timerCON( IN := FALSE );(* Reset timer *)
        timerTERM( IN := FALSE );(* Reset timer *)
        fbLog( put := CONCAT( '<=', IEC101ASDU_TO_STRING(txAsdu) ) );
        state := 80;(* Wait for command confirmation *)
    ELSE(* Report send buffer overflow error *)
        fbLog( put := 'TX buffer overflow (single command)!' );
        state := 1;
    END_IF

END_IF

...

Requirements

Development environment

Target system type

PLC libraries to be linked (category group)

TwinCAT v3.1.4012.0

PC oder CX (x86, x64, Arm®)

Tc2_IEC60870_5_10x (Communication->IEC60870)
Tc2_SerialCom (Communication->Serial)
Tc2_TcpIp (Communication->TcpIp)
Tc2_Utilities (System)