Merge branch 'release-1.0' into develop

This commit is contained in:
Jason Watkins
2015-04-28 12:11:59 -07:00
35 changed files with 66 additions and 998 deletions

View File

@@ -1,192 +0,0 @@
X-Plane Connect-C (XPC-C) Readme
DESCRIPTION
XPC-C is a series of C functions that facilitate communication with X-Plane.
-----------------------------------
SETUP
Before using XPC Functions you must
1. Copy the folder "[XPC Directory]/xpcPlugin/XPlaneConnect" 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:
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
USE:
closeUDP(theSocket);
3. setCONN sets the return port for requested datarefs.
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);
setCONN(theSocket,IP,49009,49022); // Sets receive address to 49022;
4. pauseSim pauses/resumes the x-plane simulation
INPUT:
socket (xpcSocket): Socket to use to send the command
pause (short): 1=Pause, 0=Resume
OUTPUT:
status (short): 0 if successful
USE:
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
ACNum (short): Number of aircraft to be moved, use 0 for main aircraft (ownPlane).
numArgs (short): Number of Arguments to be sent (size of position array)
position (float []): Arguments corresponding to aircrafts position
position[0] = Latitude
position[1] = Longitude
position[2] = Altitude (m MSL)
position[3] = Roll (deg)
position[4] = Pitch (deg)
position[5] = True Heading (deg)
position[6] = Gear (0=up, 1=down)
OUTPUT:
status (short): 0 if successful
USE:
char IP[16] = "127.0.0.1";
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
numArgs (short): Number of Arguments to be sent (size of control array)
control (float []): Arguments corresponding to aircraft control command
control[0] = Latitudinal Stick [-1,1]
control[1] = Longitudinal Stick [-1,1]
control[2] = Pedal [-1, 1]
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
dataRef (char *): Dataref to be set (with or without "sim/" preceeding it)
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
USE:
char IP[16] = "127.0.0.1";
struct xpcSocket theSocket = openUDP(49067);
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
inSocket (xpcSocket): Socket to use to receive the result
DREFArray (char[][100]): Array of DataRefs to be requested
DREFSizes (int[]): Array of string lengths for each DataRef in DREFArray
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
USE:
char IP[16] = "127.0.0.1";
struct xpcSocket theSocket = openUDP(49067);
char DREFArray[][100] = {"sim/cockpit/switches/gear_handle_status"};
requestDREF(theSocket, IP, 49009, DREFArray, strlen(DREFArray[0]),1);
10. sendTEXT write some text to the screen.
INPUT:
outSocket (xpcSocket): Socket to use to send the command
message (char*): The string to be wrote to the screen
x (int): The x position where the text will be written. Set to -1 to use default position.
y (int): The y position where the text will be written. Set to -1 to use default position.
-----------------------------------
ADVANCED FUNCTIONS (These are mostly used by the xpcPlugin to read requests)
1. sendUDP
2. readUDP
3. readDATA
4. parseDATA
5. readPOSI
6. parsePOSI
7. readCTRL
8. parseCTRL
9. readRequest
10. parseRequest
11. parseDREF
12. readDREF
-----------------------------------
PLANNED FUNCTIONS
1. sendVIEW
2. parseVIEW
3. readVIEW
4. sendWYPT
5. parseWYPT
6. readWYPT
7. selectDATA
-----------------------------------
CONTACT
Email Christopher Teubert (christopher.a.teubert@nasa.gov) with any questions.

View File

@@ -362,7 +362,7 @@ int readDATA(XPCSocket sock, float data[][9], int rows)
/*****************************************************************************/ /*****************************************************************************/
/**** DREF functions ****/ /**** DREF functions ****/
/*****************************************************************************/ /*****************************************************************************/
int setDREF(XPCSocket sock, const char* dref, float value[], int size) int sendDREF(XPCSocket sock, const char* dref, float value[], int size)
{ {
// Setup command // Setup command
// 5 byte header + max 255 char dref name + max 255 values * 4 bytes per value = 1279 // 5 byte header + max 255 char dref name + max 255 values * 4 bytes per value = 1279
@@ -432,23 +432,24 @@ int getDREFResponse(XPCSocket sock, float* values[], unsigned char count, int si
// Read data. Try 40 times to read, then give up. // Read data. Try 40 times to read, then give up.
// TODO: Why not just set the timeout to 40ms? // TODO: Why not just set the timeout to 40ms?
int result; int result;
for (int i = 0; i < 512; ++i) for (int i = 0; i < 40; ++i)
{ {
result = readUDP(sock, buffer, 65536); result = readUDP(sock, buffer, 65536);
if (result > 0) if (result > 0)
{ {
break; break;
} }
if (result < 0)
{
#ifdef _WIN32
printError("getDREFs", "Read operation failed. (%d)", WSAGetLastError());
#else
printError("getDREFs", "Read operation failed.");
#endif
return -1;
}
} }
if (result < 0)
{
#ifdef _WIN32
printError("getDREFs", "Read operation failed. (%d)", WSAGetLastError());
#else
printError("getDREFs", "Read operation failed.");
#endif
return -1;
}
if (result < 6) if (result < 6)
{ {

View File

@@ -133,7 +133,7 @@ int sendDATA(XPCSocket sock, float data[][9], int rows);
/// \param values An array of values representing the data to set. /// \param values An array of values representing the data to set.
/// \param size The number of elements in values. /// \param size The number of elements in values.
/// \returns 0 if successful, otherwise a negative value. /// \returns 0 if successful, otherwise a negative value.
int setDREF(XPCSocket sock, const char* dref, float value[], int size); int sendDREF(XPCSocket sock, const char* dref, float value[], int size);
/// Gets the value of the specified dataref. /// Gets the value of the specified dataref.
/// ///

View File

@@ -93,7 +93,7 @@ int main()
const char* dref = "sim/cockpit/switches/gear_handle_status"; // Gear handle data reference const char* dref = "sim/cockpit/switches/gear_handle_status"; // Gear handle data reference
float gear = 0; // Stow gear float gear = 0; // Stow gear
setDREF(sock, dref, &gear, 1); // Set gear to stow sendDREF(sock, dref, &gear, 1); // Set gear to stow
// Simulate for 10 seconds // Simulate for 10 seconds
sleep(10); sleep(10);

View File

@@ -71,7 +71,7 @@ public class Main
try { Thread.sleep(10000); } catch (InterruptedException ex) {} try { Thread.sleep(10000); } catch (InterruptedException ex) {}
System.out.println("Stowing landing gear"); System.out.println("Stowing landing gear");
xpc.setDREF("sim/cockpit/switches/gear_handle_status", 1); xpc.sendDREF("sim/cockpit/switches/gear_handle_status", 1);
//Let sim run for 10 seconds //Let sim run for 10 seconds
try { Thread.sleep(10000); } catch (InterruptedException ex) {} try { Thread.sleep(10000); } catch (InterruptedException ex) {}

View File

@@ -306,9 +306,9 @@ public class XPlaneConnect implements AutoCloseable
throw new IOException("No response received."); throw new IOException("No response received.");
} }
public void setDREF(String dref, float value) throws IOException public void sendDREF(String dref, float value) throws IOException
{ {
setDREF(dref, new float[] {value}); sendDREF(dref, new float[] {value});
} }
/** /**
@@ -318,7 +318,7 @@ public class XPlaneConnect implements AutoCloseable
* @param value An array of floating point values whose structure depends on the dref specified. * @param value An array of floating point values whose structure depends on the dref specified.
* @throws IOException If the command cannot be sent. * @throws IOException If the command cannot be sent.
*/ */
public void setDREF(String dref, float[] value) throws IOException public void sendDREF(String dref, float[] value) throws IOException
{ {
//Preconditions //Preconditions
if(dref == null) if(dref == null)
@@ -731,7 +731,7 @@ public class XPlaneConnect implements AutoCloseable
* Sets the port on which the client will receive data from X-Plane. * Sets the port on which the client will receive data from X-Plane.
* *
* @param port The new incoming port number. * @param port The new incoming port number.
* @throws IOException If the command cannnot be sent. * @throws IOException If the command cannot be sent.
*/ */
public void setCONN(int port) throws IOException public void setCONN(int port) throws IOException
{ {

View File

@@ -1,4 +1,4 @@
function setDREF( dref, value, socket ) function sendDREF( dref, value, socket )
% sendDREF Sends a command to X-Plane that sets the given DREF. % sendDREF Sends a command to X-Plane that sets the given DREF.
% %
% Inputs % Inputs

View File

@@ -1,115 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<h1>XPC-MATLAB</h1>
Chris Teubert (Christopher.A.Teubert@nasa.gov)<br />
<h2>Summary</h2>
XPC-MATLAB is a series of MATLAB functions that facilitate communication with X-Plane. This toolbox allows for the real-time application of active control to an XPlane simulation, flight visualization, record state during a flight, or interact with a mission using UDP.
<h2>Table of Contents</h2>
<ol>
<li><a href="#Func">Functions</a></li>
<li><a href="#Setup">Setup</a>
<li><a href="#Use">Use</a></li>
<li><a href="#Example">Example</a></li>
<li><a href="#Future">Future Work</a></li>
<li><a href="#Notice">Notices and Disclaimers</a></li>
<li><a href="#Changes">Change Log</a></li>
</ol>
<a id="Func"><h2>Functions</h2></a>
<h3>Basic Package</h3>
<table><tr><td width="150px">&nbsp;
- <a href="pages/sendDATA.html"><b>sendDATA:</b></a></td><td>
Send X-Plane Formatted DATA over UDP</td></tr><tr><td>&nbsp;
- <a href="pages/sendPOSI.html"><b>sendPOSI:</b></a></td><td>
Send Position and orientation update command to X-Plane over UDP for any aircraft (own or traffic)</td></tr><tr><td>&nbsp;
- <a href="pages/sendCTRL.html"><b>sendCTRL:</b></a></td><td>
Send control commands to X-Plane over UDP for any aircraft (own or traffic)</td></tr><tr><td>&nbsp;
- <a href="pages/sendDREF.html"><b>sendDREF:</b></a></td><td>
Set any X-Plane internal variable (dataref) over UDP </td></tr><tr><td>&nbsp;
- <a href="pages/selectDATA.html"><b>selectDATA:</b></a></td><td>
Choose specific X-Plane DATA parameters to be sent by X-Plane over UDP</td></tr><tr><td>&nbsp;
- <a href="pages/setConn.html"><b>setConn:</b></a></td><td>
Sets the return port for requested datarefs.</td></tr><tr><td>&nbsp;
- <a href="pages/pauseSim.html"><b>pauseSim:</b></a></td><td>
Pause simulation</td></tr><tr><td>&nbsp;
- <a href="pages/openUDP.html"><b>openUDP:</b></a></td><td>
Script that opens an UDP Socket</td></tr><tr><td>&nbsp;
- <a href="pages/closeUDP.html"><b> closeUDP:</b></a></td><td>
Script that closes an UDP Socket</td></tr>
</table>
<h3>Advanced/Special-Use Functions</h3>
<table><tr><td width="150px">&nbsp;
- <a href="pages/clearUDPBuffer.html"><b> clearUDPBuffer:</b></a></td><td>
Script that clears an UDP Socket Buffer</td></tr><tr><td>&nbsp;
- <a href="pages/readDATA.html"><b>readDATA:</b></a></td><td>
Read X-Plane Formatted Data from UDP Socket</td></tr><tr><td>&nbsp;
- <a href="pages/readUDP.html"><b>readUDP:</b></a></td><td>
Read Array from UDP Socket</td></tr><tr><td>&nbsp;
- <a href="pages/sendSTRU.html"><b>sendSTRU:</b></a></td><td>
Send a MATLAB structure over UDP</td></tr><tr><td>&nbsp;
- <a href="pages/sendUDP.html"><b>sendUDP:</b></a></td><td>
Send array over UDP</td></tr>
</table>
<h3>Future</h3>
<table><tr><td width="150px">&nbsp;
- <a href="pages/requestDREF.html"><b>requestDREF:</b></a></td><td>
Request the value of a specific data ref</td></tr><tr><td>&nbsp;
- <b>drawWaypoint:</b></td><td>
NOT FUNCTIONAL</td></tr>
</table>
<a id="Setup"><h2>Setup</h2></a>
Before using XPC Functions you must
1. Install X-Plane (http://www.x-plane.com)
2. Copy the file xpcPlugin.xpl to the "[X-Plane Directory]/Resources/plugins" directory.
a. For Mac xpcPlugin can be found in the "[XPlaneConnect]/xpcPlugin/Mac" directory.
a. For Windows xpcPlugin can be found in the "[XPlaneConnect]/xpcPlugin/Win" directory.
3. Insert X-Plane CD 1 or X-Plane USB Key.
4. Start X-Plane.
5. import XPlaneConnect.*
<a id="Example"><h2>Examples</h2></a>
<h3>Files</h3>
TO BE ADDED
<h3>Description</h3>
<a id="Future"><h2>Future Work</h2></a>
<ul>
<li> </li>
</ul>
<a id="Notice"><h2>Notices and Disclaimers</h2></a>
<b>Notices:</b><br />
Copyright ©2013-2014 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. All Rights Reserved.<br />
<br/><b>Disclaimers:</b>
<p><b>No Warranty:</b> THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE. FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT "AS IS."</p>
<p><b>Waiver and Indemnity:</b> RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT.</p>
<br /><b>X-Plane API</b><br/>
Copyright (c) 2008, Sandy Barbour and Ben Supnik All rights reserved.<br/>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
<ul>
<li>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</li>
<li>Neither the names of the authors nor that of X-Plane or Laminar Research may be used to endorse or promote products derived from this software without specific prior written permission from the authors or Laminar Research, respectively.</li>
</ul>
<p>X-Plane API SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
</body>
</html>

View File

@@ -1,37 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-ClearUDPBuffer</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>clearUDPBuffer</h1>
Script that clears an UDP Socket Buffer
<h2>Inputs</h2>
<ul>
<li><b>Socket:</b> UDP Socket to be cleared</li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>Socket:</b> UDP Socket</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.*;<br />
2. Socket = openUDP(49005); <br />
3. Socket = clearUDPBuffer(Socket);<br />
<h2>Change Log</h2>
10/02/14: [CT] V0.9: Updated to work with updated xpcPlugin<br />
09/12/13: [CT] Add optional arguments<br />
09/10/13: [CT] Code created<br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -1,36 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-closeUDP</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>closeUDP</h1>
Script that closes a UDP Socket
<h2>Inputs</h2>
<ul>
<li><b>Socket:</b> UDP Socket to be closed</li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>Status:</b> Integer indicating the success of socket closing. 1 = Success 0 = Failure</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.*; <br />
2. Socket = openUDP(49005); <br />
3. Status = closeUDP(Socket);<br />
<h2>Change Log</h2>
10/02/14: [CT] V0.9: Updated to work with updated xpcPlugin<br />
09/10/13: [CT] Code created<br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -1,39 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-openUDP</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>openUDP</h1>
Script that opens a UDP Socket
<h2>Inputs</h2>
<ul>
<li><b>port:</b> UDP Port for socket</li>
<li><b>timeout (optional):</b> Optional parameter for time to UDP timeout (in ms)-Default 0.1 seconds</li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>Socket:</b> UDP Socket</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.*;<br />
2. Socket = openUDP(49005);%Open socket at port 49005 with timeout of 0.1 seconds <br /><br />
or<br/><br/>
2. Socket = openUDP(49005,200);%Open socket at port 49005 with timeout of 0.2 seconds<br /><br />
<h2>Change Log</h2>
10/02/14: [CT] V0.9: Updated to work with updated xpcPlugin<br />
09/12/13: [CT] Added optional timeout input argument<br />
09/10/13: [CT] Code created<br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -1,36 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-pauseSim</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>pauseSim</h1>
<h2>Inputs</h2>
<ul>
<li><b>Pause:</b> binary value 0=run, 1=pause</li>
<li><b>IP Address (optional):</b> IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)</li>
<li><b>port (optional):</b> Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin and 49005 to send to the x-plane udp </li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>status:</b> If there was an error. status<0 means there was an error.</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.*;<br />
2. status = pauseSim(1);<br />
<h2>Change Log</h2>
10/02/14: [CT] V0.9: Updated to work with updated xpcPlugin<br />
06/10/13: [CT] Code created<br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -1,59 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-readDATA</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>readDATA</h1>
Reads UDP Socket and interprets data
<h2>Inputs</h2>
<ul>
<li><b>location:</b> Either an opened UDP Socket or integer port number</li>
</ul>
<h2>Outputs</h2>
If data is X-Plane data format:
<ul>
<li><b>data:</b> Matlab X-Plane DATA Structure<ul>
<li>.h: Header array containing header numbers corresponding to values in the X-Plane UDP Data screen. </li>
<li>.d: 2-D Data array. Each row contains eight values corresponding to the header value (.h(1) corresponds to .d(1,:))</li>
<li>.raw: raw UDP data array received by readUDP</li></ul></li>
</ul>
If data is matlab structure:
<ul>
<li><b>data:</b> Matlab Structure. Raw udp data saved to data.raw</li>
</ul>
If data is any other format:
<ul>
<li><b>data:</b> Matlab Structure containing one field <ul>
<li>.raw & .d: raw UDP data array received by readUDP</li></ul></li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.*;<br />
2. socket = openUDP(49005); <br />
3. data = readDATA(socket); <br />
4. status = closeUDP(socket); <br /><br />
or <br /> <br />
1. import XPlaneConnect.*;<br />
2. data = readDATA(49005);
<h2>Note</h2>
NOTE: sending in a port number instead of an opened socket clears the UDP buffer. This only works if the data is being sent at a fast rate. Sending in a UDP Socket reads the first packet in the buffer. <br />
<h2>Change Log</h2>
10/02/14: [CT] V0.9: Updated to work with updated xpcPlugin<br />
09/10/13: [CT] Updated to receive UDP socket or port number<br />
06/10/13: [CT] Code created<br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -1,43 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-readUDP</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>readUDP</h1>
Read Array from UDP Socket
<h2>Inputs</h2>
<ul>
<li><b>location:</b> Either an opened UDP Socket or integer port number</li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>data:</b> UDP uint8 Array. Equal to -998 in the case of an error.</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.*;<br />
2. socket = openUDP(49005); <br />
3. data = readUDP(socket); <br />
4. status = closeUDP(socket); <br /><br />
or <br /> <br />
1. import XPlaneConnect.*;<br />
2. data = readUDP(49005); <br />
<h2>Note</h2>
NOTE: sending in a port number instead of an opened socket clears the UDP buffer. This only works if the data is being sent at a fast rate. Sending in a UDP Socket reads the first packet in the buffer.
<h2>Change Log</h2>
10/02/14: [CT] V0.9: Updated to work with updated xpcPlugin<br />
09/08/13: [CT] Added option for either UDP Socket or port number input <br/>
06/10/13: [CT] Code created<br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />

View File

@@ -1,37 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-requestDREF</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>requestDREF</h1>
<h2>Inputs</h2>
<ul>
<li><b>DREFArray:</b> Cell Array of DataRefs to be requested</li>
<li><b>IP Address (optional):</b> IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)</li>
<li><b>port (optional):</b> Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin </li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>status:</b> If there was an error. status<0 means there was an error.</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.*; <br />
2. DREFArray = {'sim/cockpit2/controls/yoke_heading_ratio','sim/cockpit2/controls/yoke_roll_ratio'}; <br />
3. status = requestDREF( DREFArray, '172.0.100.54' );<br />
<h2>Change Log</h2>
10/02/14: [CT] V0.9: Updated to work with updated xpcPlugin<br />
06/10/13: [CT] Code created<br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -1,39 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-selectDATA</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>selectDATA</h1>
Choose specific X-Plane parameters to be send over UDP
<h2>Inputs</h2>
<ul>
<li><b>index:</b> An array of the values that to be sent. Corresponds to the numbers on the XPlane Output screen (ACTUAL NAME?)</li>
<li><b>IP Address (optional):</b> IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)</li>
<li><b>port (optional):</b> Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin and 49005 to send to the x-plane udp </li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>status:</b> If there was an error. Status<0 means there was an error.</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.*;<br />
2. values = [1, 2, 3, 27, 40];
3. status = selectDATA(values,'127.0.0.1',49005);<br />
<h2>Change Log</h2>
10/02/14: [CT] V0.9: Updated to work with updated xpcPlugin<br />
04/18/14: [CT] V0.2: Added Versioning<br />
06/10/13: [CT] Code created<br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -1,48 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-sendCTRL</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>sendCTRL</h1>
Send position and orientation update command to X-Plane over UDP. This requires the X-Plane Connect Plugin to be running
<h2>Inputs</h2>
<ul>
<li><b>ctrl:</b> Array of 6 values where:
<ul>
<li>ctrl(1) Latitudinal Stick [-1,1] </li>
<li>ctrl(2) Longitudinal Stick [-1,1] </li>
<li>ctrl(3) Pedal [-1, 1] </li>
<li>ctrl(4) Throttle [-1, 1] </li>
<li>ctrl(5) Gear (0=up, 1=down) </li>
<li>ctrl(6) Flaps [0, 1] </li>
</ul>
<li><b>aircraft number (optional):</b> 0=own aircraft</li>
<li><b>IP Address (optional):</b> IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)</li>
<li><b>port (optional):</b> Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin and 49005 to send to the x-plane udp </li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>status:</b> If there was an error. status<0 means there was an error.</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.*;<br />
2. ctrl = [0, 0, 0, 0.8, 0, 0];
3. status = sendCTRL(ctrl); % Set position of own aircraft<br />
4. status2 = sendCTRL(ctrl,1); % Set position of aircraft 1<br />
<h2>Change Log</h2>
10/02/14: [CT] V0.9 Updated to use new xpcPlugin<br />
09/26/14: [CT] Code created<br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -1,46 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-sendDATA</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation%20(MATLAB).html"><-- Back</a><br />
<h1>sendDATA</h1>
Send X-Plane formatted DATA over UDP. This function is used to change one of the parameters listed in the x-plane udp data screen (see http://www.nuclearprojects.com/xplane/images/xp_datainout.jpg)
<h2>Inputs</h2>
<ul>
<li><b>data:</b> X-Plane formatted data. Is a matlab structure with the following fields:
<ul>
<li>.h: Header array containing header numbers corresponding to values in the X-Plane UDP Data screen. </li>
<li>.d: 2-D Data array. Each row contains eight values corresponding to the header value (.h(1) corresponds to .d(1,:))</li>
</ul></li>
<li><b>IP Address (optional):</b> IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)</li>
<li><b>port (optional):</b> Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin and 49005 to send to the x-plane udp </li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>status:</b> If there was an error. Status=1 means there was an error.</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.*;<br />
2. data = struct('h',14,'d',[1,-998,-998,-998,-998,-998,-998,-998]); %Set Gear<br />
3. %Send the data array to port 49005 on the computer at IP address 172.0.100.54.<br />
4. status = sendDATA(data, '172.0.100.54', 49005);
<h2>note</h2>
Note: send the value -998 to not overwrite that parameter. That is, if -998 is sent, the parameter will stay at the current X-Plane value<br />
<h2>Change Log</h2>
10/01/14: [CT] V0.9: updated to function with new xpcPlugin<br />
06/10/13: [CT] First created<br /><br />
<a href="../Documentation%20(MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -1,48 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-sendCTRL</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>sendCTRL</h1>
Send position and orientation update command to X-Plane over UDP. This requires the X-Plane Connect Plugin to be running
<h2>Inputs</h2>
<ul>
<ul>
<li>data(1) Latitudinal Stick [-1,1] </li>
<li>data(2) Longitudinal Stick [-1,1] </li>
<li>data(3) Pedal [-1, 1] </li>
<li>data(4) Throttle [-1, 1] </li>
<li>data(5) Gear (0=up, 1=down) </li>
<li>data(6) Flaps [0, 1] </li>
</ul>
<li><b>aircraft number (optional):</b> 0=own aircraft</li>
<li><b>IP Address (optional):</b> IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)</li>
<li><b>port (optional):</b> Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin and 49005 to send to the x-plane udp </li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>status:</b> If there was an error. status<0 means there was an error.</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.* <br />
2. dataRef = 'sim/aircraft/parts/acf_gear_deploy'; // Landing Gear <br />
3. Value = 0; <br />
4. status = sendDREF(dataRef, Value); <br />
<h2>Change Log</h2>
10/02/14: [CT] V0.9: Updated to use new xpcPlugin
06/10/13: [CT] Code created<br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -1,50 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-sendDREF</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>sendPosition</h1>
Send position and orientation update command to X-Plane over UDP. This requires the X-Plane Connect Plugin to be running
<h2>Inputs</h2>
<ul>
<li><b>data:</b> Array of 6 values where:
<ul>
<li>data(1) is the aircraft's Latitude (degrees) </li>
<li>data(2) is the aircraft's Longitude (degrees) </li>
<li>data(3) is the aircraft's altitude (meters above sea level)</li>
<li>data(4) is the aircraft's roll angle (degrees)</li>
<li>data(5) is the aircraft's pitch angle (degrees)</li>
<li>data(6) is the aircraft's heading/yaw angle (degrees)</li>
</ul>
<li><b>aircraft number (optional):</b> 0=own aircraft</li>
<li><b>IP Address (optional):</b> IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)</li>
<li><b>port (optional):</b> Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin and 49005 to send to the x-plane udp </li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>status:</b> If there was an error. status<0 means there was an error.</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.*;<br />
2. latlon = [37.4185718,-121.935565]; %Lat,lon of NASA Ames Research Center<br />
3. alt = 500; %meters above sea level<br />
4. orient = [0,20,180]; %Orientation (roll,pitch,yaw/heading). 20 degrees yaw, heading south<br />
5. status = sendPOSI([latlon,alt,orient]); % Set position of own aircraft<br />
6. status2 = sendPOSI([[latlon(1)+0.005,latlon(2)],alt,orient],1); % Set position of aircraft 1<br />
<h2>Change Log</h2>
10/02/14: [CT] V0.9 Updated to use new xpcPlugin<br />
06/10/13: [CT] Code created<br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -1,39 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-sendSTRU</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>sendSTRU</h1>
Send a MATLAB structure over UDP
<h2>Inputs</h2>
<ul>
<li><b>stru:</b> A MATLAB structure</li>
<li><b>IP Address (optional):</b> IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)</li>
<li><b>port (optional):</b> Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin </li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>status:</b> If there was an error. Status<0 means there was an error.</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.*;<br />
2. data = struct('a',[1:20],'b',1.853,'name','Example Structure');<br />
3. #Send the data structure to port 49005 on the computer at IP address 172.0.100.54<br />
4. status = sendSTRU( data, '172.0.100.54', 49005 ); <br />
<h2>Change Log</h2>
10/02/14: [CT] V0.9: Updated to work with updated xpcPlugin<br />
08/01/13: [CT] Code created<br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -1,39 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-sendUDP</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>sendUDP</h1>
Send an one dimensional array of type uint8 data over an UDP connection
<h2>Inputs</h2>
<ul>
<li><b>data:</b> 1-D array of type uint8 data to be sent</li>
<li><b>IP Address (optional):</b> IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)</li>
<li><b>port (optional):</b> Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin and 49005 to send to the x-plane udp </li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>status:</b> If there was an error. Status=1 means there was an error.</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.*;<br />
2. data = uint8([1:20]);<br />
3. #Send the data array to port 49005 on the computer at IP address 172.0.100.54.<br />
4. status = sendUDP( data, '172.0.100.54', 49005 ); <br />
<h2>Change Log</h2>
10/02/14: [CT] V0.9: Updated to work with updated xpcPlugin<br />
06/10/13: [CT] Code created <br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -1,37 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>XPlaneConnect Toolbox-setConn</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138.51">
</head>
<body>
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
<h1>setConn</h1>
Send a command to set up the port where you will receive data on this computer.
<h2>Inputs</h2>
<ul>
<li><b>Receiving Port:</b> Port that data will be sent to in the future for this connection</li>
<li><b>IP Address (optional):</b> IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)</li>
<li><b>port (optional):</b> Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin and 49005 to send to the x-plane udp </li>
</ul>
<h2>Outputs</h2>
<ul>
<li><b>status:</b> If there was an error. status<0 means there was an error.</li>
</ul>
<h2>Use</h2>
1. import XPlaneConnect.* <br />
2. status = setConn(49011); <br />
<h2>Change Log</h2>
10/02/14: [CT] V0.9: Updated to work with updated xpcPlugin<br />
04/21/14: [CT] V0.2: First Version<br /><br />
<a href="../Documentation (MATLAB).html"><-- Back</a><br />
</body>
</html>

View File

@@ -150,7 +150,7 @@ int sendDREFTest() // sendDREF test
} }
// Execution // Execution
setDREF(sock, drefs[0], &value, 1); sendDREF(sock, drefs[0], &value, 1);
int result = getDREFs(sock, drefs, data, 1, sizes); int result = getDREFs(sock, drefs, data, 1, sizes);
// Close // Close
@@ -180,9 +180,9 @@ int sendDATATest() // sendDATA test
{ {
"sim/aircraft/parts/acf_gear_deploy" "sim/aircraft/parts/acf_gear_deploy"
}; };
float* data[100]; float* data[100]; // array for result of getDREFs
int sizes[100]; int sizes[100];
float DATA[4][9]; float DATA[4][9]; // Array for sendDATA
XPCSocket sock = openUDP("127.0.0.1", 49009, 49066); XPCSocket sock = openUDP("127.0.0.1", 49009, 49066);
// Setup // Setup
@@ -198,9 +198,9 @@ int sendDATATest() // sendDATA test
data[i][j] = -998; data[i][j] = -998;
} }
} }
data[0][0] = 14; // Gear DATA[0][0] = 14; // Gear
data[0][1] = 1; DATA[0][1] = 1;
data[0][2] = 0; DATA[0][2] = 0;
// Execution // Execution
sendDATA(sock, DATA, 1); sendDATA(sock, DATA, 1);

View File

@@ -308,7 +308,7 @@ public class XPlaneConnectTest
float gearHandle = xpc.getDREF(dref)[0]; float gearHandle = xpc.getDREF(dref)[0];
float value = gearHandle > 0.5 ? 0 : 1; float value = gearHandle > 0.5 ? 0 : 1;
xpc.setDREF(dref, value); xpc.sendDREF(dref, value);
float result = xpc.getDREF(dref)[0]; float result = xpc.getDREF(dref)[0];
assertEquals(value, result, 1e-4); assertEquals(value, result, 1e-4);
@@ -320,7 +320,7 @@ public class XPlaneConnectTest
{ {
try(XPlaneConnect xpc = new XPlaneConnect()) try(XPlaneConnect xpc = new XPlaneConnect())
{ {
xpc.setDREF(null, 0); xpc.sendDREF(null, 0);
fail(); fail();
} }
} }
@@ -332,7 +332,7 @@ public class XPlaneConnectTest
try(XPlaneConnect xpc = new XPlaneConnect()) try(XPlaneConnect xpc = new XPlaneConnect())
{ {
xpc.setDREF(dref, null); xpc.sendDREF(dref, null);
fail(); fail();
} }
} }
@@ -343,7 +343,7 @@ public class XPlaneConnectTest
String dref = "sim/cockpit/switches/gear_handle_status"; String dref = "sim/cockpit/switches/gear_handle_status";
try(XPlaneConnect xpc = new XPlaneConnect()) try(XPlaneConnect xpc = new XPlaneConnect())
{ {
xpc.setDREF(dref, new float[0]); xpc.sendDREF(dref, new float[0]);
fail(); fail();
} }
} }
@@ -358,7 +358,7 @@ public class XPlaneConnectTest
String dref = "sim/cockpit/switches/gear_handle_status"; String dref = "sim/cockpit/switches/gear_handle_status";
try(XPlaneConnect xpc = new XPlaneConnect()) try(XPlaneConnect xpc = new XPlaneConnect())
{ {
xpc.setDREF(dref, new float[200]); xpc.sendDREF(dref, new float[200]);
} }
} }
@@ -368,7 +368,7 @@ public class XPlaneConnectTest
String dref = "sim/cockpit/switches/i/am/a/very/long/fake/dref/that/is/over/255/characters/./which/means/that/my/length/cant/be/encoded/in/the/single/byte/allocated/by/the/message/format/,/so/i/should/cause/an/exception/instead/./i/am/still/not/long/enough/./almost/there"; String dref = "sim/cockpit/switches/i/am/a/very/long/fake/dref/that/is/over/255/characters/./which/means/that/my/length/cant/be/encoded/in/the/single/byte/allocated/by/the/message/format/,/so/i/should/cause/an/exception/instead/./i/am/still/not/long/enough/./almost/there";
try(XPlaneConnect xpc = new XPlaneConnect()) try(XPlaneConnect xpc = new XPlaneConnect())
{ {
xpc.setDREF(dref, 0); xpc.sendDREF(dref, 0);
fail(); fail();
} }
} }
@@ -379,7 +379,7 @@ public class XPlaneConnectTest
String dref = ""; String dref = "";
try(XPlaneConnect xpc = new XPlaneConnect()) try(XPlaneConnect xpc = new XPlaneConnect())
{ {
xpc.setDREF(dref, 0); xpc.sendDREF(dref, 0);
fail(); fail();
} }
} }

View File

@@ -1,4 +1,4 @@
function setDREFTest( ) function sendDREFTest( )
%SENDREADTEST Summary of this function goes here %SENDREADTEST Summary of this function goes here
% Detailed explanation goes here % Detailed explanation goes here
addpath('../../MATLAB') addpath('../../MATLAB')
@@ -7,7 +7,7 @@ import XPlaneConnect.*
DREFS = {'sim/cockpit/switches/gear_handle_status'}; DREFS = {'sim/cockpit/switches/gear_handle_status'};
value = randi([0 10]); value = randi([0 10]);
setDREF(DREFS{1},value); sendDREF(DREFS{1},value);
result = getDREFs(DREFS); result = getDREFs(DREFS);
assert(isequal(length(result),1),'setDREFTest: requestDREF unsucessful-wrong number of elements returned'); assert(isequal(length(result),1),'setDREFTest: requestDREF unsucessful-wrong number of elements returned');

View File

@@ -13,7 +13,7 @@ disp(['XPC Tests-MATLAB (', os, ')']);
theTests = {{@openCloseTest, 'Open/Close Test', 0},... theTests = {{@openCloseTest, 'Open/Close Test', 0},...
{@sendTEXTTest,'TEXT Test', 0},... {@sendTEXTTest,'TEXT Test', 0},...
{@getDREFsTest,'Request DREF Test', 0},... {@getDREFsTest,'Request DREF Test', 0},...
{@setDREFTest,'Send DREF Test', 0},... {@sendDREFTest,'Send DREF Test', 0},...
{@DATATest,'DATA Test', 0},... {@DATATest,'DATA Test', 0},...
{@CTRLTest,'CTRL Test', 0},... {@CTRLTest,'CTRL Test', 0},...
{@POSITest,'POSI Test', 0},... {@POSITest,'POSI Test', 0},...

View File

@@ -25,6 +25,7 @@
namespace std namespace std
{ {
// Note: This is required for unordered_map
template <> template <>
struct hash<XPC::DREF> struct hash<XPC::DREF>
{ {
@@ -438,7 +439,7 @@ namespace XPC
#endif #endif
float gearArray[10]; float gearArray[10];
if ((gear < -8.5f && gear > 9.5f) || (gear < -997.9f && gear > -999.1f)) if ((gear < -8.5f && gear > -9.5f) || (gear < -997.9f && gear > -999.1f))
{ {
return; return;
} }

View File

@@ -136,13 +136,11 @@ namespace XPC
float py = XPLMGetDataf(planeYref); float py = XPLMGetDataf(planeYref);
float pz = XPLMGetDataf(planeZref); float pz = XPLMGetDataf(planeZref);
Waypoint* g;
LocalPoint* l;
//Convert to local //Convert to local
for (size_t i = 0; i < numWaypoints; ++i) for (size_t i = 0; i < numWaypoints; ++i)
{ {
g = &waypoints[i]; Waypoint* g = &waypoints[i];
l = &localPoints[i]; LocalPoint* l = &localPoints[i];
XPLMWorldToLocal(g->latitude, g->longitude, g->altitude, XPLMWorldToLocal(g->latitude, g->longitude, g->altitude,
&l->x, &l->y, &l->z); &l->x, &l->y, &l->z);
} }
@@ -153,7 +151,7 @@ namespace XPC
glBegin(GL_LINES); glBegin(GL_LINES);
for (size_t i = 0; i < numWaypoints; ++i) for (size_t i = 0; i < numWaypoints; ++i)
{ {
l = &localPoints[i]; LocalPoint* l = &localPoints[i];
glVertex3f((float)l->x, (float)l->y, (float)l->z); glVertex3f((float)l->x, (float)l->y, (float)l->z);
glVertex3f((float)l->x, -1000.0F, (float)l->z); glVertex3f((float)l->x, -1000.0F, (float)l->z);
} }
@@ -164,7 +162,7 @@ namespace XPC
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
for (size_t i = 0; i < numWaypoints; ++i) for (size_t i = 0; i < numWaypoints; ++i)
{ {
l = &localPoints[i]; LocalPoint* l = &localPoints[i];
glVertex3f((float)l->x, (float)l->y, (float)l->z); glVertex3f((float)l->x, (float)l->y, (float)l->z);
} }
glEnd(); glEnd();
@@ -173,7 +171,7 @@ namespace XPC
glColor3f(1.0F, 1.0F, 1.0F); glColor3f(1.0F, 1.0F, 1.0F);
for (size_t i = 0; i < numWaypoints; ++i) for (size_t i = 0; i < numWaypoints; ++i)
{ {
l = &localPoints[i]; LocalPoint* l = &localPoints[i];
float xoff = (float)l->x - px; float xoff = (float)l->x - px;
float yoff = (float)l->y - py; float yoff = (float)l->y - py;
float zoff = (float)l->z - pz; float zoff = (float)l->z - pz;
@@ -218,7 +216,7 @@ namespace XPC
//Enable drawing if necessary //Enable drawing if necessary
if (!msgEnabled) if (!msgEnabled)
{ {
XPLMRegisterDrawCallback(MessageDrawCallback, xplm_Phase_LastCockpit, 0, NULL); XPLMRegisterDrawCallback(MessageDrawCallback, xplm_Phase_Window, 0, NULL);
msgEnabled = true; msgEnabled = true;
} }
} }

View File

@@ -78,13 +78,13 @@ namespace XPC
void Log::FormatLine(const char* format, ...) void Log::FormatLine(const char* format, ...)
{ {
va_list args; va_list args;
va_start(args, format);
FILE* fd = fopen("XPCLog.txt", "a"); FILE* fd = fopen("XPCLog.txt", "a");
if (!fd) if (!fd)
{ {
return; return;
} }
va_start(args, format);
WriteTime(fd); WriteTime(fd);
vfprintf(fd, format, args); vfprintf(fd, format, args);

View File

@@ -257,7 +257,7 @@ namespace XPC
for (int i = 0; i < numCols; ++i) for (int i = 0; i < numCols; ++i)
{ {
unsigned char dataRef = (unsigned char)values[i][0]; unsigned char dataRef = (unsigned char)values[i][0];
if (dataRef > 134) if (dataRef >= 134)
{ {
#if LOG_VERBOSITY > 0 #if LOG_VERBOSITY > 0
Log::FormatLine("[DATA] ERROR: DataRef # must be between 0 - 134 (Received: %hi)", (int)dataRef); Log::FormatLine("[DATA] ERROR: DataRef # must be between 0 - 134 (Received: %hi)", (int)dataRef);

View File

@@ -162,7 +162,7 @@ namespace XPC
inet_ntop(AF_INET, &sin->sin_addr, ip, INET6_ADDRSTRLEN); inet_ntop(AF_INET, &sin->sin_addr, ip, INET6_ADDRSTRLEN);
int len = strnlen(ip, INET6_ADDRSTRLEN); int len = strnlen(ip, INET6_ADDRSTRLEN);
ip[len++] = ':'; ip[len++] = ':';
sprintf(ip + len, "%d", ntohs((*sin).sin_port)); sprintf(ip + len, "%u", ntohs((*sin).sin_port));
break; break;
} }
case AF_INET6: case AF_INET6:
@@ -171,7 +171,7 @@ namespace XPC
inet_ntop(AF_INET6, &sin->sin6_addr, ip, INET6_ADDRSTRLEN); inet_ntop(AF_INET6, &sin->sin6_addr, ip, INET6_ADDRSTRLEN);
int len = strnlen(ip, INET6_ADDRSTRLEN); int len = strnlen(ip, INET6_ADDRSTRLEN);
ip[len++] = ':'; ip[len++] = ':';
sprintf(ip + len, "%d", ntohs((*sin).sin6_port)); sprintf(ip + len, "%u", ntohs((*sin).sin6_port));
break; break;
} }
default: default:

Binary file not shown.

View File

@@ -76,35 +76,43 @@
/* End PBXFrameworksBuildPhase section */ /* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
AC4E46B809C2E0B3006B7E1B /* C Source */ = { AC4E46B809C2E0B3006B7E1B /* src */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
BE37D95E187C8B0F0033B082 /* XPCPlugin.cpp */, BE37D95E187C8B0F0033B082 /* XPCPlugin.cpp */,
BEDC620218EDF1A7005DB364 /* xplaneConnect.c */, BEDC620218EDF1A7005DB364 /* xplaneConnect.c */,
BEDC620318EDF1A7005DB364 /* xplaneConnect.h */,
BEABAD2B1AE041A3007BA7DA /* DataManager.cpp */, BEABAD2B1AE041A3007BA7DA /* DataManager.cpp */,
BEABAD2C1AE041A3007BA7DA /* DataManager.h */,
BEABAD2D1AE041A3007BA7DA /* DataMaps.cpp */, BEABAD2D1AE041A3007BA7DA /* DataMaps.cpp */,
BEABAD2E1AE041A3007BA7DA /* DataMaps.h */,
BEABAD2F1AE041A3007BA7DA /* Drawing.cpp */, BEABAD2F1AE041A3007BA7DA /* Drawing.cpp */,
BEABAD301AE041A3007BA7DA /* Drawing.h */,
BEABAD311AE041A3007BA7DA /* Log.cpp */, BEABAD311AE041A3007BA7DA /* Log.cpp */,
BEABAD321AE041A3007BA7DA /* Log.h */,
BEABAD331AE041A3007BA7DA /* Message.cpp */, BEABAD331AE041A3007BA7DA /* Message.cpp */,
BEABAD341AE041A3007BA7DA /* Message.h */,
BEABAD351AE041A3007BA7DA /* MessageHandlers.cpp */, BEABAD351AE041A3007BA7DA /* MessageHandlers.cpp */,
BEABAD361AE041A3007BA7DA /* MessageHandlers.h */,
BEABAD3D1AE0498D007BA7DA /* UDPSocket.cpp */, BEABAD3D1AE0498D007BA7DA /* UDPSocket.cpp */,
);
name = src;
sourceTree = "<group>";
};
BE953E0B1AEB183400CE4A8C /* inc */ = {
isa = PBXGroup;
children = (
BEDC620318EDF1A7005DB364 /* xplaneConnect.h */,
BEABAD2C1AE041A3007BA7DA /* DataManager.h */,
BEABAD2E1AE041A3007BA7DA /* DataMaps.h */,
BEABAD301AE041A3007BA7DA /* Drawing.h */,
BEABAD321AE041A3007BA7DA /* Log.h */,
BEABAD341AE041A3007BA7DA /* Message.h */,
BEABAD361AE041A3007BA7DA /* MessageHandlers.h */,
BEABAD3E1AE0498D007BA7DA /* UDPSocket.h */, BEABAD3E1AE0498D007BA7DA /* UDPSocket.h */,
); );
name = "C Source"; name = inc;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
D607B15F09A5563000699BC3 = { D607B15F09A5563000699BC3 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D6A7BDAD16A1DEA700D1426A /* Frameworks */, D6A7BDAD16A1DEA700D1426A /* Frameworks */,
AC4E46B809C2E0B3006B7E1B /* C Source */, AC4E46B809C2E0B3006B7E1B /* src */,
BE953E0B1AEB183400CE4A8C /* inc */,
D607B19A09A556E400699BC3 /* Products */, D607B19A09A556E400699BC3 /* Products */,
); );
sourceTree = "<group>"; sourceTree = "<group>";