• 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 returning incorrect data in WPF c# application.

Messages
40
Country
netherlands
when using same code from the managed data request sample from the SDK i do not receive the same results.


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);

Only thing that is different from the original SDK sample is WndProc this is my WndProc:

C#:
  private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            // report that Win32 event is not handled.
            handled = false;

            switch (msg)
            {
                case WM_USER_SIMCONNECT:
                    {
                        if (simconnect != null)
                        {
                            simconnect.ReceiveMessage();
                            handled = true;
                        }
                    }
                    break;

                default:
                    break;
            }
            return (IntPtr)0;
        }

problem is i receive wayy off results, such as : 7.835953401658903E-67 when it should be around 400 feet.
im lost i do not know what i could do about this, anyone that knows anything about such thing please let me know.
 
Did you see this in the SDK? in the Managed SimConnect Projects section.


simconnect.RegisterDataDefineStruct<Struct1>((uint)DEFINITIONS.Struct1);

Not at my computer to check if it makes a difference.

HTH
 
Did you see this in the SDK? in the Managed SimConnect Projects section.


simconnect.RegisterDataDefineStruct<Struct1>((uint)DEFINITIONS.Struct1);

Not at my computer to check if it makes a difference.

HTH
Cant actually do that, i've seen that part of the documentation but i cant use a uint becuase :
http://prntscr.com/jlq86b
cant convert uint to enum...
 
I think you mangled things by wanting to use WPF since I have seen nothing from L-M regarding using that type of C# app. Since SimConnect is not likely to have actually returned incorrect data, the error is most likely in your code. Every time I have seen an error like what you're reporting it has been a data size issue. Somewhere in your code a data size is defined incorrectly. The hard part will be figuring out where.
 
Back
Top