16384 != 16383

According to the offset description:

  • wheel status is controlled by a 2 byte storage
  • wheel status is defined in offset ox0BE8
  • all wheels up should be stored internally as decimal value ‘0‘.
  • all wheels down should be stored internally as decimal value ‘16383

A. Wheels up.

That seems OK in the code below. ‘0’ is probably the lowest value a two byte array can store. So far so good…

public void GearUp()
    {
    byte[] data = new byte[2];
    data[0] = 0; //0000 0000 binary (0x00 hexadecimal)
    data[1] = 0; //0000 0000 binary (0x00 hexadecimal)
    fsuipc_wrapper.WriteData(0x0BE8,2,data); //0000 0000 0000 0000 (0 decimal, OK.)
    }

B. Wheels down

When I take a closer look at the sample code, the code seems to be sending value ‘16384’, and still this thing is working. Maybe the thing just verifies if the value is >=16383?

public void GearDown()
    {
    byte[] data = new byte[2];
    data[0] = 0x00; //0000 0000 binary (0 decimal)
    data[1] = 0x40; //0100 0000 binary (64 decimal)
    fsuipc_wrapper.WriteData(0x0BE8,2,data);// 0100 0000 0000 0000 binary (16384 decimal, while the expected value is 16383)
    }

Wouldn’t the code below be correcter?

public void GearDown_Corrected()
      {
      byte[] data = new byte[2];
      data[0] = 0xFF; //1111 1111 binary (255 decimal)
      data[1] = 0x3F; //0011 1111 binary (63 decimal)
      fsuipc_wrapper.WriteData(0x0BE8,2,data);// 0011 1111 1111 1111 binary (16383 decimal)
      }

Further: why are all examples using hexadecimal notation for the offset and it’s value?

1 comment

Leave a Reply

Your email address will not be published. Required fields are marked *