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!