Function - Extract a string from a binary frame


FRAME : USINT    Source buffer - must be an array
DST : STRING     Destination variable to be copied
: DINT       Position in the source buffer
: DINT    Specifies a fixed length string
: BOOL       Specifies a null terminated string
: BOOL      Specifies a string headed with its length


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


This function is commonly used for extracting data from 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 fit the input position and data size. If the value cannot be safely extracted, the function returns 0.

The DST input must be directly connected to a variable, and cannot be a constant or complex expression. This variable will be forced with the extracted value.

The function extracts the following bytes from the source frame:

MAXLEN EOS HEAD description
<> 0 any any The string is stored on a fixed length specified by MAXLEN. If the string is actually smaller, the space is completed with null bytes.
= 0 TRUE any The string is stored with its actual length and terminated by anull byte.
= 0 FALSE TRUE The string is stored with its actual length and preceded by its length stored on one byte
=0 FALSE FALSE invalid call

The function returns the position in the source frame, after the extracted 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