Skip to main content

7.11.5 SERIALIZE

Function

The serialization instruction converts multiple PLC data types (UDT), STRUCT or ARRAY of (data type) into sequential identifiers without losing structural parts

warning
  • The serialization instruction temporarily saves multiple structured data items of the user program into a serialized array (the data type must be ARRAY[] of BYTE or ARRAY[] of CHAR) and sends it to other CPUs
  • The maximum capacity of the serialized array is 64KB. It is recommended to define the lower limit of ARRAY as "0" because the subscript in ARRAY corresponds to the POS parameter value. For example, ARRAY[]= POS0. The explanations and examples below are based on this formula. The operand at parameter POS contains information about the number of bytes occupied by the converted data. After the instruction is executed, POS=POS+the number of bytes occupied by the data

LD graphics

alt text

Parameter description

Interface variableDeclarationData typeDescription
SOURCE_VARVAR_InputANY_TYPEVariable to be serialized
POSVAR_IN_OUTDINTThe variable to be serialized is stored in the relative subscript position of the array calculated by the POS parameter. The POS parameter will be calculated starting from 0, corresponding to the starting index position of the array. After the instruction is executed, POS = POS + the number of bytes occupied by the data
DEST_ARRAYVAR_IN_OUTARRAY of BYTE or ARRAY of CHARThe ARRAY variable name used to store the generated data stream
Function nameReturn valueINTError message

Return value error code

Error code (hexadecimal code)Description
0000No error
80B0The storage areas of parameters SOURCE_VAR and DEST_ARRAY overlap
8150The data type in the SOURCE_VAR parameter contains a ZERO pointer
8151Invalid reference in SOURCE_VAR parameter
8236Illegal variable at DEST_ARRAY parameter
8250NULL pointer passed at DEST_ARRAY parameter
8251Invalid reference in DEST_ARRAY parameter
8253The variable at parameter DEST_ARRAY does not provide enough space to contain the contents of the variable at parameter SOURCE_VAR. Due to the input value of the variable at the POS parameter, the available storage space will be reduced. The input value at the POS parameter determines the starting position in the variable at the DEST_ARRAY parameter
8254The data type in the DEST_ARRAY parameter is invalid
8382The value of the POS parameter exceeds the limit of the array

Example

  • LD sample pictures are shown below: alt text

  • ST sample code is as follows:

ss:=SERIALIZE(SOURCE_VAR:=sarr[13],POS:=darr[0],DEST_ARRAY:=dd);