Jump to content
The simFlight Network Forums

Recommended Posts

Posted (edited)

Using this code in C# (.NET v4) i get very strange outputs from the "on ground flag".

        public int getIsOnGround()
        {
            bool result = false;
            int dwResult = -1;
            int token = -1;
            result = fsuipc.FSUIPC_Read(0x0366, 2, ref token, ref dwResult);
            result = fsuipc.FSUIPC_Process(ref dwResult);
            result = fsuipc.FSUIPC_Get(ref token, ref dwResult);
            
            return dwResult;
        }

This is from a test I did with FSX:

Before first takeoff: 1

After takeoff: 262145

After landing: 262144

After new takeoff: 262145

After landing: 262144

 

What am I doing wrong?

 

Best regards,

Even

Edited by Even92LN
Posted (edited)

Hi Even,

 

Offset 0x0366 is only 2 bytes.  You're copying the value into dwResult which is 4 bytes (int).  This means only the lower 2 bytes are getting updated by the C# SDK you are using so you've got the bad values.

 

The best solution here is to use the correct length integer (2 bytes called 'short' in C#) to receive the value.  I think the following code will work but this isn't my SDK so I'm not very familiar with it.

 

public short getIsOnGround()
        {
            bool result = false;

            short onGround = 0;
            int dwResult = -1;
            int token = -1;
            result = fsuipc.FSUIPC_Read(0x0366, 2, ref token, ref dwResult);
            result = fsuipc.FSUIPC_Process(ref dwResult);
            result = fsuipc.FSUIPC_Get(ref token, ref onGround);
            return onGround;
        }

Edited by Paul Henty

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.