Results 1 to 4 of 4
  1. #1
    New Member
    Join Date
    Sep 2008
    Location
    Barcelona
    Posts
    4
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    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.

  2. #2
    75+ Posting Member TasKiNG's Avatar
    Join Date
    Jul 2008
    Location
    Derby, England
    Posts
    143
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    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

  3. #3
    Heli Builder fweinrebe's Avatar
    Join Date
    May 2008
    Location
    Namibia
    Posts
    325
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Quote Originally Posted by DiscDur View Post
    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

    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 | C# Avionics | CNC)

  4. #4
    Heli Builder fweinrebe's Avatar
    Join Date
    May 2008
    Location
    Namibia
    Posts
    325
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Quote Originally Posted by TasKiNG View Post
    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.
    Fritz -> Helicopter Cockpit Builder
    (FSX | TH2Go | Arduino | C# Avionics | CNC)

Tags for this Thread