Simconnect Indicated Airspeed at Half?


Does someone have an example of pulling values from simconnect correctly (This is example is C#)? Nothing sent from sim connect seems to match the panel (C172). The indicated airspeed is the most glaringly wrong at roughly half of what’s displayed on the panel, but throttle position and whiskey compass values also seem to be quite a bit off.

I expect you are either reading the value with incorrect data types or the structure you are reading them in to does not match.

Here is an example of how to read the IAS correctly:

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct Definition1Struct
{
    public double IAS;
};
Definition1Struct Definition1;

void RegisterStructures(SimConnect _Obj)
{
_Obj.AddToDataDefinition(Definition1, “AIRSPEED INDICATED”, “Knots”, SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
}

Notice the “Knots” request unit which is put in to a FLOAT64, and the struct has a respective double type for the FLOAT64.

Edit: If you have a struct that is reading a number of variables, but you don’t have the data types correct, the read data will underflow or overflow, causing odd readings for the rest of the data. i.e., if you request a FLOAT64, make sure it goes to a double in the struct, and an INT32 to an int in the struct, etc.

Thank you for the code example! It made me realize that I need to pass in the desired unit instead of null to get the correct result. The docs made it sound like the number I’d get back from simconnect were in knots, not that I had to request that unit.

looks like it is reporting in meters per second

image