• 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.

Problem Reading various Bool values

Messages
16
Country
us-california
I have created a program to interface with BetaInnovations Gammatron. I have one device that emulates the G1000 and everything is working fine. I have another device for switches like lights, deice, battery etc. which I am having some difficulty.

In my code I read some values for heading, kohlsman, nav radials and then use those to perform some processes. These work fine. I added several variables that are bools and they do not retrun the proper values. For example pitot heat is always false regardless of the switch position. I am using the no callback method. Here is some relevent code. Any Ideas?

struct Struct1
{
double headingn;
double kohlsmann;
bool pitotheatn;
};

hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_READ, "Heading indicator", "Degrees");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_READ, "Kohlsman setting MB", "Millibars");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_READ, "Pitot Heat", "Bool", SIMCONNECT_DATATYPE_FLOAT32);

hr = SimConnect_RequestDataOnSimObject(hSimConnect, REQUEST_READ, DEFINITION_READ, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_ONCE);

hr = SimConnect_GetNextDispatch(hSimConnect, &pData, &cbData);

case SIMCONNECT_RECV_ID_SIMOBJECT_DATA:
{
SIMCONNECT_RECV_SIMOBJECT_DATA *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA*) pData;

case REQUEST_READ:
{
Struct1 *pS = (Struct1*)&pObjData->dwData;
 
Last edited:
I had one of my professional business and robotics apllication programmers come in and look for me. We had it working in five minutes. The solution is to use doubles in the struct statement. Appearantly, bools are not recongnized properly in the SDK.
 
I had one of my professional business and robotics apllication programmers come in and look for me. We had it working in five minutes. The solution is to use doubles in the struct statement. Appearantly, bools are not recongnized properly in the SDK.

That's a bit wasteful. All BOOLeans are kept as 32-bit integers internally.

I think what is happening here is a mix up in understanding the difference between the UNITS of a value being returned, and how it is stored. The "Bool" part of the request merely specifies the units (like feet or metres elsewhere). The TYPE of the value returned is specified by the data type parameter.

You should define the data type for a "Bool" as "SIMCONNECT_DATATYPE_INT32", that is all.

In the example, it might have actually worked if the "SIMCONNECT_DATATYPE_FLOAT32" type requested actually matched the data type declared in the struct:

struct Struct1
{
double headingn;
double kohlsmann;
bool pitotheatn;
};

A C/C++ "bool" is an INT32, not a FLOAT32. In C/C++ you define FLOAT32 by "float", if that's what you really want, though obviously a floating point value for something which is either 0 or 1 is wasteful.

Regards

Pete
 
Last edited:
Makes since and that was what we discovered. In my blind rage to solve this issue after several hours I did not even see the int32 type. That is why another set of eyes always works. Thanks.
 
Back
Top