- Messages
- 45
- Country

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 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 !
