Simulation variable datatypes C++?

Hello! How to know the C++ datatype of a simulation variable ?

I have successfully read the “COM ACTIVE FRECUENCY:1”, “MHz” by chance declare a double in my data-struct. However reading “ADF ACTIVE FREQUENCY:1”, “MHz” as a double fails as the value seams corrupted. In the SDK reference I see only “Units” with some information “Frequency ADF BCD32” for the ADF1, but not datatype even but it is crucial to know.

If I recall correctly, you have to specify a data type for each field when creating your data definition, so make sure you’re specifying the right type and size for the data type. The documentation indicates that SIMCONNECT_DATATYPE_FLOAT64 is the default, which should indeed be a double in C++.

https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_AddToDataDefinition.htm

I guess the question is, can that be “wrong”? :smiley: Or does it convert to the type you specify anyway?

Datatype Frequency ADF BCD32 is the data type. You probably didn’t get it wrong and it is a double in the backend, but it’s not to be read literally See Simulation Variable Units (flightsimulator.com)
COM ACTIVE FREQUENCY is BCD16 so they are encoded differently.
You might want to check ou BCD32 in C++ | FSDeveloper

Thanks for help. I solved the problem even but I not found relevant documentation. One may alternative request e.g. “Mhz” that returning double if matching the item alternatives. ADF is actually kHz and when request “ADF ACTIVE FREQUENCY:1”, “kHz" it returns a valid correct double value.