Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Got Problem to read the Autopilot altitude !

my envioroment:VS2008 FSX FSUIPCV4.2

the Autopilot altitude value explained in the manual:FSUIPC4 Offsets Status.pdf

07D4 4 Autopilot altitude value, as metres*65536 Ok Ok

in my project

I declare a struct:

struct AUTOPILOT

{

int Status[6];

UINT uHDG;//heading

TCHAR szHDG[256];

DWORD dwALT;//altitude

TCHAR szALT[256];

UINT uAS;//air speed

TCHAR szAS[256];

long lVS;//vertical speed

TCHAR szVS[256];

}AP;

and I use the following function to get the value of AP' altitude:

if (!FSUIPC_Read(0x07D4,2, &AP.dwALT, &dwResult) ||

// If we wanted other reads/writes at the same time, we could put them here

!FSUIPC_Process(&dwResult)) // Process the request(s)

{

SetDlgItemText(hwnd,IDC_EDIT_AP_ALT,TEXT("FAIL"));

}

else

{

wsprintf(AP.szALT,TEXT("%05d"),AP.dwALT/65536);

SetDlgItemText(hwnd,IDC_EDIT_AP_ALT,AP.szALT);

}

but the AP.szALT always get the "00000"

I make a break point on the "else" line,and check the value of the AP.dwALT in the debug mode,which I read in the offset 0x07D4.

It's so weird,when the AP altitude valued in the FSX is 100,I got 31457(decimal system) from the AP.dwALT,more showed below:

FSX AP.szALT (decimal system)

0 00000

100 31457

200 32915

300 28836

1000 52428

99900 34048

I dont know what is going wrong with my code and very confuse about this. :oops:

Very appreciate if somebody Colud help me!

Posted

07D4 4 Autopilot altitude value, as metres*65536 Ok Ok

offset 07D4 is 4byte value,I dont know how can I miss this!

Stay up late to work is not wise. :mrgreen:

here is the right function:

if (!FSUIPC_Read(0x07D4,4, &AP.dwALT, &dwResult) ||
// If we wanted other reads/writes at the same time, we could put them here
!FSUIPC_Process(&dwResult)) // Process the request(s)
{
SetDlgItemText(hwnd,IDC_EDIT_AP_ALT,TEXT("FAIL"));
}
else
{
wsprintf(AP.szALT,TEXT("%05d"),AP.dwALT/65536);
SetDlgItemText(hwnd,IDC_EDIT_AP_ALT,AP.szALT);
}

Posted
my environment:VS2008 FSX FSUIPCV4.2

I hope FSUIPC 4.2 is a typo, if it's not then you are about 3 years out of date. Pete is away till Monday but I can tell you now he wont offer support to anyone using software that is 3 years out of date. Please see the post below to get the latest version of FSUIPC, you will need to download the 4.6 installer first then apply the interim update afterwards if you wish.

http://forums.simflight.com/viewtopic.php?f=54&t=74352

I'm glad you sorted your problem out though :D

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.