F_iecCopyStreamToStream

F_iecCopyStreamToStream 1:

This function copies data bytes from the source variable to the target variable. The memory content of the source variable remains unchanged. The memory content of the target variable is increased. The return parameter of the function returns the number of successfully copied data bytes.

Syntax

FUNCTION F_iecCopyStreamToStream: UDINT
VAR_INPUT
    cbCopy  : UDINT;
END_VAR
VAR_IN_OUT
    target  : ST_IEC870_5_101Stream;
    source  : ST_IEC870_5_101Stream;
END_VAR

F_iecCopyStreamToStream 2: Inputs

cbCopy: Number of bytes to be copied from the source variable to the target variable.

Inputs/outputs

target: Target data buffer.

source: Source data buffer.

Sample in ST

A rising edge at bCopy results in incrementing of srcValue, followed by copying to srcStream. Then, the first 4 data bytes are copied from srcStream to dstStream. Finally, the first 4 data bytes are copied from dstStream to the dstValue variable.

PROGRAM P_iecCopyStreamToStream
VAR
    srcStream   : ST_IEC870_5_101Stream;
    srcValue    : DWORD;

    dstStream   : ST_IEC870_5_101Stream;
    dstValue    : DWORD;

    bCopy       : BOOL;
END_VAR
IF bCopy THEN
    bCopy := FALSE;
    srcValue := srcValue + 1;
    F_iecCopyBufferToStream( ADR( srcValue ), SIZEOF( srcValue ), srcStream );
    F_iecCopyStreamToStream ( SIZEOF( srcValue ), dstStream, srcStream );
    F_iecCopyStreamToBuffer( ADR( dstValue ), SIZEOF( dstValue ), dstStream );
END_IF

Memory representation of the srcStream and dstStream variables after the first F_iecCopyStreamToStream function call:

srcStream:

length

data

4

16#01

16#00

16#00

16#00

...

...

...

...

...

...

...

IEC870_MAX_ASDU_DATA_BYTE

dstStream:

length

data

4

16#01

16#00

16#00

16#00

...

...

...

...

...

...

...

IEC870_MAX_ASDU_DATA_BYTE

Memory representation of the srcStream and dstStream variables after the second F_iecCopyStreamToStream function call:

srcStream:

length

data

8

16#01

16#00

16#00

16#00

16#02

16#00

16#00

16#00

...

...

...

IEC870_MAX_ASDU_DATA_BYTE

dstStream:

length

data

8

16#01

16#00

16#00

16#00

16#01

16#00

16#00

16#00

...

...

...

IEC870_MAX_ASDU_DATA_BYTE

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)