From 472ed4feacff64cbb1ef833c3f7c60db6ebfb021 Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Fri, 1 May 2015 14:20:44 -0700 Subject: [PATCH 1/3] Added check to beginning of C example to ensure that the client is connected to X-Plane. --- C/xpcExample/xpcExample/src/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/C/xpcExample/xpcExample/src/main.cpp b/C/xpcExample/xpcExample/src/main.cpp index 17b2a81..5792368 100644 --- a/C/xpcExample/xpcExample/src/main.cpp +++ b/C/xpcExample/xpcExample/src/main.cpp @@ -23,6 +23,13 @@ int main() // Open Socket const char* IP = "127.0.0.1"; //IP Address of computer running X-Plane XPCSocket sock = openUDP(IP); + float tVal[1]; + int tSize; + if (getDREF(sock, "sim/test/test_float", tVal, &tSize) < 0) + { + printf("Error establishing connecting. Unable to read data from X-Plane."); + return EXIT_FAILURE; + } // Set Location/Orientation (sendPOSI) // Set Up Position Array From d2282c76951e885175c6bf08ffd42cb52ff6feb3 Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Fri, 1 May 2015 14:26:12 -0700 Subject: [PATCH 2/3] Added check to MATLAB example to ensure connection to X-Plane. --- MATLAB/Example/Example.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MATLAB/Example/Example.m b/MATLAB/Example/Example.m index 9803791..f25e848 100644 --- a/MATLAB/Example/Example.m +++ b/MATLAB/Example/Example.m @@ -11,6 +11,10 @@ import XPlaneConnect.* disp('xplaneconnect Example Script-'); disp('Setting up Simulation'); Socket = openUDP(49005); + +%% Ensure connected +getDREFs('sim/test/test_float') + %% Set position of the player aircraft disp('Setting position'); pauseSim(1); From 200eadd1e93d0391710d0c34afa9be166c287d02 Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Fri, 1 May 2015 14:28:33 -0700 Subject: [PATCH 3/3] Updated Java example. - Removed setCONN, since very few users should need it in the future. - Added test at the beginning of the example to ensure that the client is connected to X-Plane. --- Java/Examples/BasicOperation/src/Main.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Java/Examples/BasicOperation/src/Main.java b/Java/Examples/BasicOperation/src/Main.java index 1ab5bcc..dc82c9f 100644 --- a/Java/Examples/BasicOperation/src/Main.java +++ b/Java/Examples/BasicOperation/src/Main.java @@ -21,8 +21,8 @@ public class Main System.out.println("Setting up simulation..."); try(XPlaneConnect xpc = new XPlaneConnect()) { - System.out.println("Setting inbound port"); - xpc.setCONN(49055); + // Ensure connection established. + xpc.getDREF("sim/test/test_float"); System.out.println("Setting player aircraft position"); float[] posi = new float[] {37.524F, -122.06899F, 2500, 0, 0, 0, 1};