Dragonlaird / SimConnectHelper

A static class to simplify communication with MSFS 2020 using SimConnect.
28 stars 7 forks source link

Not able to get transponder and com info #7

Open MrPixelGlitch opened 2 years ago

MrPixelGlitch commented 2 years ago

I recently tried to request transponder and com values, but nothing is coming back from the sim.

I used your demo-project with MSFS2020 for testing if they're available. Tried all indexes for each setting and different planes, but I'm not able to get values for:

Other requests are working fine. Is this an error on my side or what am I doing wrong?

Dragonlaird commented 2 years ago

It seems the test form is "losing" the index value being supplied, although the tool itself does accept/use indexes, I will investigate and fix this when I have a little time.

afefer commented 2 years ago

I found the issue - in RegisterSimVar() you have the following chunk of code that strips out the index:

double index = 0;
if (simVarName.IndexOf(':') > -1)
{
    index = double.Parse(simVarName.Substring(simVarName.IndexOf(':') + 1));
    simVarName = simVarName.Substring(0, simVarName.IndexOf(':'));
}*/

However, the variable index is never used after that, and simVarName is passed in to simConnect.AddToDataDefinition() without its original index, which fails. Commenting out the above chunk of code seems to fix the problem.

Dragonlaird commented 2 years ago

Thanks Alex,

From memory, some methods in earlier versions of the DLL required the index to be supplied as a separate parameter and didn't like them being included as part of the SimVar name.

I think I was in midst of editing this when I had to stop work on this project to concentrate on something more urgent and time-consuming.

If it works without the code above, I'll remove it in a new Pull Request and submit it.

Jim