Currently it is assumed that the payload being decoded is not corrupt.
Also it assumes the Byte Order of the PLC is Intel (Little-endian).
Note the Byte Order of the Payload must be Little-endian.
Perhaps use a MemUtils.ByteBuffer to accomplish both goals.
__SYSTEM could return the Endianness of the architecture the software is running on. We could read Endianness once and store it somewhere (GVL?) for immediate retrieval. This way we could reference it in code to determine Little or Big without calling __SYSTEM everytime. I think it could or allready is also part of the Edge Properties which we send to the Primary Host.
Last edit: hermsen 2022-05-03
https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_pragma_conditional.html
defined (IsLittleEndian)
The operator causes the expression to be given the value FALSE when the CPU memory is organized in Big Endian (Motorola byte order).