PDA

View Full Version : lat/alt/lon from FSX



DiscDur
10-27-2008, 08:45 AM
Hey ,

Can Anybody help me for How I can take Lat/Lon/Alt from FSX using simconnect and C#.
I'm using the examples are in sdk examples but I can't take that information.

Thank's.
Anton.

TasKiNG
10-27-2008, 04:32 PM
Hi Anton,

I have never used C# but thought you might find it useful to see how I would do it in C. This requires FSX to be running FSUIPC.


#include < stdio.h >
#include < stdlib.h >
#include < windows.h >
#include "FSUIPC_User.h"


double longitude, latitude, altitude;

DWORD dwResult;

int main( void )
{
while (!FSUIPC_Open(SIM_ANY, &dwResult) ) Sleep( 1000 ); //try to connect to sim every second

if(!FSUIPC_Read(0x6010, 8, &latitude, &dwResult) || !FSUIPC_Process(&dwResult)) { FSUIPC_Close(); return( -1 ); }
if(!FSUIPC_Read(0x6018, 8, &longitude, &dwResult) || !FSUIPC_Process(&dwResult)) { FSUIPC_Close(); return( -1 ); }
if(!FSUIPC_Read(0x6020, 8, &altitude, &dwResult) || !FSUIPC_Process(&dwResult)) { FSUIPC_Close(); return( -1 ); }

printf( "Latitude = %f\n", latitude );
printf( "Longitude = %f\n", longitude );
printf( "Altitude(meters) = %f\n\n", altitude );

FSUIPC_Close();
return( -1 );
}

You need to specify the FSUIPC_User.lib file when you compile it.
The FSUIPC_User.h & FSUIPC_User.lib file were from the FSUIPC SDK

When the above program is run I get the following ( when on EGNX Runway ):-


Latitude = 52.831377
Longitude = -1.307392
Altitude(meters) = 94.595764

Not C# but hope this helps

Cheers

fweinrebe
10-28-2008, 03:16 AM
Can Anybody help me for How I can take Lat/Lon/Alt from FSX using simconnect and C#.
I'm using the examples are in sdk examples but I can't take that information.

I looked at the C# project in the FSX SDK for you and it work 100% without any modifications. (Apart from upgrading the C# project to the version I use ie. Visual C# 2008 Express) This is the project I used:
[SDK Install Path]\Core Utilities Kit\SimConnect SDK\Samples\Managed Data Request\Managed Data Request

1159

For it to work make sure that the FSX SDK is installed properly otherwise it will not work. The installation instructions is in the folder:
[SDK Install Path]\Core Utilities Kit\SimConnect SDK\SimConnect.htm file.

Or what did you mean by "I can't take that information"?

fweinrebe
10-28-2008, 03:26 AM
I have never used C# .... :(

C# is actually a nice language to program in. I use it together with GDI+ to program my gauges for the Pilatus PC-9M. You should give it a try if you are used to C and C++.

Sofar I've had had great success with GDI+ to create a PFD and EICAS for the PC-9M. Even to integrate the PIC18F4550 via USB to FS2004.