F_iecMoveStreamToBuffer
![F_iecMoveStreamToBuffer 1:](Images/gif/984918411__en-US__Web.gif)
This function copies data bytes from the stream variable into an external buffer variable and then deletes the copied data bytes from the stream variable. The memory content of the stream variable is reduced. The return parameter of the function returns the number of successfully copied data bytes.
Syntax
FUNCTION F_iecMoveStreamToBuffer : UDINT
VAR_INPUT
pBuffer : PVOID;
cbBuffer : UDINT;
END_VAR
VAR_IN_OUT
stream : ST_IEC870_5_101Stream;
END_VAR
Inputs
pBuffer: Pointer (address) of an external buffer variable.
cbBuffer: Maximum number of data bytes to be copied from the stream variable to the external buffer.
Sample in ST
After the program start, 8 byte values are initialized in the stream variable. A rising edge at bRx results in copying of 4 data bytes from the stream variable into the rxBuffer variable.
PROGRAM P_iecMoveStreamToBuffer
VAR
stream : ST_IEC870_5_101Stream := ( length := 8, data := [16#78, 16#56, 16#34, 16#12, 16#01, 16#EF, 16#CD, 16#AB] );
rxBuffer : DWORD;
cbResult : UDINT;
bRx : BOOL := TRUE;
END_VAR
IF bRx THEN
bRx := FALSE;
cbResult := F_iecMoveStreamToBuffer( ADR( rxBuffer ), SIZEOF( rxBuffer ), stream );
END_IF
Memory representation of the stream variable after the program start:
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 representation of the 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 representation of the 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 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) |