This function copies the memory area defined in Src in the memory area defined in Dest for the size defined in Size. The two memory areas may also overlap.
The function guarantees the atomicity of the transfer, therefore the memory area defined in Dest it always has a consistent value even if written by one task and used by another task. It must be used to pass variables larger than 4 bytes a for strings from one task to another task with higher execution priority.
Function
CODESYS: eCDSXUnified12Lib
LogicLab: eLLabXUnified12Lib
Description
Dest (PVOID) Address of the destination memory area.
Src (PVOID) Address of the source memory area.
Size (UDINT) Size of the memory area to be transferred.
The function returns a variable (PVOID) with the address of the destination memory area. In the event of an error, e is returnedNULL.
Examples
How to use the examples.
Setting the variable from debug CMove, the memory Source will be transferred to Destination.
LogicLab (Ptp116)
PROGRAM ST_Sysmemmove
VAR
i : UDINT; (* Auxiliary variable *)
CMove : BOOL; (* Move command *)
Source : ARRAY[ 0..15 ] OF BYTE; (* Source memory *)
Destination : STRING[ 32 ]; (* Destination memory *)
END_VAR
// *****************************************************************************
// PROGRAM "ST_Sysmemmove"
// *****************************************************************************
// By setting the "Move" command the memory is moved
// -----------------------------------------------------------------------------
IF (CMove) THEN
CMove:=FALSE; //Move command
i:=Sysmemmove(ADR(Destination), ADR(Source), SIZEOF(Source));
END_IF;
// [End of file]
CODESYS (Ptp161)
PROGRAM ST_Sysmemmove
VAR
i : UDINT; //Auxiliary variable
CMove : BOOL; //Move command
Source : ARRAY[ 0..15 ] OF BYTE; //Source memory
Destination : STRING[ 32 ]; //Destination memory
END_VAR
// *****************************************************************************
// PROGRAM "ST_Sysmemmove"
// *****************************************************************************
// By setting the "Move" command the memory is moved
// -----------------------------------------------------------------------------
IF (CMove ) THEN
CMove :=FALSE; //Move command
i:=Sysmemmove(ADR(Destination), ADR(Source), SIZEOF(Source));
END_IF;
// [End of file]