Description
With the "Read values from buffer and write them into resolved symbols" instruction, you read values from a memory area (Array of BYTE) and write them into the values of several resolved symbols. In this way, you can process a memory area that you have received from a communication instruction, such as TRCV.
The "src" parameter is an Array of BYTE. It serves as the source buffer from which the values are read. The "dst" parameter is an Array of ResolvedSymbol (SDT). It contains references to tags that were previously resolved with the instruction "ResolveSymbols". By using the references, the tags are to be written with the values from the source buffer.
By using the parameters "firstIndex" and "lastIndex", you restrict the selection of tags in the list of resolved symbols whose values are to be written. If you do not wish to restrict the list, the value at the "firstIndex" parameter must correspond to the low limit of the list and the value at the "lastIndex" parameter must correspond to the high limit of the list.
The value at the "mode" parameter defines the memory format at the "src" parameter.
With offsets, you determine from where the value of the resolved symbol is read and copied in the source buffer. You specify the offsets at the "srcOffsets" (Array of DINT) parameter. Each offset is a bit offset and determines the first bit from which the value is read from the buffer. You can store several values of the BOOL data type in one byte. Values of all other data types must start at a bit position divisible by 8.
If, for example, the "dst[i]" parameter references a tag of the REAL data type, the value at the "srcOffsets[i]" parameter is 88 and at the "mode" parameter 2#1, the instruction reads the values from bytes 11 to 14, starting with the least significant byte.
If, for example, the "src[i]" parameter references a tag of the BOOL data type, the value at the "srcOffsets[i]" parameter is 29, the instruction reads the value at byte 3, offset 5 of the source buffer.
The arrays at "srcOffsets" and "dst" must have the same limits to ensure that "srcOffsets[i]" contains the offset for "dst[i]".
This allows you to specify exactly which values are copied from the target buffer. However, note that the instruction does not verify whether the specified offsets overlap. An error is not signaled in this case and the read value can be random.
The "status" parameter is an Array of INT. It must have the same limits as the "dst" and "srcOffsets" parameters to ensure that "status[i]" contains the status for "dst[i]".
For WSTRING and STRING, the current length of the source string is copied. If the source string is longer than the destination string, the remaining characters of the source string are not copied.
|
Note Invalid references in the SDT "ResolvedSymbol" The references in the SDT "ResolvedSymbol" can become invalid when the referenced tags are overwritten by loading in "RUN". The references may point to tags that no longer exist. An error code at the "status" parameter indicates invalid references. In this case, resolve the symbols again with the instruction "ResolveSymbols". |
Parameters
The following table shows the parameters of the "Read values from buffer and write them into resolved symbols" instruction:
|
Parameter |
Declaration |
Data type |
Memory area |
Description |
|---|---|---|---|---|
|
firstIndex |
Input |
DINT |
I, Q, M, D, L, C |
Index of the first resolved symbol in the target buffer that is to be written. |
|
lastIndex |
Input |
DINT |
I, Q, M, D, L, C |
Index of the last resolved symbol in the target buffer that is to be written. |
|
mode |
Input |
DWORD |
I, Q, M, D, L, C |
Memory format
|
|
src |
Input |
Array of BYTE |
D, L |
Source buffer from which the values are read |
|
srcOffsets |
Input |
Array of DINT |
D, L |
Offsets of the values in the source buffer |
|
dst |
InOut |
Array of ResolvedSymbol |
D, L |
Target buffer that contains the references to the resolved symbols |
|
status |
InOut |
Array of INT |
D, L |
Contains a copy status for each value to be written |
|
Function value (RET_VAL) |
INT |
I, Q, M, D, L |
Error information |
|
You can find additional information on SDT here: System data type ResolvedSymbol
Status parameter
The following table shows the meaning of the values of the Status parameter:
|
Error code*(W#16#...) |
Explanation |
|---|---|
|
8020 |
The symbol was not resolved. |
|
8021 |
The WSTRING for the symbolic tag name is empty. |
|
8022 |
The WSTRING for the symbolic tag name contains invalid characters. |
|
8023 |
The data type declaration of the referenced tag is missing. |
|
8024 |
The reference points to a tag that no longer exists. It may have been overwritten by a loading in "RUN". |
|
8054 |
The reference points to a tag with invalid data type. |
|
80B4 |
The project is inconsistent. |
|
8031 |
dst[i]: The data block does not exist. |
|
8033 |
dst[i]: The data block is only available in the load memory and cannot be addressed by the instruction. |
|
8034 |
dst[i]: The data block is write-protected. |
|
8054 |
dst[i]: The data type of the referenced tag is not supported. |
|
8082 |
srcOffset[i]: The offset is located outside the ARRAY limits of the src parameter. |
|
8085 |
srcOffset[i]: The offset does not start at a bit position divisible by 8. |
RET_VAL parameter
The following table shows the meaning of the values of the RET_VAL parameter:
|
Error code*(W#16#...) |
Explanation |
|---|---|
|
0000 |
No error |
|
80B3 |
The value at the firstIndex parameter is greater than the value at the lastIndex parameter. |
|
80B4 |
The parameters dst, srcOffsets and status have different ARRAY limits. |
|
8182 |
The value at the firstIndex parameter is outside the limits of the ARRAY. |
|
8282 |
The value at the lastIndex parameter is outside the limits of the ARRAY. |
|
8431 |
src: The data block does not exist. |
|
8433 |
src: The data block is only available in the load memory and cannot be addressed by the instruction. |
|
8454 |
src: Invalid data type. |
|
8531 |
srcOffsets: The data block does not exist. |
|
8533 |
srcOffsets: The data block is only available in the load memory and cannot be addressed by the instruction. |
|
8554 |
srcOffsets: Invalid data type. |
|
8631 |
dst: The data block does not exist. |
|
8633 |
dst: The data block is only available in the load memory and cannot be addressed by the instruction. |
|
8634 |
dst: The data block is write-protected. |
|
8636 |
dst: The data block is not in an optimized memory area. |
|
8654 |
dst: Invalid data type. |
|
8731 |
status: The data block does not exist. |
|
8733 |
status: The data block is only available in the load memory and cannot be addressed by the instruction. |
|
8734 |
status: The data block is write-protected. |
|
8736 |
status: The data block is not in an optimized memory area. |
|
8754 |
status: Invalid data type. |
Example
The following example shows how the instruction works:
The following table shows how the instruction works using specific operand values:
|
Parameter |
Operand |
Value/Data type |
|---|---|---|
|
firstIndex |
- |
2 |
|
lastIndex |
- |
7 |
|
mode |
- |
2#0 |
|
src |
Input_Buffer |
Array[0..99] of Byte |
|
srcOffsets |
Input_Offset |
Array[0..99] of Dint |
|
dst |
InOut_ResolvedSymbols |
Array[0..99] of ResolvedSymbol |
|
status |
InOut_Status |
Array[0..99] of Int |
The values of the tags from the source buffer "Input_Buffer" are read in Big-Endian format and written to the resolved symbols via the references in "#InOut_ResolvedSymbols".
The two constants at the "firstIndex" and "lastIndex" parameters restrict the number of tags in the target buffer whose values are to be written. Based on the offset in the operand "Input_Offset", it is determined from where the value in the source buffer is being read.