Big/Small Endian
Ronen
Posts: 55
Hi All,
I'm trying to understand a string i'm getting from an air-condition system using modbus.
when i'm getting the "Set Point" Hex value i'v been told that it's a float number using big endian.
so, i need to convert from Big Endian to Small Endian.
I understand it's somthing with bit shifting, anyone have any idea?
or better... an example...
Thanks
I'm trying to understand a string i'm getting from an air-condition system using modbus.
when i'm getting the "Set Point" Hex value i'v been told that it's a float number using big endian.
so, i need to convert from Big Endian to Small Endian.
I understand it's somthing with bit shifting, anyone have any idea?
or better... an example...
Thanks
0
Comments
I have found my answer on the internet and wrote the following:
define_function integer fuBigEndian2Small(integer i)
{
return (((i >> 8)) | (i << 8))
}
it works fine but while i'm compiling i'm getting the following error:
WARNING: C:\Modules\IP\havc\Dalkia - Unisense\Dalkina - Unisense Demo.axs(152): C10571: Converting type [LONG] to [INTEGER]
any idea why?
If you are sure that it works OK for the full range of possible inputs, then adding a type_cast makes the warning message go away.
A type_cast is sometimes required in situations like these; just put it in and move on with life.
BTW you have more parentheses than you need on the LHS.
Well,
I'm using this function as we speak and it seems to work fine.
I'm gonna put my eye on it, but, as you said, move on with my life
Thanks for the help