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.
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;
}
}
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.
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;
}
}


