F_iecCopyStreamToStream
From product version: TwinCAT PLC Library IEC60870-5-104 substation v2.0.6 and higher.

This function copies data bytes from the source variable to the target variable. The memory content of source variable remains unchanged. The memory content of the target variable increases. The return parameter of the function delivers the number of successfully copied data bytes.
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
cbCopy: Number of bytes to be copied from the source variable to the target variable.
target: Target data buffer
source: Source data buffer
Example in ST:
At a rising edge at bCopy first the srcValue is incremented and copied to srcStream . After that the first 4 data bytes are copied from srcStream to dstStream. At the end the first 4 data bytes are copied from dstStream into 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 description of srcStream and dstStream variable after the first F_iecCopyStreamToStream function call:
length | data | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
4 | 16#01 | 16#00 | 16#00 | 16#00 | ... | ... | ... | ... | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE |
length | data | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
4 | 16#01 | 16#00 | 16#00 | 16#00 | ... | ... | ... | ... | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE |
Memory description of srcStream and dstStream variable after thesecond F_iecCopyStreamToStream function call:
length | data | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
8 | 16#01 | 16#00 | 16#00 | 16#00 | 16#02 | 16#00 | 16#00 | 16#00 | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE |
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 | PLC libraries to include |
---|---|---|
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86) CX (ARM) | TcIEC870_5_101.Lib |