SerializeOut
Description
This function copies the value of a variable to a binary frame. This function is commonly used for building a communication frame in binary format.
In LD"Ladder diagram" Ladder logic is a method of drawing electrical logic schematics. It is now a very popular graphical language for programming Programmable Logic Controllers (PLCs). It was originally invented to describe logic made from relays. The name is based on the observation that programs in this language resemble ladders, with two vertical "rails" and a series of horizontal "rungs" between them 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"Instruction list" This is a low-level language and resembles assembly 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 | BOOL, SINT, USINT and BYTE variables |
2 bytes | INT, UINT and WORD variables |
4 bytes | DINT, UDINT, DWORD and REAL variables |
8 bytes | 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
Arguments
Input
En | Description | Execute the function |
Data type | BOOL | |
Range | [0,1] | |
Unit | n/a | |
Default | — | |
FrameIn networking dialect, a message is called a frame[] | Description | Destination buffer - must be an array. |
Data type | USINT | |
Range | [0,+65535] | |
Unit | n/a | |
Default | — | |
Data | Description | Source variable to be copied |
Data type | any except STRING | |
Range | — | |
Unit | n/a | |
Default | — | |
Pos | Description | Position in the destination buffer |
Data type | DINT | |
Range | [0,+65535] | |
Unit | n/a | |
Default | — | |
BigEndian | Description | TRUE if the frame is encoded with Big Endian format. |
Data type | BOOL | |
Range | [0,1] | |
Unit | n/a | |
Default | — |
Output
OK | Description | Returns true when the function successfully executes. See Function - General rules. |
Data type | BOOL | |
Unit | n/a | |
NextPos | Description | Position in the destination buffer after the copied data.
0 in case or error (invalid position / buffer size).
|
Data type | DINT | |
Unit | n/a |
Examples
Structured Text
NextPos := SerializeOut(Frame[](*USINT*), Data(*ANY*), Pos(*DINT*), BigEndian(*BOOL*)); //Read the position