• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

P3D v4 Simconnect Data Requests.

Messages
40
Country
netherlands
Hi, ive been trying to get altitude from the simulator using data requests. I've been following the SDK example and SDK documentation but ran into a problem. My results are not the same in WPF as it is in a WinForms example. Here is my data request code:

The problem i'm having it that my result from the datarequest is : 7.8359836439297E-67
while the result should be around: 1000 feet...

C#:
            simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Altitude", "feet", SIMCONNECT_DATATYPE.FLOAT64, 0,SimConnect.SIMCONNECT_UNUSED);

            // IMPORTANT: register it with the simconnect managed wrapper marshaller
            // if you skip this step, you will only receive a uint in the .dwData field.
            simconnect.RegisterDataDefineStruct<Struct1>(DEFINITIONS.Struct1);

            // catch a simobject data request
            simconnect.OnRecvSimobjectDataBytype += new SimConnect.RecvSimobjectDataBytypeEventHandler(simconnect_OnRecvSimobjectDataBytype);


C#:
 switch ((DATA_REQUESTS)data.dwRequestID)
            {
                case DATA_REQUESTS.REQUEST_1:
                    Struct1 s1 = (Struct1)data.dwData[0];


                    uint u = Convert.ToUInt32(s1.altitude);
                    AltitudeTXT.Text = s1.altitude.ToString();

                    break;

                default:
                   
                    break;
            }
 
Messages
138
Country
ca-britishcolumbia
Hi Sniperfull,

Are you sure you're requesting the data at some point using "simconnect.RequestDataOnSimObjectType(...)"?
Also, is there any specific reason to cast it to an Unsigned int there? I didn't see you using 'u' later. Remember that you are converting a double (64-bit) to an unsigned Int 32-bit. You might loose some data I guess.
Moreover, make sure your struct has the same configuration as the data definitions you are registering. For instance, if you have more than the altitude there, you should register them too and in the same order, to be able to receive the same struct back from SimConnect.

7.8359836439297E-67 is actually almost zero.

Cheers,

Jorge.
 
Messages
40
Country
netherlands
Hi Sniperfull,

Are you sure you're requesting the data at some point using "simconnect.RequestDataOnSimObjectType(...)"?
Also, is there any specific reason to cast it to an Unsigned int there? I didn't see you using 'u' later. Remember that you are converting a double (64-bit) to an unsigned Int 32-bit. You might loose some data I guess.
Moreover, make sure your struct has the same configuration as the data definitions you are registering. For instance, if you have more than the altitude there, you should register them too and in the same order, to be able to receive the same struct back from SimConnect.

7.8359836439297E-67 is actually almost zero.

Cheers,

Jorge.


Hi Amengol,
the 'u' convertion was something i was just playing around with... that should be ignored. And yes i am using "simconnect.RequestDataOnSimObjectType(...)" when requesting data. Like i said this is code from the sdk example that i cannot get working in WPF... when trying in a normal WinForms it works perfectly, the issue is when i use it in WPF.
 
Top