Home AMX User Forum AMX General Discussion

Big/Small Endian

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

Comments

  • RonenRonen Posts: 55
    well, found my answer

    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?
  • Ronen wrote:
    it works fine but while i'm compiling i'm getting the following error:
    WARNING: ... Converting type [LONG] to [INTEGER]

    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.
  • RonenRonen Posts: 55
    Seems to work fine

    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
Sign In or Register to comment.