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

Waypoints

Paavo

Resource contributor
Messages
192
Country
estonia
Everything works fine as long as the number of waypoints is less than ten.
When I add more waypoints, the object will not move.
SDK says that the number of waypoints is unlimited. How to add more than nine waypoints?

Here's the code:


Code:
	HRESULT hr;
	SIMCONNECT_DATA_WAYPOINT	wp_list[9];

	wp_list[0].Flags		= SIMCONNECT_WAYPOINT_SPEED_REQUESTED;
	wp_list[0].Altitude	= 0;
	wp_list[0].Latitude	= 58.3104155956372;
	wp_list[0].Longitude = 26.6887841956585;
	wp_list[0].ktsSpeed	= 35;

	wp_list[1].Flags		= SIMCONNECT_WAYPOINT_SPEED_REQUESTED;
	wp_list[1].Altitude	= 0;
	wp_list[1].Latitude	= 58.310263754683;
	wp_list[1].Longitude = 26.6891543823598;
	wp_list[1].ktsSpeed	= 50;

	wp_list[2].Flags		= SIMCONNECT_WAYPOINT_SPEED_REQUESTED;
	wp_list[2].Altitude	= 0;
	wp_list[2].Latitude	= 58.310058138894;
	wp_list[2].Longitude = 26.6892958741827;
	wp_list[2].ktsSpeed	= 50;

	wp_list[3].Flags		= SIMCONNECT_WAYPOINT_SPEED_REQUESTED;
	wp_list[3].Altitude	= 0;
	wp_list[3].Latitude	= 58.3096801798509;
	wp_list[3].Longitude = 26.6893504749214;
	wp_list[3].ktsSpeed	= 50;

	wp_list[4].Flags		= SIMCONNECT_WAYPOINT_SPEED_REQUESTED;
	wp_list[4].Altitude	= 0;
	wp_list[4].Latitude	= 58.309651228458;
	wp_list[4].Longitude = 26.6894545575116;
	wp_list[4].ktsSpeed	= 50;

	wp_list[5].Flags		= SIMCONNECT_WAYPOINT_SPEED_REQUESTED;
	wp_list[5].Altitude	= 0;
	wp_list[5].Latitude	= 58.3096684362408;
	wp_list[5].Longitude = 26.6901567078433;
	wp_list[5].ktsSpeed	= 35;

	wp_list[6].Flags		= SIMCONNECT_WAYPOINT_SPEED_REQUESTED;
	wp_list[6].Altitude	= 0;
	wp_list[6].Latitude	= 58.3096700235243;
	wp_list[6].Longitude = 26.6903475246118;
	wp_list[6].ktsSpeed	= 30;

	wp_list[7].Flags		= SIMCONNECT_WAYPOINT_SPEED_REQUESTED;
	wp_list[7].Altitude	= 0;
	wp_list[7].Latitude	= 58.3096700235243;
	wp_list[7].Longitude = 26.6903475246118;
	wp_list[7].ktsSpeed	= 30;

	wp_list[8].Flags		= SIMCONNECT_WAYPOINT_SPEED_REQUESTED;
	wp_list[8].Altitude	= 0;
	wp_list[8].Latitude	= 58.3096700235243;
	wp_list[8].Longitude = 26.6903475246118;
	wp_list[8].ktsSpeed	= 20;

	hr = SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_WAYPOINT, Maz503KollaneID, 0, 9, sizeof(wp_list), wp_list);
 
Did you see any error message on the simconnect diagnostic console when you run this program ?

The documentation says that you have to give the number of elements and the size of each element. sizeof(wp_list) returns the size of the whole array (9*44 here), not the size of a single Waypoint. In that case, the client will read 9*(9*44) bytes from memory starting at wp_list, causing possible memory segmentation errors or buffer overflows.
 
I get exception 19 (INVALID_DATA_SIZE) when I give the size of an element instead of the size of the array. In AI Objects and Waypoints sample, there's also the size of the array (not element) sent to SimConnect.

However, I get absolutely no errors when I give the size of the array and send more than 9 waypoints with SetDataOnSimObject. But when I send more than nine waypoints and give the size of an element, I'm back at exception 19.

Makes no sense to me.
 
I implemented my own simconnect library in java and got puzzled with this function, now I really think it's a bug in the library.
The behavior of the function is to copy size*nelts bytes and send them to the server. Of course it will overflow if you specify a larger size than supported by the I/O buffers. For instance if you send 10 waypoints and give the size of the entire array, the packet size will be 36 (headers) + 10*(10*44) = 4436 bytes, but with only 10*44 useful bytes of data. If the maximum send buffer size is 4096, your packet will never be sent to FSX. :(

If you specify the size of one element instead, there will be no overflow but the packet will be malformed and you receive an INVALID_DATA_SIZE exception.

There is a configuration option in SimConnect.cfg (client side) to change the maximum receive size. You can try to increase it, but I don't know if it affects both receive & send buffers or receive alone.

If this is a really a bug, someone should send a mail to tell_fs@microsoft.com :alert:
 
Just quick question, do you need to send this information as one ?
Can you add and send like first 5, then next 5 and next until all sended?
 
I'm a beginner in so advanced programming (no laughing, guys) and I have no idea how to write a feedback system that would for example set an event when object reaches last waypoint so I can send additional waypoints.

Also, I tried to send two five-element arrays in a row, but the last send would then overwrite all the previous ones.
 
Last edited:
I'm a beginner in so advanced programming (no laughing, guys) and I have no idea how to write a feedback system that would for example set an event when object reaches last waypoint so I can send additional waypoints.

There is a simulation variable "AI CURRENT WAYPOINT" that returns the number of the current waypoint in list. You can periodically poll this variable to see where is the plane, or better use a tagged data request to receive only variable changes.
 
Paavo,

Does your real code have the last waypoint with
ft[n].Flags = SIMCONNECT_WAYPOINT_WRAP_TO_FIRST | SIMCONNECT_WAYPOINT_SPEED_REQUESTED;

The simobjects need to go round in a closed circle. Not sure if this would fix your problem.

Ron
 
Back
Top