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

Requesting Data from SimConnect

Messages
7
Country
us-california
Hello,
I posted a thread a few days ago about a problem I am having with requesting data from FSX. I am working with the sample program Request Data from the SDK. This section of code (pasted below) has four main cases. It seems as if the code is defaulting to the last case. The debug window says:

Connected to Flight Simulator!
Received:2.

SIMCONNECT_RECV_ID=2 is SIMCONNECT_RECV_ID_OPEN

I would like the program to choose case 2, which is where REQUEST_1 is located. This section of code takes the Struct1 data and prints it to the debug screen.

I have build a G1000, GNS430/530 and Avidyne Entegra for X-Plane using the build-in UDP to transfer the data. Now, we are trying to convert this software so that it runs on Microsoft Flight Sim also.

Your help would be greatly appreciated.:confused:

Cut and Paste of sample REQUEST DATA code:
----------------------------------------------------
void CALLBACK MyDispatchProcRD(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)
{
HRESULT hr;

switch(pData->dwID)
{
case SIMCONNECT_RECV_ID_EVENT:
{
SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData;

switch(evt->uEventID)
{
case EVENT_SIM_START:

// Now the sim is running, request information on the user aircraft
hr = SimConnect_RequestDataOnSimObjectType(hSimConnect, REQUEST_1, DEFINITION_1, 0, SIMCONNECT_SIMOBJECT_TYPE_USER);

break;

default:
break;
}
break;
}

case SIMCONNECT_RECV_ID_SIMOBJECT_DATA_BYTYPE:
{
SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE*)pData;

switch(pObjData->dwRequestID)
{
case REQUEST_1:
{
DWORD ObjectID = pObjData->dwObjectID;
Struct1 *pS = (Struct1*)&pObjData->dwData;
if (SUCCEEDED(StringCbLengthA(&pS->title[0], sizeof(pS->title), NULL))) // security check
{
printf("\nObjectID=%d Title=\"%s\"\nLat=%f Lon=%f Alt=%f Kohlsman=%.2f", ObjectID, pS->title, pS->latitude, pS->longitude, pS->altitude, pS->kohlsmann );
}
break;
}

default:
break;
}
break;
}


case SIMCONNECT_RECV_ID_QUIT:
{
quit = 1;
break;
}

default:
printf("\nReceived:%d",pData->dwID);
break;
}
}
 
This might be a order of running the program issue.

If you just use the debug run in visual studio and FSX is not running, you get the cmd window appear and disapear.

If FSX is running you get what you described. In order to get the EVENT_SIM_START to trigger you will have to

1. start FSX and wait till it finishs loading and you have loaded a flight (or fly now) then start the program via run debug

or

2. when in FSX and you are actually flying an aircraft, press esc and instead of end flight press Continue flying.

It should display the string data. The SDK example works for me.
 
FSX is running

That is weird. I DID have FSX flying an airplane when I started the program with the debug screen. I DID NOT try the esc, then continue flying option.

Does it matter what settings I have in SimConnect.XLM, or SimConnect.cfg? I am running FSX and Visual Studio on the same computer.

I will try again and see if it works this time.:confused:
 
It works now!

wow, it works now!!
It looks like the only time it samples the data is when I hit escape key, then continue button. It only samples the data once. I assume this is how the Request Data sample program is supposed to work. Is that correct?
 
wow, it works now!!
It looks like the only time it samples the data is when I hit escape key, then continue button. It only samples the data once. I assume this is how the Request Data sample program is supposed to work. Is that correct?

You are using the call to request data about what objects there are, i.e. SimConnect_RequestDataOnSimObjectType

This is the one you use primarily to obtain the IDs of objects in the vicinity. You'll only get the returns when the objects change, NOT when the data included changes. When you use "ESC" etc you are effectively refreshing the Flight, so you get the data again. That is all.

For data about an object, like its position etc etc, regularly updated as you like, you should be using:

SimConnect_RequestDataOnSimObject

As it says in the documentation, this function is used to request when the SimConnect client is to receive data values for a specific object. In particular, check out the "Period", "Flags" and "interval" parameters for this.

Regards

Pete
 
Thanks for your support.

I am finding some major differences between the way we sample data from X-Plane, and the way we will have to do it for FSX. For example, there are no EVENTS in X-Plane. It is all just considered data. The "Events" in X-Plane are just coded as integers like 0,1,2,3. Each digit defines a different state for some functionality in X-Plane.... like the autopilot (0=off, 1=flight director only, 2=autopilot ON). I believe this would be an EVENT in FSX. The the G1000, GNS430 and other avionics panels that we have, I assume we will be sending Event instructions TO FSX, and receiving data streams FROM FSX. In X-Plane, we had to build the GPS virtually from scratch, however FSX has most of these variables all ready build in. (Like CDI scaling for each phase of flight: Depature, Enroute, and Appoach) Hopefully, we won't have to modify our models very much if we can leave the internal variables alone, and just refer to a lookup/translation table that sends the correct events, and receives the correct data.

But I am looking forward to providing FSX users with the same avionics we have for X-Plane.
 
The Request Data sample is set up to only gather the information on sim start as it uses:-

EVENT_SIM_START

as the EVENT_ID, however if you check in the SDK there are other values you can use including:-

EVENT_RECUR_4SEC

which requests the data every 4 seconds, there are also options for every second, six times a second, when a view is changed etc.
 
Back
Top