-
Notifications
You must be signed in to change notification settings - Fork 277
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.
- The
xpcSocket
struct has been typedefed toXPCSocket
. This allows users to reference opened sockets without using thestruct
keyword.
- Fix: Be aware that
struct xpcSocket
andXPCSocket
have the same meaning.
- 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
andsendfd
, replace all instances ofsendfd
withrecvfd
and removesendfd
from your code. - Ex:
struct xpcSocket recvfd = openUDP(...); struct xpcSocket sendfd = openUDP(...);
becomesXPCSocket sock = openUDP(...);
- After making the above change, all places where either
recvfd
orsendfd
were referenced should be replaced withsock
.
- The
open
field has been removed fromXPCSocket
because it was never properly set.
- Fix: Treat all sockets returned by
openUDP
as open until they are passed tocloseUDP
.
- The
readUDP
andsendUDP
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.
- The readDATA function now takes a
rows
argument that specifies the sizes of thedata
array.
- Fix: Add the size of the
data
array to thereadDATA
call. - Ex:
float data[4][9]; readData(sock, data);
becomesfloat data[4][9]; readData(sock, data, 4)
.
- The
sendDREF
function has been renamed tosetDREF
to better match other clients.
- Fix: replace calls to
sendDREF
with calls tosetDREF
. - Ex:
sendDREF(sendfd, "sim/a/dref", 10, values, 8);
becomessetDREF(sendfd, "sim/a/dref", 10, values, 8);
- The
setDREFs
function removes thelength_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);
becomessetDREF(sendfd, "sim/a/dref", values, 8);
- The
requestDREF
function has been substantially overhauled.
- The
requestDREF
function has been renamed togetDREFs
. -
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 togetDREFs
, remove theDREFSizes
argument, and order the remaining parameters as follows: - Ex:
requestDREF(sendfd, recfd, DREFArray, DREFSizes, listLength, resultArray, arraySizes;
becomesgetDREFs(sendfd, DREFArray, resultArray, listLength, arraySizes);
.
- The
ACNum
parameter insendPOSI
andsendCTRL
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
andpsendCTRL
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 thep
version of the function instead. - Ex:
sendPOSI(recfd, 1, numArgs, valueArray);
becomessendPOSI(recfd, valueArray, numArgs, 1);
- Ex:
sendCTRL(recfd, 0, numArgs, valueArray);
becomespsendCTRL(recfd, valueArray, numArgs);
- The values of the
WYPT_OP
enum have been switched to ALL CAPS.
- Fix: Capitalize the
xpc
prefix ofWYPT_OP
values. - Ex:
xpc_WYPT_ADD
becomesXPC_WYPT_ADD
.