1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

P3D v3 How to use execute_calculator_code function to read GPS Variables (C:fs9gps) in any aircraft?

Discussion in 'SimConnect' started by laiyokabc, 20 Mar 2017.

  1. laiyokabc

    laiyokabc

    Joined:
    20 Mar 2017
    Messages:
    3
    Country:
    china
    Hi,
    I hope that use c++ language to read GPS Variables (C:fs9gps) in any aircraft,My code is based on the example of P3D C++/XML Mixed Mode Sample 'CabinComfort' modification,I met two problems:

    1.The Sample code only used to one aircraft(The sample is Mooney_Bravo),I hope that in any aircraft.

    2.I try to create a separate thread to call execute_calculator_code function, P3D(V3.1 version) after completion of loading always crash. This is my code snippet:

    Code:
    bool    bStart = false;
    HANDLE hMyMainThread = NULL;
    void  My_main(void* pArguments);
    void FSAPI  module_init(void)
    {
        if (NULL != Panels)
        {
            ImportTable.PANELSentry.fnptr = (PPANELS)Panels;
            CABINPanelCallbackInit();
            bStart = true;
            hMyMainThread = (HANDLE)_beginthread(My_main, 0, NULL);        //Create a separate thread to call execute_calculator_code function
        }
    }      
    
    void FSAPI  module_deinit(void)
    {
        bStart = false;
        WaitForSingleObject(hMyMainThread, 1000);
        CABINPanelCallbackDeInit();
    }
    void  My_main(void* pArguments)
    {
        while (bStart)
        {
            FLOAT64 att_pitch = 0;
            FLOAT64 att_bank = 0;
            PCSTRINGZ    WaypointAirportICAO;
            execute_calculator_code ("(A:ATTITUDE INDICATOR PITCH DEGREES:2, degrees)", &att_pitch, NULL, NULL);    //P3D(V3.1 version) after completion of loading always crash
            execute_calculator_code ("(A:ATTITUDE INDICATOR BANK DEGREES:2, degrees)", &att_bank, NULL, NULL);        //P3D(V3.1 version) after completion of loading always crash
            execute_calculator_code("(C:fs9gps:WaypointAirportICAO, String)",NULL,NULL,&WaypointAirportICAO);        //P3D(V3.1 version) after completion of loading always crash
            Sleep(10);
        }
    }
    
    Is there a better way, only need .DLL file, without the XML file?
    If there is a use of c++ execute_calculator_code function to get GPS Variables (C: fs9gps) example is the best!

    thanks,
    Yorke
     
  2. taguilo

    taguilo Resource contributor

    Joined:
    20 Oct 2006
    Messages:
    1,482
    Country:
    argentina
  3. laiyokabc

    laiyokabc

    Joined:
    20 Mar 2017
    Messages:
    3
    Country:
    china
    Thank you Tom,This post, help me solve a lot of questions.:)
     

Share This Page