• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

MSFS20 COM1 frequency swap event

Messages
533
Country
france
In order to have my CockpitSonic RMP operational (radio management panel) with MSFS, I wrote a small 64 bits app that uses SimConnect to communicate with the sim. It works both ways, which means if I change a frequency on the device, it changes the frequency in the sim, and conversely, I read the events coming from the sim so that any change in the sim is reflected on the device.

It works perfect, when I play with the COM1 standby frequency, it is updated in the sim and conversely, but... it doesn't work when I swap standby/active frequencies. It works when I press the swap button on the device, the event is sent to the sim, but if I swap in the sim, the COM_STBY_RADIO_SWAP event is not received in my app. It is strange because it works perfect for the other events, such as COM_RADIO_FRACT_DEC and COM_RADIO_FRACT_INC and the exact same code is used...

Any idea?
 
Here is some more information about my code, in case it might help...
Right after initializing SimConnect, I set it up to listen to some events that control the COM1 standby frequency and swap:

C++:
SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_COM1_STDBY_WHOLE_DEC, "COM_RADIO_WHOLE_DEC");
        SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_COM1_STDBY_WHOLE_DEC);
        SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_COM1_STDBY_WHOLE_INC, "COM_RADIO_WHOLE_INC");
        SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_COM1_STDBY_WHOLE_INC);
        SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_COM1_STDBY_FRACT_DEC, "COM_RADIO_FRACT_DEC");
        SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_COM1_STDBY_FRACT_DEC);
        SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_COM1_STDBY_FRACT_INC, "COM_RADIO_FRACT_INC");
        SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_COM1_STDBY_FRACT_INC);
        SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_COM1_SWAP, "COM_STBY_RADIO_SWAP");
        SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_COM1_SWAP);
        SimConnect_SetNotificationGroupPriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST);

Then in my dispatch proc, I have something like this to trace the incoming events:

C++:
switch (pData->dwID)
    {
        case SIMCONNECT_RECV_ID_EVENT:
        {
            SIMCONNECT_RECV_EVENT* evt = (SIMCONNECT_RECV_EVENT*)pData;
            switch (evt->uEventID)
            {
                case EVENT_COM1_STDBY_WHOLE_DEC:
                    printf("COM Standby Integer DEC (%d)\n", evt->dwData);
                    break;
                case EVENT_COM1_STDBY_WHOLE_INC:
                    printf("COM Standby Integer INC (%d)\n", evt->dwData);
                    break;
                case EVENT_COM1_STDBY_FRACT_DEC:
                    printf("COM Standby Decimal DEC (%d)\n", evt->dwData);
                    break;
                case EVENT_COM1_STDBY_FRACT_INC:
                    printf("COM Standby Decimal INC (%d)\n", evt->dwData);
                    break;
                case EVENT_COM1_SWAP:
                    printf("COM frequency swap (%d)\n", evt->dwData);
                    break;
            }
            break;
        }

It works for all but not for the swap event. Strange, isn't it?
 
It works fine for me.
C++:
...       
if (FAILED(SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_COM1_SWAP, "COM_STBY_RADIO_SWAP")))
{
    std::cout << "Unable to map to COM_STBY_RADIO_SWAP" << std::endl;
}
else
{
    SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_COM1_SWAP);
}
if (FAILED(SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_NAV1_SWAP, "NAV1_RADIO_SWAP")))
{
    std::cout << "Unable to map to NAV1_RADIO_SWAP" << std::endl;
}
else
{
    SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_NAV1_SWAP);
}
if (FAILED(SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_COM2_SWAP, "COM2_RADIO_SWAP")))
{
    std::cout << "Unable to map to EVENT_COM2_SWAP" << std::endl;
}
else
{
    SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_COM2_SWAP);
}
SimConnect_SetNotificationGroupPriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST);
...

case SIMCONNECT_RECV_ID_EVENT:
{
    SIMCONNECT_RECV_EVENT* pRecvEvent = (SIMCONNECT_RECV_EVENT*)pData;
    switch (pRecvEvent->uGroupID)
    {
    case GROUP0:
    {
        switch (pRecvEvent->uEventID)
        {
        case EVENT_COM1_SWAP:
        {
            std::cout << "COM1 SWAP" << std::endl;
            break;
        }
        case EVENT_NAV1_SWAP:
        {
            std::cout << "NAV1 SWAP" << std::endl;
            break;
        }
        case EVENT_COM2_SWAP:
        {
            std::cout << "COM2 SWAP" << std::endl;
            break;
        }
        default:
        {
            std::cout << "Unknown event in GROUP0: " << pRecvEvent->uEventID << std::endl;
        }
        }
        break;
    }
    break;
}
...
Screenshot 2020-11-23 075522.png
 
I am happy to see this, it means there is no bug in the product.
Now I have to find what is wrong in my code...

Thank you :)
 
I found the explanation !!
In fact, my code is working fine, just like yours, when testing with an aircraft that has a Garmin GPS that manages the radio. But all my tests were done with the Cessna 152 that has steam gauges and a "basic" radio set. For an unknown reason, the SWAP event is not detected with the C152, probably because the COM radio gauge does not use the SWAP event. So the bug comes from the C152, not from my code :)
I wonder why it doesn't work, especially because when I send a swap event to the sim, it works...
 
So the bug comes from the C152
It's not a bug.

In the aircraft.cfg there's a radios section. Here's the way the entry works and why it would or would not support a standby frequency:
Aircraft Configuration Files
com.1Two flags, set the first one to 1 if a Com1 radio is available, and the second if it supports a standby frequency.
 
I know this since FS2002. The problem here is that THERE IS a standby frequency in the C152, and there is a swap button that works in the plane, but for an unknown reason, it doesn't use the "COM_STBY_RADIO_SWAP" event. We might not call this a bug, but it is strange...
 
For default C152 works COM1_RADIO_SWAP (undocumented, or wrong documentation) 😡
C++:
SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_COM1_SWAP1, "COM1_RADIO_SWAP")
C++:
...
case EVENT_COM1_SWAP1:
{
    std::cout << "Another COM1 SWAP" << std::end
    break;
}
...
Screenshot 2020-11-23 201545.png
 
You're right, it works !! Congratulations !!
I wonder how yo found this while it is not in the documentation... Maybe you explored some DLLs :)
Anyway, thank you, it really helps and my software is now fully operational.
 
Back
Top