Even92LN Posted November 24, 2013 Report Posted November 24, 2013 (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 November 24, 2013 by Even92LN
Paul Henty Posted November 24, 2013 Report Posted November 24, 2013 (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 November 24, 2013 by Paul Henty
Even92LN Posted November 25, 2013 Author Report Posted November 25, 2013 (edited) Thanks alot, Paul! I will give it a try! EDIT: Looks like that did the trick. Thanks for your help! Edited November 30, 2013 by Even92LN
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now