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

FSX With FSX, Simconnect and VS C++. READ Simulation Variables

Messages
19
Country
spain
After a while I return with my homemade simulator. With FSX, Simconnect and VS C++.
From what the SDK says it is these but I don't get any reading.
From other variables that I have configured, it works.
TRAILING_EDGE_FLAPS_LEFT_ANGLE
AUTOPILOT_AUTO_THROTTLE_ARM
AUTOPILOT_FLIGHT_DIRECTOR_ACTIVE
Can someone guide me. Thank you.
example:
C++:
static enum DATA_NAMES {
    AUTOPILOT_FLIGHT_DIRECTOR_ACTIVE,
    AUTO_BRAKE_SWITCH_CB,
    GEAR_CENTER_POSITION,
//--------
hr = SimConnect_AddToDataDefinition(SimuConmutaGethSimConnect, DEFINITION_ComuGet, "AUTOPILOT FLIGHT DIRECTOR ACTIVE", "Bool ",
            SIMCONNECT_DATATYPE_FLOAT32, 0, AUTOPILOT_FLIGHT_DIRECTOR_ACTIVE);
    
hr = SimConnect_RequestDataOnSimObject(SimuConmutaGethSimConnect, REQUEST_ComuGet, DEFINITION_ComuGet,
            SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SIM_FRAME,
            SIMCONNECT_DATA_REQUEST_FLAG_CHANGED | SIMCONNECT_DATA_REQUEST_FLAG_TAGGED);
    
    //-------------------------
                case SIMCONNECT_RECV_ID_SIMOBJECT_DATA:
            {
                SIMCONNECT_RECV_SIMOBJECT_DATA *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA*)pData;
                    switch (pObjData->dwRequestID)
                    {
                        case REQUEST_ComuGet:
                        {    int    count = 0;
                            StructDatum *pS = (StructDatum*)&pObjData->dwData;
                            while (count < (int)pObjData->dwDefineCount)
                            {
                                Sleep(5); //<<<<----------------------------------------------------------------
                                switch (pS->datum[count].id)
                                {
                                case AUTOPILOT_FLIGHT_DIRECTOR_ACTIVE:
                                    printf("\n AUTOPILOT FLIGHT DIRECTOR ACTIVE   = %02.0f\n", (pS->datum[count].value));
                                    cuantos = sprintf_s(bufferFormat, "L04%02d", (pS->datum[count].value));
                                    break;
 
AUTOPILOT FLIGHT DIRECTOR ACTIVE is a boolean, so the result is either a one or a zero. Try %1d and also be sure that the autopilot is turned ON.
Same for AUTOPILOT_AUTO_THROTTLE_ARM.
TRAILING_EDGE_FLAPS_LEFT_ANGLE is in radians. If you want it in degrees, convert it using the following formula: degrees = radians * (180.0 / 3.141592)
 
Grateful for your response.
Maybe I didn't express the problem well or I didn't understand your answer.
My problem is that I don't receive data for those variables when I toggle the FlyDirector or AUTARM switch on or off in FSX with the mouse.
I don't go through this one: case SIMCONNECT_RECV_ID_SIMOBJECT_DATA:
Not even with a BREAKPOINT, do I detect the step, with the other variables in that same group yes, with this three nothing at all.
The printf should present the literal and the data wrongly or correctly, you are right about that.
This makes me think that the problem is either poorly defined or the literals are not correct.
Thank you.
 
That may be your problem. Please check the spelling of the variables and make sure that you don't have any extra spaces in the names, either at the beginning of the name or at the end of it.
 
Since you're only showing very small code snippets... I suspect the actual issue is in the code you're not showing.
 
Exactly, the problem is a space. "Bool " :banghead:
It is not good to do things alone, it is always better to comment, especially with people with experience.
Thanks for your help.
 
I would not have considered the space after the unit designation to be an issue... how horribly sloppy of L-M/Microsoft to allow that to exist.
 
Back
Top