• 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.

MSFS How to work with SimConnect_AIReleaseControl

Messages
60
Country
spain
Hello,

I have been struggling with this topic for quite sometime and checking several code to try and find an answer. Also, and although I might misinterpret something, I have read once and again the official documentation (MSFS's, FSX's and P3D).

The question is this simple, and maybe I am doing it right already. But since I am still getting some issues within my code, I'm not sure if these are due to this problem or some other.

This is what I do, from what I've seen:

First I include the proper requestID in my enum structure:

C++:
static enum DATA_REQUEST_ID {
    REQUEST_PROBE_RELEASE,
    ...
}

At some point in my code, when I create a SimConnect_AICreateSimulatedObject, I initialize it with the following to release it and be able to move it without issues:


C++:
void probe_init(int probe_i)
{
    HRESULT hr;

    hr = SimConnect_AIReleaseControl(hSimConnect, probe_info[probe_i].id, (UINT)REQUEST_PROBE_RELEASE+probe_i);
    hr = SimConnect_TransmitClientEvent(hSimConnect,
        probe_info[probe_i].id,
        EVENT_FREEZE_ALTITUDE,
        1,
        SIMCONNECT_GROUP_PRIORITY_HIGHEST,
        SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
    hr = SimConnect_TransmitClientEvent(hSimConnect,
        probe_info[probe_i].id,
        EVENT_FREEZE_ATTITUDE,
        1,
        SIMCONNECT_GROUP_PRIORITY_HIGHEST,
        SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
    hr = SimConnect_TransmitClientEvent(hSimConnect,
        probe_info[probe_i].id,
        EVENT_FREEZE_LATLONG,
        1,
        SIMCONNECT_GROUP_PRIORITY_HIGHEST,
        SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
}

Now, the problem I see from third-party code, is that the REQUEST_PROBE_RELEASE is never called within the Callback function. Is this how its supposed to work?

I am wondering if this is the problem why I am getting a SIMCONNECT_EXCEPTION_DATA_ERROR (20) although the code seems to be working fine.

Thank you.

Best!
 

DragonflightDesign

Resource contributor
Messages
947
Country
northernireland
Error 20: '(... )It is also used by other functions to report that flags or reserved parameters have not been set to zero'. Are you sure that your SimConnect_AIReleaseControl call has the correct parameters?
 
Messages
60
Country
spain
Error 20: '(... )It is also used by other functions to report that flags or reserved parameters have not been set to zero'. Are you sure that your SimConnect_AIReleaseControl call has the correct parameters?

Thank you for the tip. As it turns out, both questions/ issues are not correlated:

1. regarding AIReleaseControl, I found out that it doesn't do much for non-Aircraft SimObjects which have not be given a path (waypoints) and are not controlled by the AI. So this is not a problem anymore for my specific case.

2. regarding Exception (20), it turns out the problem was on the SetDataOnSimObject. On my data definition, I was trying to read a SimVar which is not supported for the SimObject in question.

Again, thank you!
 
Top