1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Waypoints

Discussion in 'SimConnect' started by Paavo, 19/11/06.

  1. Paavo

    Paavo

    Joined:
    20/5/06
    Messages:
    140
    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);
  2. lc0277

    lc0277

    Joined:
    25/9/06
    Messages:
    156
    Country:
    france
    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.
  3. Paavo

    Paavo

    Joined:
    20/5/06
    Messages:
    140
    Country:
    estonia
    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.
  4. lc0277

    lc0277

    Joined:
    25/9/06
    Messages:
    156
    Country:
    france
    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:
  5. Manda

    Manda

    Joined:
    21/11/06
    Messages:
    1
    Country:
    finland
    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?
  6. Paavo

    Paavo

    Joined:
    20/5/06
    Messages:
    140
    Country:
    estonia
    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: 21/11/06
  7. lc0277

    lc0277

    Joined:
    25/9/06
    Messages:
    156
    Country:
    france
    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.
  8. ronh

    ronh

    Joined:
    2/11/06
    Messages:
    385
    Country:
    canada
    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

Share This Page