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

FSX Help for Sending Waypoint Dynamically

Messages
1
Country
canada
Hi all:

First time developing using simconnect.

I am trying to update new waypoint in front of the AI aircraft as the AI aircraft is flying. I see that when I send the first waypoint, AI aircraft will takeoff and fly towards it, but when I try to send another waypoint, I get exception 19 (invalid data size?).

I basically have a function (as a test) that will send a single waypoint by a button click. First time, no exception, everythings cool. Then after the aircraft is in the air on its way to the single waypoint, I call this function again by subsequent button clicks (right now for test I use same waypoint), I get exception 19. Even if I use a different waypoint (by another button click), I get the same.

Basic code is here

private void set_Single_Waypoint(double lat, double lon, double alt, double speed, DEFINITIONS d)
{
simconnect.AddToDataDefinition(d, "AI WAYPOINT LIST", "number", SIMCONNECT_DATATYPE.WAYPOINT, 0.0f, SimConnect.SIMCONNECT_UNUSED);
SIMCONNECT_DATA_WAYPOINT[] wp = new SIMCONNECT_DATA_WAYPOINT[1];

wp[0].Flags = (uint)SIMCONNECT_WAYPOINT_FLAGS.SPEED_REQUESTED;
wp[0].Altitude = 1000;
wp[0].Latitude = 47.445501972979;// 47 + (27.79 / 60);
wp[0].Longitude = -122.308007293086;// -122 - (18.46 / 60);
wp[0].ktsSpeed = 100;


Object[] objv1 = new Object[wp.Length];
wp.CopyTo(objv1, 0);

simconnect.SetDataOnSimObject(DEFINITIONS.Extra300SWaypoints, Extra300SID, 0, objv1);

}


I tried the freeze alt/lat/long, send the above waypoint, then unfreeze it, still get exception 19 (I dont think thats the problem).

I think my methodology of updating new waypoints is wrong...but out of ideas now...:(

This is for school project. Help will be much appreciated.

Sincerely,

Sam
 
Hi Sam,

I have been using intensively this method and it works alright.

Exception 19 is a data size error. So, I suspect a problem with the SimConnect_AddToDataDefinition command.

Patrick.
 
I even use this method to control AI aircraft interactively. The only difference to my solution is, that I set the SIMCONNECT_DATA_WAYPOINT. percentThrottle explicitely to zero and I take care, that the SimConnect_SetDataOnSimObject is invoked only from the thread who opened the connection. No idea whether this little difference could explain your effect.
Regards,
Mike
 
Back
Top