diff --git a/C/src/xplaneConnect.c b/C/src/xplaneConnect.c
index f1da9673..97830f2e 100755
--- a/C/src/xplaneConnect.c
+++ b/C/src/xplaneConnect.c
@@ -139,6 +139,7 @@ void closeUDP(XPCSocket sock)
{
#ifdef _WIN32
int result = closesocket(sock.sock);
+ WSACleanup();
#else
int result = close(sock.sock);
#endif
diff --git a/Java/.project b/Java/.project
new file mode 100644
index 00000000..e18da484
--- /dev/null
+++ b/Java/.project
@@ -0,0 +1,17 @@
+
+
+ xpc-parent
+
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/Java/.settings/org.eclipse.core.resources.prefs b/Java/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..99f26c02
--- /dev/null
+++ b/Java/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/=UTF-8
diff --git a/Java/.settings/org.eclipse.m2e.core.prefs b/Java/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 00000000..f897a7f1
--- /dev/null
+++ b/Java/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/Java/Examples/.project b/Java/Examples/.project
new file mode 100644
index 00000000..589dd0ab
--- /dev/null
+++ b/Java/Examples/.project
@@ -0,0 +1,17 @@
+
+
+ xpc-examples
+
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/Java/Examples/.settings/org.eclipse.core.resources.prefs b/Java/Examples/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..99f26c02
--- /dev/null
+++ b/Java/Examples/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/=UTF-8
diff --git a/Java/Examples/.settings/org.eclipse.m2e.core.prefs b/Java/Examples/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 00000000..f897a7f1
--- /dev/null
+++ b/Java/Examples/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/Java/Examples/ContinuousOperation/libs/XPlaneConnect.jar b/Java/Examples/ContinuousOperation/libs/XPlaneConnect.jar
deleted file mode 100644
index eba5283b..00000000
Binary files a/Java/Examples/ContinuousOperation/libs/XPlaneConnect.jar and /dev/null differ
diff --git a/Java/Examples/Playback/.classpath b/Java/Examples/Playback/.classpath
new file mode 100644
index 00000000..5e8a55fe
--- /dev/null
+++ b/Java/Examples/Playback/.classpath
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Java/Examples/Playback/.gitignore b/Java/Examples/Playback/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/Java/Examples/Playback/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/Java/Examples/Playback/.project b/Java/Examples/Playback/.project
new file mode 100644
index 00000000..1f830e84
--- /dev/null
+++ b/Java/Examples/Playback/.project
@@ -0,0 +1,23 @@
+
+
+ playback-example
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/Java/Examples/Playback/.settings/org.eclipse.core.resources.prefs b/Java/Examples/Playback/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..e9441bb1
--- /dev/null
+++ b/Java/Examples/Playback/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding/=UTF-8
diff --git a/Java/Examples/Playback/.settings/org.eclipse.jdt.core.prefs b/Java/Examples/Playback/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..2f5cc74c
--- /dev/null
+++ b/Java/Examples/Playback/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/Java/Examples/Playback/.settings/org.eclipse.m2e.core.prefs b/Java/Examples/Playback/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 00000000..f897a7f1
--- /dev/null
+++ b/Java/Examples/Playback/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/Java/Examples/Playback/pom.xml b/Java/Examples/Playback/pom.xml
new file mode 100644
index 00000000..4e252402
--- /dev/null
+++ b/Java/Examples/Playback/pom.xml
@@ -0,0 +1,12 @@
+
+ 4.0.0
+
+
+ gov.nasa
+ xpc-examples
+ 1.4.0-SNAPSHOT
+
+
+ playback-example
+ XPC Example Playback
+
diff --git a/Java/Examples/Playback/src/gov/nasa/xpc/Main.java b/Java/Examples/Playback/src/main/java/gov/nasa/xpc/ex/Main.java
similarity index 96%
rename from Java/Examples/Playback/src/gov/nasa/xpc/Main.java
rename to Java/Examples/Playback/src/main/java/gov/nasa/xpc/ex/Main.java
index 3b5925b1..d1bfb20b 100644
--- a/Java/Examples/Playback/src/gov/nasa/xpc/Main.java
+++ b/Java/Examples/Playback/src/main/java/gov/nasa/xpc/ex/Main.java
@@ -1,7 +1,9 @@
-package gov.nasa.xpc;
+package gov.nasa.xpc.ex;
import com.sun.javafx.scene.EnteredExitedHandler;
+import gov.nasa.xpc.XPlaneConnect;
+
import java.io.*;
import java.util.Scanner;
@@ -99,7 +101,7 @@ public static void record(String path, int interval, int duration) throws IOExce
{
for (int i = 0; i < count; ++i)
{
- float[] posi = xpc.getPOSI(0); // FIXME: change this to 64-bit double
+ double[] posi = xpc.getPOSI(0); // FIXME: change this to 64-bit double
writer.write(String.format("%1$f, %2$f, %3$f, %4$f, %5$f, %6$f, %7$f\n",
posi[0], posi[1], posi[2], posi[3], posi[4], posi[5], posi[6]));
try
diff --git a/Java/Examples/basic-operation/.classpath b/Java/Examples/basic-operation/.classpath
new file mode 100644
index 00000000..5e8a55fe
--- /dev/null
+++ b/Java/Examples/basic-operation/.classpath
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Java/Examples/basic-operation/.gitignore b/Java/Examples/basic-operation/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/Java/Examples/basic-operation/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/Java/Examples/BasicOperation/.idea/compiler.xml b/Java/Examples/basic-operation/.idea/compiler.xml
similarity index 100%
rename from Java/Examples/BasicOperation/.idea/compiler.xml
rename to Java/Examples/basic-operation/.idea/compiler.xml
diff --git a/Java/Examples/BasicOperation/.idea/copyright/profiles_settings.xml b/Java/Examples/basic-operation/.idea/copyright/profiles_settings.xml
similarity index 100%
rename from Java/Examples/BasicOperation/.idea/copyright/profiles_settings.xml
rename to Java/Examples/basic-operation/.idea/copyright/profiles_settings.xml
diff --git a/Java/Examples/BasicOperation/.idea/libraries/Java.xml b/Java/Examples/basic-operation/.idea/libraries/Java.xml
similarity index 100%
rename from Java/Examples/BasicOperation/.idea/libraries/Java.xml
rename to Java/Examples/basic-operation/.idea/libraries/Java.xml
diff --git a/Java/Examples/BasicOperation/.idea/misc.xml b/Java/Examples/basic-operation/.idea/misc.xml
similarity index 100%
rename from Java/Examples/BasicOperation/.idea/misc.xml
rename to Java/Examples/basic-operation/.idea/misc.xml
diff --git a/Java/Examples/BasicOperation/.idea/modules.xml b/Java/Examples/basic-operation/.idea/modules.xml
similarity index 100%
rename from Java/Examples/BasicOperation/.idea/modules.xml
rename to Java/Examples/basic-operation/.idea/modules.xml
diff --git a/Java/Examples/BasicOperation/.idea/vcs.xml b/Java/Examples/basic-operation/.idea/vcs.xml
similarity index 100%
rename from Java/Examples/BasicOperation/.idea/vcs.xml
rename to Java/Examples/basic-operation/.idea/vcs.xml
diff --git a/Java/Examples/basic-operation/.project b/Java/Examples/basic-operation/.project
new file mode 100644
index 00000000..ac3ce072
--- /dev/null
+++ b/Java/Examples/basic-operation/.project
@@ -0,0 +1,23 @@
+
+
+ basic-operation
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/Java/Examples/basic-operation/.settings/org.eclipse.core.resources.prefs b/Java/Examples/basic-operation/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..e9441bb1
--- /dev/null
+++ b/Java/Examples/basic-operation/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding/=UTF-8
diff --git a/Java/Examples/basic-operation/.settings/org.eclipse.jdt.core.prefs b/Java/Examples/basic-operation/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..2f5cc74c
--- /dev/null
+++ b/Java/Examples/basic-operation/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/Java/Examples/basic-operation/.settings/org.eclipse.m2e.core.prefs b/Java/Examples/basic-operation/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 00000000..f897a7f1
--- /dev/null
+++ b/Java/Examples/basic-operation/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/Java/Examples/BasicOperation/BasicOperation.iml b/Java/Examples/basic-operation/BasicOperation.iml
similarity index 100%
rename from Java/Examples/BasicOperation/BasicOperation.iml
rename to Java/Examples/basic-operation/BasicOperation.iml
diff --git a/Java/Examples/basic-operation/pom.xml b/Java/Examples/basic-operation/pom.xml
new file mode 100644
index 00000000..fbd35118
--- /dev/null
+++ b/Java/Examples/basic-operation/pom.xml
@@ -0,0 +1,12 @@
+
+ 4.0.0
+
+
+ gov.nasa
+ xpc-examples
+ 1.4.0-SNAPSHOT
+
+
+ basic-operation
+ XPC Example Basic Operation
+
diff --git a/Java/Examples/BasicOperation/src/Main.java b/Java/Examples/basic-operation/src/main/java/gov/nasa/xpc/ex/Main.java
similarity index 100%
rename from Java/Examples/BasicOperation/src/Main.java
rename to Java/Examples/basic-operation/src/main/java/gov/nasa/xpc/ex/Main.java
diff --git a/Java/Examples/continuous-operation/.classpath b/Java/Examples/continuous-operation/.classpath
new file mode 100644
index 00000000..5e8a55fe
--- /dev/null
+++ b/Java/Examples/continuous-operation/.classpath
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Java/Examples/continuous-operation/.gitignore b/Java/Examples/continuous-operation/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/Java/Examples/continuous-operation/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/Java/Examples/ContinuousOperation/.idea/.name b/Java/Examples/continuous-operation/.idea/.name
similarity index 100%
rename from Java/Examples/ContinuousOperation/.idea/.name
rename to Java/Examples/continuous-operation/.idea/.name
diff --git a/Java/Examples/ContinuousOperation/.idea/compiler.xml b/Java/Examples/continuous-operation/.idea/compiler.xml
similarity index 100%
rename from Java/Examples/ContinuousOperation/.idea/compiler.xml
rename to Java/Examples/continuous-operation/.idea/compiler.xml
diff --git a/Java/Examples/ContinuousOperation/.idea/copyright/profiles_settings.xml b/Java/Examples/continuous-operation/.idea/copyright/profiles_settings.xml
similarity index 100%
rename from Java/Examples/ContinuousOperation/.idea/copyright/profiles_settings.xml
rename to Java/Examples/continuous-operation/.idea/copyright/profiles_settings.xml
diff --git a/Java/Examples/ContinuousOperation/.idea/libraries/XPlaneConnect.xml b/Java/Examples/continuous-operation/.idea/libraries/XPlaneConnect.xml
similarity index 100%
rename from Java/Examples/ContinuousOperation/.idea/libraries/XPlaneConnect.xml
rename to Java/Examples/continuous-operation/.idea/libraries/XPlaneConnect.xml
diff --git a/Java/Examples/ContinuousOperation/.idea/misc.xml b/Java/Examples/continuous-operation/.idea/misc.xml
similarity index 100%
rename from Java/Examples/ContinuousOperation/.idea/misc.xml
rename to Java/Examples/continuous-operation/.idea/misc.xml
diff --git a/Java/Examples/ContinuousOperation/.idea/modules.xml b/Java/Examples/continuous-operation/.idea/modules.xml
similarity index 100%
rename from Java/Examples/ContinuousOperation/.idea/modules.xml
rename to Java/Examples/continuous-operation/.idea/modules.xml
diff --git a/Java/Examples/ContinuousOperation/.idea/vcs.xml b/Java/Examples/continuous-operation/.idea/vcs.xml
similarity index 100%
rename from Java/Examples/ContinuousOperation/.idea/vcs.xml
rename to Java/Examples/continuous-operation/.idea/vcs.xml
diff --git a/Java/Examples/continuous-operation/.project b/Java/Examples/continuous-operation/.project
new file mode 100644
index 00000000..b74f80f5
--- /dev/null
+++ b/Java/Examples/continuous-operation/.project
@@ -0,0 +1,23 @@
+
+
+ continuous-operation
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/Java/Examples/continuous-operation/.settings/org.eclipse.core.resources.prefs b/Java/Examples/continuous-operation/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..e9441bb1
--- /dev/null
+++ b/Java/Examples/continuous-operation/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding/=UTF-8
diff --git a/Java/Examples/continuous-operation/.settings/org.eclipse.jdt.core.prefs b/Java/Examples/continuous-operation/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..2f5cc74c
--- /dev/null
+++ b/Java/Examples/continuous-operation/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/Java/Examples/continuous-operation/.settings/org.eclipse.m2e.core.prefs b/Java/Examples/continuous-operation/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 00000000..f897a7f1
--- /dev/null
+++ b/Java/Examples/continuous-operation/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/Java/Examples/ContinuousOperation/ContinuousOperation.iml b/Java/Examples/continuous-operation/ContinuousOperation.iml
similarity index 100%
rename from Java/Examples/ContinuousOperation/ContinuousOperation.iml
rename to Java/Examples/continuous-operation/ContinuousOperation.iml
diff --git a/Java/Examples/continuous-operation/pom.xml b/Java/Examples/continuous-operation/pom.xml
new file mode 100644
index 00000000..803c4719
--- /dev/null
+++ b/Java/Examples/continuous-operation/pom.xml
@@ -0,0 +1,12 @@
+
+ 4.0.0
+
+
+ gov.nasa
+ xpc-examples
+ 1.4.0-SNAPSHOT
+
+
+ continuous-operation
+ XPC Example Continuous Operation
+
diff --git a/Java/Examples/ContinuousOperation/src/Main.java b/Java/Examples/continuous-operation/src/main/java/gov/nasa/xpc/ex/Main.java
similarity index 92%
rename from Java/Examples/ContinuousOperation/src/Main.java
rename to Java/Examples/continuous-operation/src/main/java/gov/nasa/xpc/ex/Main.java
index 801a3695..486d46f6 100644
--- a/Java/Examples/ContinuousOperation/src/Main.java
+++ b/Java/Examples/continuous-operation/src/main/java/gov/nasa/xpc/ex/Main.java
@@ -20,7 +20,7 @@ public static void main(String[] args)
int aircraft = 0;
while(true)
{
- float[] posi = xpc.getPOSI(aircraft); // FIXME: change this to 64-bit double
+ double[] posi = xpc.getPOSI(aircraft); // FIXME: change this to 64-bit double
float[] ctrl = xpc.getCTRL(aircraft);
System.out.format("Loc: (%4f, %4f, %4f) Aileron:%2f Elevator:%2f Rudder:%2f\n",
diff --git a/Java/Examples/discovery/.classpath b/Java/Examples/discovery/.classpath
new file mode 100644
index 00000000..5e8a55fe
--- /dev/null
+++ b/Java/Examples/discovery/.classpath
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Java/Examples/discovery/.gitignore b/Java/Examples/discovery/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/Java/Examples/discovery/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/Java/Examples/discovery/.project b/Java/Examples/discovery/.project
new file mode 100644
index 00000000..fb76ee0d
--- /dev/null
+++ b/Java/Examples/discovery/.project
@@ -0,0 +1,23 @@
+
+
+ discovery-example
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/Java/Examples/discovery/.settings/org.eclipse.core.resources.prefs b/Java/Examples/discovery/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..e9441bb1
--- /dev/null
+++ b/Java/Examples/discovery/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding/=UTF-8
diff --git a/Java/Examples/discovery/.settings/org.eclipse.jdt.core.prefs b/Java/Examples/discovery/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..2f5cc74c
--- /dev/null
+++ b/Java/Examples/discovery/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/Java/Examples/discovery/.settings/org.eclipse.m2e.core.prefs b/Java/Examples/discovery/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 00000000..f897a7f1
--- /dev/null
+++ b/Java/Examples/discovery/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/Java/Examples/DiscoveryExample/DiscoveryExample.iml b/Java/Examples/discovery/DiscoveryExample.iml
similarity index 100%
rename from Java/Examples/DiscoveryExample/DiscoveryExample.iml
rename to Java/Examples/discovery/DiscoveryExample.iml
diff --git a/Java/Examples/discovery/pom.xml b/Java/Examples/discovery/pom.xml
new file mode 100644
index 00000000..8902bae4
--- /dev/null
+++ b/Java/Examples/discovery/pom.xml
@@ -0,0 +1,12 @@
+
+ 4.0.0
+
+
+ gov.nasa
+ xpc-examples
+ 1.4.0-SNAPSHOT
+
+
+ discovery-example
+ XPC Discovery Example
+
diff --git a/Java/Examples/DiscoveryExample/src/DiscoveryConnectionExample.java b/Java/Examples/discovery/src/main/java/gov/nasa/xpc/ex/DiscoveryConnectionExample.java
similarity index 100%
rename from Java/Examples/DiscoveryExample/src/DiscoveryConnectionExample.java
rename to Java/Examples/discovery/src/main/java/gov/nasa/xpc/ex/DiscoveryConnectionExample.java
diff --git a/Java/Examples/DiscoveryExample/src/SimpleDiscoveryExample.java b/Java/Examples/discovery/src/main/java/gov/nasa/xpc/ex/SimpleDiscoveryExample.java
similarity index 100%
rename from Java/Examples/DiscoveryExample/src/SimpleDiscoveryExample.java
rename to Java/Examples/discovery/src/main/java/gov/nasa/xpc/ex/SimpleDiscoveryExample.java
diff --git a/Java/Examples/pom.xml b/Java/Examples/pom.xml
new file mode 100644
index 00000000..3b99c0f2
--- /dev/null
+++ b/Java/Examples/pom.xml
@@ -0,0 +1,30 @@
+
+
+ 4.0.0
+
+
+ gov.nasa
+ xpc-parent
+ 1.4.0-SNAPSHOT
+
+
+ xpc-examples
+ pom
+ xpc-examples
+
+
+ basic-operation
+ continuous-operation
+ discovery
+ playback
+
+
+
+
+ gov.nasa
+ xpc
+ 1.4.0-SNAPSHOT
+
+
+
+
\ No newline at end of file
diff --git a/Java/pom.xml b/Java/pom.xml
new file mode 100644
index 00000000..c1516944
--- /dev/null
+++ b/Java/pom.xml
@@ -0,0 +1,173 @@
+
+
+
+ 4.0.0
+
+
+ org.sonatype.oss
+ oss-parent
+ 7
+
+
+ gov.nasa
+ xpc-parent
+ 1.4.0-SNAPSHOT
+ pom
+
+ X-Plane Connect Parent
+ X-Plane Connect
+ https://github.com/nasa/XPlaneConnect
+
+
+ xpc
+ examples
+
+
+
+ UTF-8
+ 1.8
+
+
+
+ https://github.com/nasa/XPlaneConnect
+ scm:git:https://github.com/nasa/XPlaneConnect.git
+ scm:git:git@github.com:nasa/XPlaneConnect.git
+ HEAD
+
+
+
+ GitHub Issues
+ https://github.com/nasa/XPlaneConnect/issues
+
+
+
+
+ NASA Open Source Agreement Version 1.3
+ https://github.com/nasa/XPlaneConnect/blob/master/license.pdf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ 1.8
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Java/src/produce_jar.cmd b/Java/src/produce_jar.cmd
new file mode 100644
index 00000000..b77151ee
--- /dev/null
+++ b/Java/src/produce_jar.cmd
@@ -0,0 +1,5 @@
+@echo off
+mkdir build
+javac -d build\ discovery\*.java *.java
+cd build
+jar cfe XPlaneConnect.jar gob.nasa.xpc.XPlaneConnect gov\nasa\xpc\*.class gov\nasa\xpc\discovery\*.class
\ No newline at end of file
diff --git a/Java/xpc/.classpath b/Java/xpc/.classpath
new file mode 100644
index 00000000..5e8a55fe
--- /dev/null
+++ b/Java/xpc/.classpath
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Java/xpc/.gitignore b/Java/xpc/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/Java/xpc/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/Java/xpc/.project b/Java/xpc/.project
new file mode 100644
index 00000000..d5eced5f
--- /dev/null
+++ b/Java/xpc/.project
@@ -0,0 +1,23 @@
+
+
+ xpc
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/Java/xpc/.settings/org.eclipse.core.resources.prefs b/Java/xpc/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..e9441bb1
--- /dev/null
+++ b/Java/xpc/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding/=UTF-8
diff --git a/Java/xpc/.settings/org.eclipse.jdt.core.prefs b/Java/xpc/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..2f5cc74c
--- /dev/null
+++ b/Java/xpc/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/Java/xpc/.settings/org.eclipse.m2e.core.prefs b/Java/xpc/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 00000000..f897a7f1
--- /dev/null
+++ b/Java/xpc/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/Java/xpc/pom.xml b/Java/xpc/pom.xml
new file mode 100644
index 00000000..d977dc4d
--- /dev/null
+++ b/Java/xpc/pom.xml
@@ -0,0 +1,18 @@
+
+
+ 4.0.0
+
+
+ gov.nasa
+ xpc-parent
+ 1.4.0-SNAPSHOT
+
+
+ xpc
+
+
+ xpc
+
+
+
+
\ No newline at end of file
diff --git a/Java/src/ViewType.java b/Java/xpc/src/main/java/gov/nasa/xpc/ViewType.java
similarity index 100%
rename from Java/src/ViewType.java
rename to Java/xpc/src/main/java/gov/nasa/xpc/ViewType.java
diff --git a/Java/src/WaypointOp.java b/Java/xpc/src/main/java/gov/nasa/xpc/WaypointOp.java
similarity index 100%
rename from Java/src/WaypointOp.java
rename to Java/xpc/src/main/java/gov/nasa/xpc/WaypointOp.java
diff --git a/Java/src/XPlaneConnect.java b/Java/xpc/src/main/java/gov/nasa/xpc/XPlaneConnect.java
similarity index 90%
rename from Java/src/XPlaneConnect.java
rename to Java/xpc/src/main/java/gov/nasa/xpc/XPlaneConnect.java
index df32cffb..86daf6a7 100644
--- a/Java/src/XPlaneConnect.java
+++ b/Java/xpc/src/main/java/gov/nasa/xpc/XPlaneConnect.java
@@ -323,8 +323,10 @@ public float[][] getDREFs(String[] drefs) throws IOException
int cur = 6;
for(int j = 0; j < result.length; ++j)
{
- result[j] = new float[data[cur++]];
- for(int k = 0; k < result[j].length; ++k) //TODO: There must be a better way to do this
+ int data_size = (data[cur] > 0) ? data[cur] : 256 + data[cur];
+ cur++;
+ result[j] = new float[data_size];
+ for(int k = 0; k < result[j].length; ++k)
{
result[j][k] = bb.getFloat(cur);
cur += 4;
@@ -413,6 +415,75 @@ public void sendDREFs(String[] drefs, float[][] values) throws IOException
sendUDP(os.toByteArray());
}
+ /**
+ * Sends a command to X-Plane that request a periodic broadcast of the given DataRefs.
+ *
+ * @param freq The frequency at which the data is requested.
+ * @param drefs The names of the X-Plane datarefs to request.
+ * @param dref_idx An array of index whose length must match the number of requested datarefs.
+ * @throws IOException If the command cannot be sent.
+ */
+ public void sendRREFs(int freq, String[] drefs, int[] dref_idx) throws IOException
+ {
+ //Preconditions
+ if(freq == 0 )
+ {
+ throw new IllegalArgumentException(("request frequency cannot be zero."));
+ }
+ if(drefs == null || drefs.length == 0)
+ {
+ throw new IllegalArgumentException(("drefs must be non-empty."));
+ }
+ if(dref_idx.length != drefs.length)
+ {
+ throw new IllegalArgumentException("index must be of the same size as drefs.");
+ }
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ os.write("RREF".getBytes(StandardCharsets.UTF_8));
+ os.write(0xFF); //Placeholder for message length
+ ByteBuffer freq_bb = ByteBuffer.allocate(4).putInt(freq);
+ freq_bb.order(ByteOrder.LITTLE_ENDIAN);
+ os.write(freq_bb);
+ for(int i = 0; i < drefs.length; ++i)
+ {
+ String dref = drefs[i];
+ int idx = dref_idx[i];
+
+ if (dref == null)
+ {
+ throw new IllegalArgumentException("dref must be a valid string.");
+ }
+
+
+
+ //Convert drefs to bytes.
+ byte[] drefBytes = dref.getBytes(StandardCharsets.UTF_8);
+ if (drefBytes.length == 0)
+ {
+ throw new IllegalArgumentException("DREF is an empty string!");
+ }
+ if (drefBytes.length > 255)
+ {
+ throw new IllegalArgumentException("dref must be less than 255 bytes in UTF-8. Are you sure this is a valid dref?");
+ }
+
+ //Values
+ ByteBuffer bb = ByteBuffer.allocate(4 * value.length);
+ bb.order(ByteOrder.LITTLE_ENDIAN);
+ for (int j = 0; j < value.length; ++j)
+ {
+ bb.putFloat(j * 4, value[j]);
+ }
+
+ //Build and send message
+ os.write(drefBytes, 0, drefBytes.length);
+ os.write(value.length);
+ os.write(bb.array());
+ }
+ sendUDP(os.toByteArray());
+ }
+
/**
* Gets the control surface information for the specified airplane.
*
@@ -588,9 +659,26 @@ public double[] getPOSI(int ac) throws IOException
double[] result = new double[7];
ByteBuffer bb = ByteBuffer.wrap(data);
bb.order(ByteOrder.LITTLE_ENDIAN);
- for(int i = 0; i < 7; ++i)
- {
- result[i] = bb.getFloat(6 + 4 * i);
+
+ if (bb.capacity() == 34) { //In XPlane v10 --> latitude/longitude/elevation are floats
+ for(int i = 0; i < 7; ++i)
+ {
+ result[i] = bb.getFloat(6 + 4 * i);
+ }
+ }else if (bb.capacity() == 46) { //In XPlane v11 --> latitude/longitude/elevation are double
+ for(int i = 0; i < 7; ++i)
+ {
+ if(i<3)
+ {
+ result[i] = bb.getDouble(6 + 8 * i);
+ }else
+ {
+ result[i] = bb.getFloat(30 + 4 * (i-3));
+ }
+
+ }
+ }else {
+ throw new IOException("Unexpected POSI message length received");
}
return result;
}
diff --git a/Java/src/discovery/Beacon.java b/Java/xpc/src/main/java/gov/nasa/xpc/discovery/Beacon.java
similarity index 100%
rename from Java/src/discovery/Beacon.java
rename to Java/xpc/src/main/java/gov/nasa/xpc/discovery/Beacon.java
diff --git a/Java/src/discovery/BeaconParser.java b/Java/xpc/src/main/java/gov/nasa/xpc/discovery/BeaconParser.java
similarity index 100%
rename from Java/src/discovery/BeaconParser.java
rename to Java/xpc/src/main/java/gov/nasa/xpc/discovery/BeaconParser.java
diff --git a/Java/src/discovery/BeaconReceivedListener.java b/Java/xpc/src/main/java/gov/nasa/xpc/discovery/BeaconReceivedListener.java
similarity index 100%
rename from Java/src/discovery/BeaconReceivedListener.java
rename to Java/xpc/src/main/java/gov/nasa/xpc/discovery/BeaconReceivedListener.java
diff --git a/Java/src/discovery/DiscoveryConnectionCallback.java b/Java/xpc/src/main/java/gov/nasa/xpc/discovery/DiscoveryConnectionCallback.java
similarity index 100%
rename from Java/src/discovery/DiscoveryConnectionCallback.java
rename to Java/xpc/src/main/java/gov/nasa/xpc/discovery/DiscoveryConnectionCallback.java
diff --git a/Java/src/discovery/XPlaneConnectDiscovery.java b/Java/xpc/src/main/java/gov/nasa/xpc/discovery/XPlaneConnectDiscovery.java
similarity index 100%
rename from Java/src/discovery/XPlaneConnectDiscovery.java
rename to Java/xpc/src/main/java/gov/nasa/xpc/discovery/XPlaneConnectDiscovery.java
diff --git a/MATLAB/+XPlaneConnect/XPlaneConnect.jar b/MATLAB/+XPlaneConnect/XPlaneConnect.jar
index a182eb3c..c234d984 100644
Binary files a/MATLAB/+XPlaneConnect/XPlaneConnect.jar and b/MATLAB/+XPlaneConnect/XPlaneConnect.jar differ
diff --git a/Python3/src/XPlaneUdpExample.py b/Python3/src/XPlaneUdpExample.py
new file mode 100644
index 00000000..1c918e7d
--- /dev/null
+++ b/Python3/src/XPlaneUdpExample.py
@@ -0,0 +1,248 @@
+# Class to get dataref values from XPlane Flight Simulator via network.
+# License: GPLv3
+
+import socket
+import struct
+import binascii
+from time import sleep
+import platform
+
+class XPlaneIpNotFound(Exception):
+ args="Could not find any running XPlane instance in network."
+
+class XPlaneTimeout(Exception):
+ args="XPlane timeout."
+
+class XPlaneVersionNotSupported(Exception):
+ args="XPlane version not supported."
+
+class XPlaneUdp:
+
+ '''
+ Get data from XPlane via network.
+ Use a class to implement RAI Pattern for the UDP socket.
+ '''
+
+ #constants
+ MCAST_GRP = "239.255.1.1"
+ MCAST_PORT = 49707 # (MCAST_PORT was 49000 for XPlane10)
+
+ def __init__(self):
+ # Open a UDP Socket to receive on Port 49000
+ self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ self.socket.settimeout(3.0)
+ # list of requested datarefs with index number
+ self.datarefidx = 0
+ self.datarefs = {} # key = idx, value = dataref
+ # values from xplane
+ self.BeaconData = {}
+ self.xplaneValues = {}
+ self.defaultFreq = 1
+
+ def __del__(self):
+ for i in range(len(self.datarefs)):
+ self.AddDataRef(next(iter(self.datarefs.values())), freq=0)
+ self.socket.close()
+ def WriteDataRef(self,dataref,value,vtype='float'):
+ '''
+ Write Dataref to XPlane
+ DREF0+(4byte byte value)+dref_path+0+spaces to complete the whole message to 509 bytes
+ DREF0+(4byte byte value of 1)+ sim/cockpit/switches/anti_ice_surf_heat_left+0+spaces to complete to 509 bytes
+ '''
+ cmd = b"DREF\x00"
+ dataref =dataref+'\x00'
+ string = dataref.ljust(500).encode()
+ message = "".encode()
+ if vtype == "float":
+ message = struct.pack("<5sf500s", cmd,value,string)
+ elif vtype == "int":
+ message = struct.pack("<5si500s", cmd, value, string)
+ elif vtype == "bool":
+ message = struct.pack("<5sI500s", cmd, int(value), string)
+
+ assert(len(message)==509)
+ self.socket.sendto(message, (self.BeaconData["IP"], self.UDP_PORT))
+
+ def AddDataRef(self, dataref, freq = None):
+
+ '''
+ Configure XPlane to send the dataref with a certain frequency.
+ You can disable a dataref by setting freq to 0.
+ '''
+
+ idx = -9999
+
+ if freq == None:
+ freq = self.defaultFreq
+
+ if dataref in self.datarefs.values():
+ idx = list(self.datarefs.keys())[list(self.datarefs.values()).index(dataref)]
+ if freq == 0:
+ if dataref in self.xplaneValues.keys():
+ del self.xplaneValues[dataref]
+ del self.datarefs[idx]
+ else:
+ idx = self.datarefidx
+ self.datarefs[self.datarefidx] = dataref
+ self.datarefidx += 1
+
+ cmd = b"RREF\x00"
+ string = dataref.encode()
+ message = struct.pack("<5sii400s", cmd, freq, idx, string)
+ assert(len(message)==413)
+ self.socket.sendto(message, (self.BeaconData["IP"], self.BeaconData["Port"]))
+ if (self.datarefidx%100 == 0):
+ sleep(0.2)
+
+ def GetValues(self):
+ try:
+ # Receive packet
+ data, addr = self.socket.recvfrom(1472) # maximum bytes of an RREF answer X-Plane will send (Ethernet MTU - IP hdr - UDP hdr)
+ # Decode Packet
+ retvalues = {}
+ # * Read the Header "RREFO".
+ header=data[0:5]
+ if(header!=b"RREF,"): # (was b"RREFO" for XPlane10)
+ print("Unknown packet: ", binascii.hexlify(data))
+ else:
+ # * We get 8 bytes for every dataref sent:
+ # An integer for idx and the float value.
+ values =data[5:]
+ lenvalue = 8
+ numvalues = int(len(values)/lenvalue)
+ for i in range(0,numvalues):
+ singledata = data[(5+lenvalue*i):(5+lenvalue*(i+1))]
+ (idx,value) = struct.unpack(" -0.001 :
+ value = 0.0
+ retvalues[self.datarefs[idx]] = value
+ self.xplaneValues.update(retvalues)
+ except:
+ raise XPlaneTimeout
+ return self.xplaneValues
+
+ def FindIp(self):
+
+ '''
+ Find the IP of XPlane Host in Network.
+ It takes the first one it can find.
+ '''
+
+ self.BeaconData = {}
+
+ # open socket for multicast group.
+ sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
+ sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+ if platform.system() == "Windows":
+ sock.bind(('', self.MCAST_PORT))
+ else:
+ sock.bind((self.MCAST_GRP, self.MCAST_PORT))
+ mreq = struct.pack("=4sl", socket.inet_aton(self.MCAST_GRP), socket.INADDR_ANY)
+ sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
+ sock.settimeout(3.0)
+
+ # receive data
+ try:
+ packet, sender = sock.recvfrom(1472)
+ print("XPlane Beacon: ", packet.hex())
+
+ # decode data
+ # * Header
+ header = packet[0:5]
+ if header != b"BECN\x00":
+ print("Unknown packet from "+sender[0])
+ print(str(len(packet)) + " bytes")
+ print(packet)
+ print(binascii.hexlify(packet))
+
+ else:
+ # * Data
+ data = packet[5:21]
+ # struct becn_struct
+ # {
+ # uchar beacon_major_version; // 1 at the time of X-Plane 10.40
+ # uchar beacon_minor_version; // 1 at the time of X-Plane 10.40
+ # xint application_host_id; // 1 for X-Plane, 2 for PlaneMaker
+ # xint version_number; // 104014 for X-Plane 10.40b14
+ # uint role; // 1 for master, 2 for extern visual, 3 for IOS
+ # ushort port; // port number X-Plane is listening on
+ # xchr computer_name[strDIM]; // the hostname of the computer
+ # };
+ beacon_major_version = 0
+ beacon_minor_version = 0
+ application_host_id = 0
+ xplane_version_number = 0
+ role = 0
+ port = 0
+ (
+ beacon_major_version, # 1 at the time of X-Plane 10.40
+ beacon_minor_version, # 1 at the time of X-Plane 10.40
+ application_host_id, # 1 for X-Plane, 2 for PlaneMaker
+ xplane_version_number, # 104014 for X-Plane 10.40b14
+ role, # 1 for master, 2 for extern visual, 3 for IOS
+ port, # port number X-Plane is listening on
+ ) = struct.unpack(" 255:
+ raise ValueError("comm must be a non-empty string less than 256 characters.")
+
+ # Pack message
+ fmt = "
#include
#include