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

This function copies data bytes from the stream variable to an external buffer variable and deletes afterwards the copied data bytes from the stream variable. The memory content of the stream variable decreases . The return parameter of the function delivers the number of successfully copied data bytes.
FUNCTION F_iecMoveStreamToBuffer : UDINT
VAR_INPUT
pBuffer : DWORD;
cbBuffer : UDINT;
END_VAR
VAR_IN_OUT
stream : ST_IEC870_5_101Stream;
END_VAR
pBuffer: Pointer (address) of external buffer variable.
cbBuffer: Maximum number of data bytes to be copied from the stream variable to the external buffer.
stream: Data buffer.
Example in ST:
After run two DWORD values are copied to the stream variable. Each time 4 data bytes of the stream variable are copied to the rxBuffer variable by a rising edge at bRx .
PROGRAM P_MoveStreamToBuffer
VAR
stream : ST_IEC870_5_101Stream;
txBuffer : ARRAY[0..1] OF DWORD := 16#12345678, 16#ABCDEF01;
cbTx : UDINT;
bTx : BOOL := TRUE;
rxBuffer : DWORD;
cbRx : UDINT;
bRx : BOOL;
END_VAR
IF bTx THEN
bTx := FALSE;
cbTx := F_iecCopyBufferToStream( ADR( txBuffer ), SIZEOF( txBuffer ), stream );
END_IF
IF bRx THEN
bRx := FALSE;
cbRx := F_iecMoveStreamToBuffer( ADR( rxBuffer ), SIZEOF( rxBuffer ), stream );
END_IF
Memory description of stream variable after run:
length | data | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
8 | 16#78 | 16#56 | 16#34 | 16#12 | 16#01 | 16#EF | 16#CD | 16#AB | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE |
Memory description of stream variable after the first F_iecMoveStreamToBuffer function call:
length | data | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
4 | 16#01 | 16#EF | 16#CD | 16#AB | 16#01 | 16#EF | 16#CD | 16#AB | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE |
Memory description of stream variable after the second F_iecMoveStreamToBuffer function call:
length | data | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 16#01 | 16#EF | 16#CD | 16#AB | 16#01 | 16#EF | 16#CD | 16#AB | ... | ... | ... | 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 |