-

BUF_TO_*

Type Function block
Description Allows to copy elementary data types from a byte stream to a variable, an array or elements of a user-defined structure. Little-/Big-Endian format is possible for the byte stream. Therefore an automatic data format conversion is supported.

This function block is useful for the data transfer or the communication among applications which are executed on different hardware platforms (Little-/Big-Endian).

Operation
After a rising edge has been put to the REQ input, the copy process starts. As defined in the BUF_FORMAT parameter, the data are converted into Little-/Big-Endian format (see the note below). The size of the destination DST is checked before copying.
After the copy process has finished correctly, DONE is set to TRUE. In case of any occurred errors, ERROR is set to TRUE and STATUS gets a value unequal to zero which represents the current error message. These values are kept until a falling edge is put to the REQ input. A new rising edge at REQ starts a new copy process.

Timing diagram
Notes
  • ' * ' is a placeholder for the supported data types. The FB is available for the data types BYTE, WORD, DWORD, LWORD, SINT, INT, DINT, LINT, UDINT, UINT, ULINT, USINT, TIME, REAL, LREAL, STRING, WSTRING, LTIME, LDATE, LTOD, and LDT.
  • For the STRING/WSTRING data type the operation is different to the following described. For information about the handling of the BUF_TO_STRING/BUF_TO_WSTRING function block click here.
  • It is not allowed to use the same addresses for the source and the destination!
  • The BUF_FORMAT parameter is not evaluated and has no effect for some data types such as BYTE or SINT.
  • Function blocks have to be instantiated. The instance name of the function block has to be declared in the 'Variables' table of the POU where the FB is going to be used. The instance name must be unique within the POU.
Parameters Inputs

REQ

BUF_FORMAT

BUF_OFFS

BUF_CNT

Input/Output

BUFFER

DST

Outputs

DONE

ERROR

STATUS
Additional information