Skip to content

Migrating to 1.0 C

Jason Watkins edited this page Apr 23, 2015 · 1 revision

Several changes have been made to the C client to improve compatability with clients written in other languages. The following list enumerates breaking changes and provides specific instructions on how to fix your code to work with version 1.0 of the X-Plane Connect Toolbox.

  1. The xpcSocket struct has been typedefed to XPCSocket. This allows users to reference opened sockets without using the struct keyword.
  • Fix: Be aware that struct xpcSocket and XPCSocket have the same meaning.
  1. The X-Plane Connect plugin now uses a single socket to communicate. It is no longer necessary to open both a send and receive socket.
  • Several functions previously required two sockets as arguments. These functions now only require one.
  • Fix: If you previously had two sockets named recvfd and sendfd, replace all instances of sendfd with recvfd and remove sendfd from your code.
  • Ex: struct xpcSocket recvfd = openUDP(...); struct xpcSocket sendfd = openUDP(...); becomes XPCSocket sock = openUDP(...);
  • After making the above change, all places where either recvfd or sendfd were referenced should be replaced with sock.
  1. The open field has been removed from XPCSocket because it was never properly set.
  • Fix: Treat all sockets returned by openUDP as open until they are passed to closeUDP.
  1. The readUDP and sendUDP functions have been removed from the header file.
  • These functions are intended only to be used internally by the client.
  • Fix: Use The pulic client functions to send and receive data. If no existing function meets your needs, submit an issue to GitHub.
  1. The readDATA function now takes a rows argument that specifies the sizes of the data array.
  • Fix: Add the size of the data array to the readDATA call.
  • Ex: float data[4][9]; readData(sock, data); becomes float data[4][9]; readData(sock, data, 4).
  1. The sendDREF function has been renamed to setDREF to better match other clients.
  • Fix: replace calls to sendDREF with calls to setDREF.
  • Ex: sendDREF(sendfd, "sim/a/dref", 10, values, 8); becomes setDREF(sendfd, "sim/a/dref", 10, values, 8);
  1. The setDREFs function removes the length_of_DREF parameter. Instead, strnlen is used.
  • Fix: Remove the third argument and ensure that the dref is null terminated.
  • Ex: setDREF(sendfd, "sim/a/dref", 10, values, 8); becomes setDREF(sendfd, "sim/a/dref", values, 8);
  1. The requestDREF function has been substantially overhauled.
  • The requestDREF function has been renamed to getDREFs.
  • getDREFs only requires one socket.
  • The length of the DREFs is now determined using strnlen.
  • The order of the remaining parameters has been changed.
  • Fix: replace calls to requestDREF with calls to getDREFs, remove the DREFSizes argument, and order the remaining parameters as follows:
  • Ex: requestDREF(sendfd, recfd, DREFArray, DREFSizes, listLength, resultArray, arraySizes; becomes getDREFs(sendfd, DREFArray, resultArray, listLength, arraySizes);.
  1. The ACNum parameter in sendPOSI and sendCTRL functions have been moved to the end of the parameter list and the array and array length parameters have been swapped.
  • This better matches other clients where the aircraft number is optional.
  • Aditionally, the psendPOSI and psendCTRL functions are now available that omit the aircraft number and act on the player aircraft.
  • Fix: Swap the array and array length arugments and move the ACNum argument to the end of the argument list or remove it entirely and call the p version of the function instead.
  • Ex: sendPOSI(recfd, 1, numArgs, valueArray); becomes sendPOSI(recfd, valueArray, numArgs, 1);
  • Ex: sendCTRL(recfd, 0, numArgs, valueArray); becomes psendCTRL(recfd, valueArray, numArgs);
  1. The values of the WYPT_OP enum have been switched to ALL CAPS.
  • Fix: Capitalize the xpc prefix of WYPT_OP values.
  • Ex: xpc_WYPT_ADD becomes XPC_WYPT_ADD.