forked from PLC-lang/rusty
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(stdlib): Endian conversion functions (PLC-lang#1029)
Currently endian conversion functions work mostly very wrong. Also most of the test would also break in BE system. Only TO_*_ENDIAN() for other than float types does what they should. FROM_*_ENDIAN() for other than float types does conversion totally wrong. Normally we would do in IEC something like this (PSEUDO): address := FROM_LITTLE_ENDIAN(READ_MODBUS_ADDRESS_DWORD()); Now we would get big endian address even if we just wanted to document that we have checked that address should be little endian. In companies it is happit that every time they read/write to/from fieldbus they use FROM_*_ENDIAN/TO_*_ENDIAN conversion functions so it is obvious that it has been taken to account. Also floating points did not do any conversions as they first convert to x endian and then convert back to native. I also improve unittests so it is now obvious that when we do not touch res we should do same conversion for the some value. Co-authored-by: Kari Argillander <[email protected]> Co-authored-by: Michael <[email protected]>
- Loading branch information
1 parent
ea718d2
commit 2da66ec
Showing
3 changed files
with
132 additions
and
112 deletions.
There are no files selected for viewing
44 changes: 24 additions & 20 deletions
44
libs/stdlib/iec61131-st/endianness_conversion_functions.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.