May 24, 200719 yr Hello together!I'm almost sure before SP1 my Code was working. But since SP1 anything goes wrong and i get some funny (or worst) Values. So, i post some Code here. I hope anyone of has an Idea whats going wrong:case PANEL_SERVICE_PRE_INSTALL:...hr = SimConnect_AddToDataDefinition(hSimConnect, LEFTSLATPERCENT, "LEADING EDGE FLAPS0 LEFT PERCENT", "percent", SIMCONNECT_DATATYPE_FLOAT64, 0, SIMCONNECT_UNUSED);hr = SimConnect_RequestDataOnSimObject(hSimConnect, LEFT_SLAT_PERCENT, LEFTSLATPERCENT, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SIM_FRAME);...hr = SimConnect_CallDispatch(hSimConnect, MyDispatchProc, NULL);...break;And in "MyDispatchProc":case SIMCONNECT_RECV_ID_SIMOBJECT_DATA: { SIMCONNECT_RECV_SIMOBJECT_DATA *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA*) pData; switch(pObjData->dwRequestID) { case LEFT_SLAT_PERCENT: { double y = pObjData->dwData; Logfile << y << std::endl; } break; ...Here is the Content of my Logfile:> 0> 0> 0...//Begin Slats Moving (normally to 50% for Flaps1)> 1.47317e+008> 1.47317e+008> 5.3471e+008> 1.83026e+009> 8.93186e+008> 3.15392e+009> 4.23492e+009> 3.9748e+008> 1.21276e+009> 8.99826e+008> 3.10019e+009> 2.84775e+009> 2.91177e+009> 3.95953e+009> 2.65984e+009> 1.15104e+009> 2.92767e+009> 3.34225e+009> 2.63025e+009> 3.93373e+009> 3.97168e+009> 3.92725e+009> 8.86257e+008> 2.03805e+009> 1.78591e+009> 1.62378e+009> 3.11629e+009> 1.7466e+009> 3.23273e+009> 1.83128e+009> 3.63705e+009> 7.13952e+008> 2.60332e+008> 1.38051e+009> 3.02223e+009> 4.11702e+009> 3.19731e+008> 2.78988e+009> 1.69573e+009> 4.78023e+008> 1.73936e+009> 2.40164e+009> 3.45379e+008> 3.71177e+009> 3.63298e+009> 2.14445e+009> 3.34651e+009> 1.48822e+009> 3.19366e+007> 6.40975e+008> 2.85198e+008> 1.97332e+009> 3.46001e+009> 4.0834e+009> 3.25088e+008> 2.832e+009> 5.23089e+008> 6.70486e+008> 9.19254e+008> 2.46752e+009> 2.62478e+008> 2.574e+009> 3.95371e+009> 2.46165e+009> 2.57673e+009> 4.23324e+009> 1.68525e+009> 3.55316e+009> 3.58622e+009> 3.38243e+009> 2.12295e+008> 3.16767e+009// End Slats Moving> 0> 0> 0Any Idea?Kind Regards,Sven
May 31, 200719 yr Commercial Member > double y = pObjData->dwData;You are reading the data as a floating point double (64 bits), but then reading it from dwData which is a 32-bit unsigned! You'll never get the correct value that way! Even if the C++ compiler wasn't attempting to convert from unsigned int to double (thus messing any real double up), you'd only be accessing the lower 32-bits of it anyway!You need to cast dwData as a double. e.g. here is one way (to prevent the compiler merely converting it instead of casting it): double y = *((double *) &pObjData->dwData);The more usual way, as illustrated in the SimConnect SDK, is to declare a struct for your data (thus allowing more than one item also), and cast &pObjData->dwData to that struct. Then you can access all its members normally.RegardsPete Win10: 22H2 19045.2728 CPU: 9900KS at 5.5GHz Memory: 32Gb at 3800 MHz. GPU: RTX 24Gb Titan 2 x 2160p projectors at 25Hz onto 200 FOV curved screen
Create an account or sign in to comment