Merge pull request #24 from edowson/user/edowson
CMake Files Added and xpcExample moved into src sub-folder
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -38,3 +38,5 @@ xpcPlugin/build/xpcPlugin.build/Debug/xpcPlugin.build/Objects-normal/x86_64/XPCP
|
||||
xpcPlugin/build/xpcPlugin.build/Debug/xpcPlugin.build/Objects-normal/x86_64/xplaneConnect.o
|
||||
|
||||
xpcPlugin/xpcPlugin.xcodeproj/project.xcworkspace/xcuserdata/cteubert.xcuserdatad/UserInterfaceState.xcuserstate
|
||||
|
||||
build/
|
||||
|
||||
5
C/CMakeLists.txt
Normal file
5
C/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
cmake_minimum_required(VERSION 2.8.4)
|
||||
|
||||
project(xplaneconnectlib)
|
||||
|
||||
add_subdirectory(src)
|
||||
@@ -1,31 +1,31 @@
|
||||
X-Plane Connect-C (XPC-C) Readme
|
||||
|
||||
DESCRIPTION
|
||||
XPC-C is a series of C functions that facilitate communication with X-Plane.
|
||||
|
||||
XPC-C is a series of C functions that facilitate communication with X-Plane.
|
||||
|
||||
-----------------------------------
|
||||
SETUP
|
||||
Before using XPC Functions you must
|
||||
1. Copy the file XPCPlugin.xpl to the "[X-Plane Directory]/Resources/plugins" directory.
|
||||
2. Put in X-Plane CD 1 or X-Plane USB Key.
|
||||
3. Start X-Plane.
|
||||
Before using XPC Functions you must
|
||||
1. Copy the file XPCPlugin.xpl to the "[X-Plane Directory]/Resources/plugins" directory.
|
||||
2. Put in X-Plane CD 1 or X-Plane USB Key.
|
||||
3. Start X-Plane.
|
||||
4. #include "xplaneConnect.h"
|
||||
|
||||
-----------------------------------
|
||||
BASIC FUNCTIONS
|
||||
1. openUDP opens a UDP Socket for communication. This is used to send data or receive.
|
||||
INPUT:
|
||||
INPUT:
|
||||
port (unsigned short): Port Number (ex:49067)
|
||||
xpIP (char *): IP Address of the computer running x-plane
|
||||
xpPort (unsigned short): Port number that the X-Plane/ xpcPlugin Receives on (send -1 for default (49009), Typically xpcPlugin is 49009)
|
||||
|
||||
OUTPUT:
|
||||
socket (xpcSocket): The Opened Socket
|
||||
|
||||
|
||||
USE:
|
||||
unsigned short portNumber = 49067;
|
||||
struct xpcSocket theSocket = openUDP(portNumber, “127.0.0.1”, 49009);
|
||||
|
||||
|
||||
2. closeUDP closes an opened UDP Socket for communication. This is to be done after the program has finished using that socket. Use opedUDP to open socket.
|
||||
INPUT:
|
||||
socket (xpcSocket): The Opened Socket
|
||||
@@ -37,10 +37,10 @@ BASIC FUNCTIONS
|
||||
INPUT:
|
||||
socket (xpcSocket): Socket to use to send the command
|
||||
recPort (unsigned Short): Port number for requested dataref values to be sent to
|
||||
|
||||
|
||||
OUTPUT:
|
||||
status (short): 0 if successful
|
||||
|
||||
|
||||
USE:
|
||||
char IP[16] = "127.0.0.1";
|
||||
struct xpcSocket theSocket = openUDP(49067);
|
||||
@@ -50,7 +50,7 @@ BASIC FUNCTIONS
|
||||
INPUT:
|
||||
socket (xpcSocket): Socket to use to send the command
|
||||
pause (short): 1=Pause, 0=Resume
|
||||
|
||||
|
||||
OUTPUT:
|
||||
status (short): 0 if successful
|
||||
|
||||
@@ -58,22 +58,22 @@ BASIC FUNCTIONS
|
||||
char IP[16] = "127.0.0.1";
|
||||
struct xpcSocket theSocket = openUDP(49067);
|
||||
pauseSim(theSocket, IP, 49009, 1);
|
||||
|
||||
|
||||
5. sendDATA set the value of a state in the "DATA Input & Output" Table
|
||||
INPUT:
|
||||
socket (xpcSocket): Socket to use to send the command
|
||||
dataArray (float[][9]): Array of data to be sent. The first element of each row is the item # (corresponding to the number on the X-Plane "DATA Input & Output" Screen). Send -999 to leave the value unchanged.
|
||||
rows (unsigned short): Number of rows of data being sent
|
||||
|
||||
|
||||
OUTPUT:
|
||||
status (short): 0 if successful
|
||||
|
||||
|
||||
USE:
|
||||
char IP[16] = "127.0.0.1";
|
||||
struct xpcSocket theSocket = openUDP(49067);
|
||||
float data[] = {{14, 1, -999, -999, -999, -999, -999, -999, -999},{25, 0.8, 0.8, -999, -999, -999, -999, -999, -999}}; // Gear and Throttle
|
||||
sendDATA(theSocket,IP,49009,data,2);
|
||||
|
||||
|
||||
6. sendPOSI set the position of an aircraft
|
||||
INPUT:
|
||||
socket (xpcSocket): Socket to use to send the command
|
||||
@@ -87,7 +87,7 @@ BASIC FUNCTIONS
|
||||
position[4] = Pitch (deg)
|
||||
position[5] = True Heading (deg)
|
||||
position[6] = Gear (0=up, 1=down)
|
||||
|
||||
|
||||
OUTPUT:
|
||||
status (short): 0 if successful
|
||||
|
||||
@@ -96,7 +96,7 @@ BASIC FUNCTIONS
|
||||
struct xpcSocket theSocket = openUDP(49067);
|
||||
float posit[] = {37.5242422, -122.06899, 2500, 0, 0, 0, 1};
|
||||
sendPOSI(theSocket, IP, 49009, 7, posit);
|
||||
|
||||
|
||||
7. sendCTRL send control commands to the aircraft
|
||||
INPUT:
|
||||
socket (xpcSocket): Socket to use to send the command
|
||||
@@ -108,16 +108,16 @@ BASIC FUNCTIONS
|
||||
control[3] = Throttle [-1, 1]
|
||||
control[4] = Gear (0=up, 1=down)
|
||||
control[5] = Flaps [0, 1]
|
||||
|
||||
|
||||
OUTPUT:
|
||||
status (short): 0 if successful
|
||||
|
||||
|
||||
USE:
|
||||
char IP[16] = "127.0.0.1";
|
||||
struct xpcSocket theSocket = openUDP(49067);
|
||||
float ctrl[] = {0, 0, 0, 0.8, 0, 1};
|
||||
sendCTRL(theSocket, IP, 49009, 6, ctrl);
|
||||
|
||||
|
||||
8. sendDREF set the value of a specific dataref. Dataref list found at http://www.xsquawkbox.net/xpsdk/docs/DataRefs.html
|
||||
INPUT:
|
||||
socket (xpcSocket): Socket to use to send the command
|
||||
@@ -125,7 +125,7 @@ BASIC FUNCTIONS
|
||||
length (short): length of dataref string
|
||||
values (float *): Array of values to be sent
|
||||
length2 (short): Number of values in values array
|
||||
|
||||
|
||||
OUTPUT:
|
||||
status (short): 0 if successful
|
||||
|
||||
@@ -135,7 +135,7 @@ BASIC FUNCTIONS
|
||||
char theDREF[] = "cockpit/switches/gear_handle_status";
|
||||
float value = 1;
|
||||
sendDREF(theSocket, IP, 49009, theDREF, strlen(theDREF), &value, 1);
|
||||
|
||||
|
||||
9. requestDREF Request the value of specific dref(s). Dataref list found at http://www.xsquawkbox.net/xpsdk/docs/DataRefs.html
|
||||
INPUT:
|
||||
outSocket (xpcSocket): Socket to use to send the command
|
||||
@@ -145,7 +145,7 @@ BASIC FUNCTIONS
|
||||
listLength (short): Number of DataRefs in DREFArray
|
||||
result (*float[]): Array of pointers to the values returned
|
||||
arrayLen (short[]): Array where each element corresponds to the number of elements in the float array.
|
||||
|
||||
|
||||
OUTPUT:
|
||||
length (short): Number of Values Returned
|
||||
|
||||
@@ -154,7 +154,7 @@ BASIC FUNCTIONS
|
||||
struct xpcSocket theSocket = openUDP(49067);
|
||||
char DREFArray[][100] = {"sim/cockpit/switches/gear_handle_status"};
|
||||
requestDREF(theSocket, IP, 49009, DREFArray, strlen(DREFArray[0]),1);
|
||||
|
||||
|
||||
-----------------------------------
|
||||
ADVANCED FUNCTIONS (These are mostly used by the xpcPlugin to read requests)
|
||||
1. sendUDP
|
||||
|
||||
19
C/src/CMakeLists.txt
Normal file
19
C/src/CMakeLists.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 2.8.4)
|
||||
|
||||
set(LIBXPLANECONNECT_SRC xplaneConnect.c)
|
||||
|
||||
add_library(xplaneconnect_dynamic SHARED ${LIBXPLANECONNECT_SRC})
|
||||
add_library(xplaneconnect_static STATIC ${LIBXPLANECONNECT_SRC})
|
||||
|
||||
set_target_properties(xplaneconnect_dynamic PROPERTIES OUTPUT_NAME "xplaneconnect")
|
||||
set_target_properties(xplaneconnect_dynamic PROPERTIES VERSION 1.2 SOVERSION 1)
|
||||
|
||||
set_target_properties(xplaneconnect_static PROPERTIES OUTPUT_NAME "xplaneconnect")
|
||||
|
||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
||||
|
||||
install(TARGETS xplaneconnect_dynamic xplaneconnect_static
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib)
|
||||
|
||||
install(FILES xplaneConnect.h DESTINATION include/xplaneConnect)
|
||||
@@ -16,14 +16,14 @@
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
BE60308318E5F7A5004B5E1D /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 12;
|
||||
buildActionMask = 8;
|
||||
dstPath = /Users/cteubert/Documents/flightdeckz/connections/src/xplaneconnect;
|
||||
dstSubfolderSpec = 0;
|
||||
files = (
|
||||
BEDC620818EDF254005DB364 /* xplaneConnect.c in CopyFiles */,
|
||||
BEDC620918EDF257005DB364 /* xplaneConnect.h in CopyFiles */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
runOnlyForDeploymentPostprocessing = 1;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
BEDC61FF18EDF0F5005DB364 /* xplaneConnect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = xplaneConnect.c; path = ../src/xplaneConnect.c; sourceTree = "<group>"; };
|
||||
BEDC620018EDF0F5005DB364 /* xplaneConnect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xplaneConnect.h; path = ../src/xplaneConnect.h; sourceTree = "<group>"; };
|
||||
BEF9890B18E4E7F7005554D1 /* xpcExample */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = xpcExample; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BEF9890E18E4E7F7005554D1 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
|
||||
BEF9890E18E4E7F7005554D1 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = src/main.cpp; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -105,7 +105,7 @@
|
||||
BEF9890318E4E7F7005554D1 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0500;
|
||||
LastUpgradeCheck = 0610;
|
||||
ORGANIZATIONNAME = "Chris Teubert";
|
||||
};
|
||||
buildConfigurationList = BEF9890618E4E7F7005554D1 /* Build configuration list for PBXProject "xpcExample" */;
|
||||
@@ -209,7 +209,6 @@
|
||||
BEF9891518E4E7F7005554D1 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
@@ -222,7 +221,6 @@
|
||||
BEF9891618E4E7F7005554D1 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
|
||||
@@ -10,31 +10,31 @@
|
||||
<string>xpcExample</string>
|
||||
<key>IDESourceControlProjectOriginsDictionary</key>
|
||||
<dict>
|
||||
<key>C03F0B00-9A73-4E8C-88E5-1BC53A92AE34</key>
|
||||
<string>https://github.com/nasa/XPlaneConnect.git</string>
|
||||
<key>975A665F236BF35140EC3819BE16448F522675A6</key>
|
||||
<string>ssh://ares:8420/aerospace/simulation/xplane/xplane_connect</string>
|
||||
</dict>
|
||||
<key>IDESourceControlProjectPath</key>
|
||||
<string>C/xpcExample/xpcExample.xcodeproj/project.xcworkspace</string>
|
||||
<string>C/xpcExample/xpcExample.xcodeproj</string>
|
||||
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
|
||||
<dict>
|
||||
<key>C03F0B00-9A73-4E8C-88E5-1BC53A92AE34</key>
|
||||
<key>975A665F236BF35140EC3819BE16448F522675A6</key>
|
||||
<string>../../../..</string>
|
||||
</dict>
|
||||
<key>IDESourceControlProjectURL</key>
|
||||
<string>https://github.com/nasa/XPlaneConnect.git</string>
|
||||
<string>ssh://ares:8420/aerospace/simulation/xplane/xplane_connect</string>
|
||||
<key>IDESourceControlProjectVersion</key>
|
||||
<integer>110</integer>
|
||||
<integer>111</integer>
|
||||
<key>IDESourceControlProjectWCCIdentifier</key>
|
||||
<string>C03F0B00-9A73-4E8C-88E5-1BC53A92AE34</string>
|
||||
<string>975A665F236BF35140EC3819BE16448F522675A6</string>
|
||||
<key>IDESourceControlProjectWCConfigurations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
|
||||
<string>public.vcs.git</string>
|
||||
<key>IDESourceControlWCCIdentifierKey</key>
|
||||
<string>C03F0B00-9A73-4E8C-88E5-1BC53A92AE34</string>
|
||||
<string>975A665F236BF35140EC3819BE16448F522675A6</string>
|
||||
<key>IDESourceControlWCCName</key>
|
||||
<string>XPlaneConnect</string>
|
||||
<string>xplane_connect</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
|
||||
5
C/xpcExample/xpcExample/CMakeLists.txt
Normal file
5
C/xpcExample/xpcExample/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
cmake_minimum_required(VERSION 2.8.4)
|
||||
|
||||
project(xpcExample)
|
||||
|
||||
add_subdirectory(src)
|
||||
13
C/xpcExample/xpcExample/src/CMakeLists.txt
Normal file
13
C/xpcExample/xpcExample/src/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
cmake_minimum_required(VERSION 2.8.4)
|
||||
|
||||
add_executable(main main.cpp)
|
||||
|
||||
include_directories(/usr/local/include/xplaneConnect)
|
||||
|
||||
find_library(XPLANECONNECT_LIB NAMES xplaneconnect PATHS "/usr/local/lib")
|
||||
|
||||
message(STATUS "Library path XPLANECONNECT_LIB is " ${XPLANECONNECT_LIB})
|
||||
|
||||
target_link_libraries(main ${XPLANECONNECT_LIB})
|
||||
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
Reference in New Issue
Block a user