Results 1 to 4 of 4
Thread: lat/alt/lon from FSX
-
10-27-2008, 08:45 AM #1
- Join Date
- Sep 2008
- Location
- Barcelona
- Posts
- 4
lat/alt/lon from FSX
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.
-
10-27-2008, 04:32 PM #2
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 );
}
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
CheersDave Ault
http://www.learjet45chimera.co.uk
-
10-28-2008, 03:16 AM #3
- Join Date
- May 2008
- Location
- Earth
- Posts
- 288
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
SimConnect1.jpg
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"?Fritz -> Helicopter Cockpit Builder
(FSX | TH2Go | Arduino | Air Manager Avionics | CNC)
-
10-28-2008, 03:26 AM #4
- Join Date
- May 2008
- Location
- Earth
- Posts
- 288
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.Fritz -> Helicopter Cockpit Builder
(FSX | TH2Go | Arduino | Air Manager Avionics | CNC)
Experience carefree connections with the top-rated site for casual dating adventures. Verified...
Run-Time Check # 0 - The value of...