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

Retrieving strings with Simconnect

Messages
45
Country
france
Hello,

I am successfully using SimConnect to get many numerical data, such as coordinates, speeds, frequencies, ... I used the tagged format and it works perfectly well.
Now I wanted to retrieve the plane model and type, so I tried to get the "ATC TYPE", "ATC MODEL" and "TITLE" variables, which are strings.
I tried to follow the exact same approach by requesting them as tagged data, declaring the proper variable type in my code, but never get a result; my code in the dispatch procedure is never called. Here are excerpts below to clarify what I am doing :

Is there a problem with string data or these particular data in MSFS2020 Simconnect ?



data :
struct stringDatum {
int id;
char str[256];
};

static enum DATA_DEFINE_ID {
DEFINITION_PDR,
DEFINITION_STR,
};

static enum DATA_REQUEST_ID {
REQUEST_FLOAT, // for numerical data
REQUEST_STRING, // string data
};

static enum DATA_NAMES {
DATA_PLANE_TYPE,
DATA_PLANE_MODEL,
DATA_PLANE_TITLE,
....

Here is the addition of the previous data to the definition for string data
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_STR, "ATC TYPE", "NULL",
SIMCONNECT_DATATYPE_STRING256, 0, DATA_PLANE_TYPE);
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_STR, "ATC MODEL", "NULL",
SIMCONNECT_DATATYPE_STRING256, 0, DATA_PLANE_MODEL);
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_STR, "TITLE", "NULL",
SIMCONNECT_DATATYPE_STRING256, 0, DATA_PLANE_TITLE);


Then the request is made following :

hr = SimConnect_RequestDataOnSimObject(hSimConnect, REQUEST_STRING, DEFINITION_STR,
SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_ONCE,
SIMCONNECT_DATA_REQUEST_FLAG_CHANGED | SIMCONNECT_DATA_REQUEST_FLAG_TAGGED);


And results are collected in the dispatch procedure by :

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

switch (pObjData->dwRequestID)
{
case REQUEST_STRING:
{
int count = 0;
structDatumStrings* pS = (structDatumStrings*)&pObjData->dwData;

while (count < (int)pObjData->dwDefineCount)
{
switch (pS->datum[count].id)
{
case DATA_PLANE_MODEL:
g_planeMODEL = pS->datum[count].str;
break;

case DATA_PLANE_TYPE:
g_planeTYPE = pS->datum[count].str;
break;

case DATA_PLANE_TITLE:
g_planeTITLE = pS->datum[count].str;
break;
}
}
++count;
}// End REQUEST_STRING

BUT this is never reached !
 
I have also unsuccessfully tried to receive text string from MSFS. Guess it is not working in current SDK version.
Read this thread.
 
With SDK version 0.10.0 there are many SimConnect Samples. Inside "Request Data" there is a working "Title" string request. The request DatumType parameter is SIMCONNECT_DATATYPE_STRING256, but documentations states that Title has type SIMCONNECT_DATATYPE_STRINGV (Variable length string).
 
Back
Top