Sign in to follow this  
Guest rbumm

Set NAV frequency via simconnect

Recommended Posts

Hi, Has anybody succeeded in setting active or standby NAV1 or NAV2 frequencies via SimConnect ? The documentation says that in 'Aircraft Avionics Data' only marker beacon state is setable ? Any idea is welcome ! rudolf

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

>Has anybody succeeded in setting active or standby NAV1 or>NAV2 frequencies via SimConnect ? You have to use the Events. The Sim Vars for radios are readable, not writable.In general, the philosophy MS has followed here is that if there's an Event (I call them controls, they are also known as KEY_Events from the Gauges SDK) which does the job then they haven't enabled it to be also done via the Sim Vars. There are notable and useful exceptions, like the throttle, aileron, elevator, rudder, mixture and prop pitch settings, but not many.If you download my interim FSUIPC SDK for FSX (see my Support Forum), and look at the FSUIPC4 Offsets Status document therein, you will see all the values which I write via Sim Vars (annotated "SimC") and those which needed events (annotated "SimE").RegardsPete

Share this post


Link to post
Share on other sites

Thanks Pete, that sound logical - I give events a try ...regardsrudolf

Share this post


Link to post
Share on other sites

If I wanted to have an external device to control the heading value etc. in the A/P, and the external device immediately reflects the new heading value (on its display), would I then send the required number of key events to move the current value to the new/desired one and then check after 'a while' whether FSX has received and processed them all ?Regards,Siggy

Share this post


Link to post
Share on other sites

Just because I needed some time to see how this has to be done and it is not documented well in the SDK: // Code starts// in globals: static enum EVENT_FSP {EVENT_SIM_START,EVENT_NAV1SET,};// during init of SimConnect: hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_NAV1SET, "NAV1_RADIO_SET");// your function to set NAV1 from your client: static void set_nav1freq(double freq) {HRESULT hr; DWORD dwVal=0; char buf[32]; // FSX needs BCD format of your input, so transform ...sprintf(buf,"%4.0f",freq*100.);sscanf(buf,"%x",&dwVal);// finally do the transmissionif (hSimConnect) { hr = SimConnect_TransmitClientEvent(hSimConnect, 0, EVENT_NAV1SET, dwVal, SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);}} // end of CodeCAVE: if you do not set SIMCONNECT_GROUP_PRIORITY_HIGHEST (i used SIMCONNECT_GROUP_PRIORITY_DEFAULT first) the transmission to FSX will not work. regardsrudolf

Share this post


Link to post
Share on other sites

>If I wanted to have an external device to control the heading>value etc. in the A/P, and the external device immediately>reflects the new heading value (on its display), would I then>send the required number of key events to move the current>value to the new/desired one and then check after 'a while'>whether FSX has received and processed them all ?>>Regards,>SiggyThis would not be very efficient. You want to set the heading value of the aircraft's inbuild autopilot ? Similar like setting the NAV1, you should be able to set the heading directly (in one transmission) via HEADING_BUG_SET as described above ...regardsrudolf

Share this post


Link to post
Share on other sites

How do I do the conversion to BCD format using a .NET language?

Share this post


Link to post
Share on other sites

BCD puts two digits into one byte, so it is easiest to think of them as hexadecimal information.For example, 109.30 would be the hex number 0x10930.

Share this post


Link to post
Share on other sites

RudolfCan I just say thanks for providing this example:DWORD dwVal=0; char buf[32]; // FSX needs BCD format of your input, so transform ...sprintf(buf,"%4.0f",freq*100.);sscanf(buf,"%x",&dwVal);I've just spent the past two hours trying to send an event with an argument to FSX and although I could see it was receiving it, it was being completely ignored. Pushing the values through your BCD conversion seems to have fixed it.Thanks!David

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this