Function - Copy the value of a variable to a binary frame


FRAME : USINT    Destination buffer - must be an array
DATA : ANY(*)    Source variable to be copied
: DINT       Position in the destination buffer
: BOOL TRUE if the frame is encoded with Big Endian format

(*) DATA cannot be a STRING


NEXTPOS : DINT   Position in the destination buffer after the copied data
                 0 in case or error (invalid position / buffer size)


This function is commonly used for building a communication frame in binary format.

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. This function is not available in IL language.

The FRAME input must be an array large enough to receive the data. If the data cannot be safely copied to the destination buffer, the function returns 0.

The function copies the following number of bytes to the destination frame:

1 byte for BOOL, SINT, USINT and BYTE variables
2 bytes for INT, UINT and WORD variables
4 bytes for DINT, UDINT, DWORD and REAL variables
8 bytes for LINT and LREAL variables

The function cannot be used to serialize STRING variables.

The function returns the position in the destination frame, after the copied data. Thus the return value can be used as a position for the next serialization.

ST Language


FBD Language

LD Language

(* The function is executed only if EN is TRUE *)
(* ENO keeps the same value as EN *)

IL Language:

Not available

See also