Initial Version

This commit is contained in:
Chris Teubert
2014-10-22 15:52:38 -07:00
parent 2f13ce38bd
commit 8013ce1003
153 changed files with 22812 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
function socket = clearUDPBuffer(socket,varargin)
% clearUDPBuffer Script that clears an UDP Socket Buffer by closing and
% reopening the socket
% Version 0.25
%
% Inputs
% Socket: UDP Socket to be cleared
%
% Outputs
% Socket: UDP Socket
%
% Use
% 1. import XPlaneConnect.*;
% 2. Socket = openUDP(49005);
% 3. Socket = clearUDPBuffer(Socket);
%
% Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 04/18/14: [CT] Added Versioning
% 09/12/13: [CT] Add optional arguments
% 09/10/13: [CT] Code created
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
% 1. Verify Input
%
% BEGIN CODE
import XPlaneConnect.*
%% Close and reopen socket
if ~socket.isClosed()
port = socket.getLocalPort(); %get port of socket
socket.close; %Close Socket
socket = openUDP(port,varargin); %open new socket
end
end

View File

@@ -0,0 +1,32 @@
function [socket] = closeUDP(socket)
% closeUDP Script that closes a UDP Socket
% Version 0.25
%
% Inputs
% Socket: UDP Socket to be closed
%
% Outputs
% Socket: Closed Socket
%
% Use
% 1. import XPlaneConnect.*;
% 2. Socket = openUDP(49005);
% 3. Status = closeUDP(Socket);
%
% Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 04/18/14: [CT] V0.2: Added Versioning
% 09/10/13: [CT] Code created
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
% 1. Verify Input
%
% BEGIN CODE
socket.close;
end

View File

@@ -0,0 +1,46 @@
function [socket] = openUDP(port, varargin)
%openUDP Script that opens an UDP Socket
% Version 0.25
%
%Inputs
% port: UDP Port for socket
% timeout (optional): Optional parameter for time to UDP timeout (in ms)
%Outputs
% Socket: UDP Socket
%
% Use
% 1. import XPlaneConnect.*;
% 2. Socket = openUDP(49005); %Open socket at port 49005 with timeout=0.1 sec
% or
% 2. Socket = openUDP(49005); %Open socket at port 49005 with timeout=0.2 sec
%
%Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 04/18/14: [CT] Added Versioning
% 09/12/13: [CT] Added optional timeout input argument
% 09/10/13: [CT] Code created
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
% 1. Verify Input
%
% BEGIN CODE
import java.net.DatagramSocket
%% create socket
socket = DatagramSocket(port);
socket.setSoTimeout(100);
socket.setReceiveBufferSize(2000);
%% interpret input
if ~isempty(varargin)
if isnumeric(varargin(1))
socket.setSoTimeout(varargin(1));
end
end
end

View File

@@ -0,0 +1,50 @@
function status = pauseSim( pause, varargin )
%pauseSim pause Simulation
% Version 0.25
%
%Inputs
% Pause: binary value 0=run, 1=pause
% IP Address (optional): IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)
% port (optional): Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin
%
%Outputs
% status: If there was an error. Status<0 means there was an error.
%
%Use
% 1. import XPlaneConnect.*;
% 2. status = pauseSim(1);
%
%Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 04/19/14: [CT] V0.2: First Created
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
% 1. Verify Input
%
%BEGIN CODE
import XPlaneConnect.*
%% Handle Input
% Optional parameters
p = inputParser;
addRequired(p,'pause',@isnumeric);
addOptional(p,'IP','127.0.0.1',@ischar);
addOptional(p,'port',49009,@isnumeric);
parse(p,pause,varargin{:});
% Check format of input-TODO
%% BODY
message = zeros(1,7);
message(1:4) = 'SIMU'-0;
message(6) = uint8(p.Results.pause);
message(7) = 0;
status = sendUDP(message, p.Results.IP, p.Results.port);
end

View File

@@ -0,0 +1,98 @@
function [ sensor ] = readDATA( socket )
% readDATA Reads UDP Socket and interprets data
% Version 0.25
%
% Inputs
% location: Either an opened UDP Socket or integer port number
%
% Outputs
% If data is X-Plane data format:
% data: Matlab X-Plane DATA Structure
% .h: Header array containing header numbers corresponding to values in the X-Plane UDP Data screen.
% .d: 2-D Data array. Each row contains eight values corresponding to the header value (.h(1) corresponds to .d(1,:))
% .raw: raw UDP data array received by readUDP
%
% If data is matlab structure:
% data: Matlab Structure. raw UDP data saved to data.raw
%
% If data is any other format:
% data: Matlab Structure containing one field
% .raw & .d: raw UDP data array received by readUDP
%
% Use
% 1. import XPlaneConnect.*;
% 2. socket = openUDP(49005);
% 3. data = readDATA(socket);
% 4. status = closeUDP(socket);
% or
% 1. import XPlaneConnect.*;
% 2. data = readDATA(49005);
%
% 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.
%
% Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 04/18/14: [CT] V0.2: Updated to work with new Plugin
% 09/10/13: [CT] Updated to receive UDP socket or port number
% 06/10/13: [CT] Code created
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
% 1. Verify Input
%
% BEGIN CODE
import XPlaneConnect.*
%% Read UDP Socket
[ sensor.raw] = readUDP(socket);
%% Interpret Input
bits = size(sensor.raw);
if sensor.raw ~= -998 %If the signal exists
header = char(sensor.raw(1:4)');
if strcmp(header,'DATA') %DATA signal type
Values = floor((bits-5)/36);
sensor.d = [];
sensor.h = zeros(Values(1),1);
for i=1:Values(1)
sensor.h(i) = sensor.raw(6+(i-1)*36);
sensor.d = [sensor.d; typecast(uint8(sensor.raw(10+(i-1)*36:5+i*36))','single')];
end
elseif strcmp(header,'STRU') %STRU signal type
a = 6;
while a<length(sensor.raw)
strdim = sensor.raw(a);
if strdim == 0
break
end
fieldName = char(sensor.raw(a+1:a+strdim)');
a = a+strdim+1;
dim1 = sensor.raw(a);
dim2 = sensor.raw(a+1);
if dim1 == 0 %String
value = char(sensor.raw(a+2:a+1+dim2));
a = a + dim2 + 2;
else
value = [];
for i=1:dim1
value(i,:) = typecast(uint8(sensor.raw(a+2+(i-1)*dim2*4:a+1+i*dim2*4))','single');
end
a = a + dim1*dim2*4+2;
end
sensor.(fieldName) = value;
end
elseif strcmp(header,'OTHR')
sensor.d = sensor.raw(6:end);
else %Other signal type
sensor.d = sensor.raw;
end
else %No Signal
sensor.d = -998;
end
end

View File

@@ -0,0 +1,79 @@
function [ data ] = readUDP( input )
%readUDP Read Array from UDP Socket
% Version 0.25
%
% Inputs
% input: Either an opened UDP Socket or integer port number
%
% Outputs
% data: UDP uint8 Array. Equal to -998 in the case of an error
%
% Use
% 1. import XPlaneConnect.*;
% 2. socket = openUDP(49005);
% 3. data = readUDP(socket);
% 4. status = closeUDP(socket);
%
% or
%
% 1. import XPlaneConnect.*;
% 2. data = readUDP(49005);
%
% 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.
%
% Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 04/18/14: [CT] V0.2: Added Versioning
% 09/08/13: [CT] Added option for either UDP Socket or port number input
% 06/10/13: [CT] Code created
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
% 1. Verify Input
%
% BEGIN CODE
import XPlaneConnect.*
import java.net.DatagramPacket
bits = 2000;
%% Interpret Input
socket = input;
if isnumeric(input)
socket=openUDP(input);
end
%% Try reading packet
try
packet = DatagramPacket(zeros(1,bits,'int8'),bits);
socket.receive(packet)
data = packet.getData;
data = int16(data);
data(data(:)<0) = uint8(data(data(:)<0) + 256); %fix signed issue
size = int16(data(5)); %size of data stream
%% trim trailing data
for i=1:floor(length(data)/256)+1
if data(size+1:end)==0
break
end
size = size + 256;
end
data = data(1:size);
catch err %Read Unsuccessful
data = -998;
end
%% Close Port (if opened in code)
if isnumeric(input)
socket.close()
end
end

View File

@@ -0,0 +1,59 @@
function status = requestDREF( DREFArray, varargin )
%requestDREF request the value of a specific DataRef from X-Plane over UDP
% Version 0.25
%
%Inputs
% DREFArray: Cell Array of DataRefs to be requested
% IP Address (optional): IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)
% port (optional): Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin
%
%Outputs
% status: If there was an error. Status<0 means there was an error.
%
%Use
% 1. import XPlaneConnect.*;
% 2. DREFArray = {'sim/cockpit2/controls/yoke_heading_ratio','sim/cockpit2/controls/yoke_roll_ratio'};
% 3. status = requestDREF( DREFArray, '172.0.100.54' );
%
%Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 04/19/14: [CT] V0.2: First Created
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
% 1. Complete- Receive response
%
%BEGIN CODE
disp('This Function is not functional yet-use the C version. Sorry for any inconvenience')
import XPlaneConnect.*
message = zeros(1,6);
len = 7;
%% Handle Input
p = inputParser;
addRequired(p,'DREFArray');
addOptional(p,'IP','127.0.0.1',@ischar);
addOptional(p,'port',49009,@isnumeric);
parse(p,DREFArray,varargin{:});
%% BODY
% Header
message(1:4) = 'GETD'-0;
message(6) = length(p.Results.DREFArray);
% DREFS
for i=1:length(p.Results.DREFArray)
message(len) = length(p.Results.DREFArray{i});
message(len+1:len+message(len)) = p.Results.DREFArray{i};
len = len+1+message(len);
end
% Send UDP
status = sendUDP(message, p.Results.IP, p.Results.port);
end

View File

@@ -0,0 +1,49 @@
function [ status ] = selectDATA( index, varargin )
% selectDATA Choose specific X-Plane parameters to be send over UDP
% Version 0.25
%
% Inputs
% index: An array of the values that to be sent. Corresponds to the numbers on the XPlane Output screen
% IP Address (optional): IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)
% port (optional): 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
%
% Outputs
% status: If there was an error. Status<0 means there was an error.
%
% Use
% 1. import XPlaneConnect.*;
% 2. values = [1, 2, 3, 27, 40];
% 3. status = selectDATA( values, '127.0.0.1', 49005 ); % send to localhose port 49005
%
% Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 04/18/14: [CT] V0.2: Added Versioning
% 06/10/13: [CT] Code created
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
% 1. Verify Input
%
% BEGIN CODE
import XPlaneConnect.*
%% Handle Input
p = inputParser;
addRequired(p,'index');
addOptional(p,'IP','127.0.0.1',@ischar);
addOptional(p,'port',49009,@isnumeric);
parse(p,index,varargin{:});
%% BODY
dataString = ['DSEL'-0,0];
for i=1:length(index)
dataString = [dataString, p.Results.index(i), 0, 0, 0];
end
status = sendUDP(dataStream, p.Results.IP, p.Results.port);
end

View File

@@ -0,0 +1,66 @@
function [ status ] = sendCTRL( ctrl, acft, IP, port )
% sendCTRL Send X-Plane Aircraft Control Commands over UDP
% Version 0.25
%
% Inputs
% ctrl: control array where the elements are as follows:
% 1. Latitudinal Stick [-1,1]
% 2. Longitudinal Stick [-1,1]
% 3. Pedal [-1, 1]
% 4. Throttle [-1, 1]
% 5. Gear (0=up, 1=down)
% 6. Flaps [0, 1]
% acft (optional): Aircraft # (default is 0; 0 = own aircraft)
% IP Address (optional): IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)
% port (optional): 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
%
% Outputs
% status: If there was an error. Status<0 means there was an error.
%
% Use
% 1. import XPlaneConnect.*;
% 2. #Send the data array to port 49009 on the computer at IP address 172.0.100.54.
% 3. status = sendCTRL([0, 0, 0, 0.8, 0, 1], 1, '172.0.100.54',49009);
%
% 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
%
% Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 09/26/14: [CT] Code created
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
% 1. Verify Input
%
% BEGIN CODE
import XPlaneConnect.*
%% Handle Input
% Optional parameters
if ~exist('IP','var'), IP = "127.0.0.1"; end
if ~exist('port','var'), port = 49009; end
if ~exist('acft','var'), acft = 0; end
% Check format of input-TODO
%%BODY
header = ['CTRL'-0,0];
dataStream = [header, acft];
% Deal with position update
control = [0, 0, 0, 0.8, 0, 1];
for i=1:min(length(ctrl),length(control))
control(i) = ctrl(i);
end
dataStream = [dataStream, typecast(single(control),'uint8')];
% Send DATA
status = sendUDP(IP, port, dataStream);
end

View File

@@ -0,0 +1,63 @@
function [ status ] = sendDATA(data, varargin)
% sendDATA Send X-Plane formatted DATA over UDP
% Version 0.25
%
% Inputs
% data: X-Plane formatted data. Is a matlab structure with the following fields:
% .h: Header array containing header numbers corresponding to values in the X-Plane UDP Data screen.
% .d: 2-D Data array. Each row contains eight values corresponding to the header value (.h(1) corresponds to .d(1,:))
% IP Address (optional): IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)
% port (optional): 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 interface.
%
% Outputs
% status: 0: no error, <0: error
%
% Use
% 1. import XPlaneConnect.*;
% 2. data = struct('h',27,'d',[1,-998,-998,-998,-998,-998,-998,-998]);
% 3. %Send the data array to port 49005 on the computer at IP address 172.0.100.54.
% 4. status = sendDATA(data, '172.0.100.54', 49005);
%
% 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
%
% Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 04/18/14: [CT] V0.2: Updated to work with new Plugin
% 06/10/13: [CT] Code created
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
%
% BEGIN CODE
import XPlaneConnect.*
%% Handle Input
p = inputParser;
addRequired(p,'data');
addOptional(p,'IP','127.0.0.1',@ischar);
addOptional(p,'port',49009,@isnumeric);
parse(p,data,varargin{:});
%% BODY
header = ['DATA'-0,0];
dataStream = header;
for i=1:length(p.Results.data.h)
dataStream = [dataStream, p.Results.data.h(i), 0, 0, 0, typecast(single(p.Results.data.d(i,1:8)),'uint8')]; %#ok<AGROW>
end
% Send DATA
if length(dataStream) > 5
status = sendUDP(dataStream, p.Results.IP, p.Results.port);
else
disp('Warning in sendDATA: Sending empty dataStream')
status = -2;
end
end

View File

@@ -0,0 +1,63 @@
function status = sendDREF( dataRef, Value, varargin )
% sendDREF Send a command to change any DataRef in X-Plane over UDP. This requires the X-Plane Connect Plugin to be running
% Version 0.25
%
% Inputs
% dataRef: The X-Plane Dataref that will be chaged
% Value: The value that the above dataref is set to
% IP Address (optional): IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)
% port (optional): 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
%
% Outputs
% status: If there was an error. status<0 means there was an error.
%
% Use
% 1. import XPlaneConnect.*
% 2. dataRef = 'sim/aircraft/parts/acf_gear_deploy'; // Landing Gear
% 3. Value = 0;
% 4. status = sendDREF(dataRef, Value);
%
% Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 04/18/14: [CT] V0.2: First Version
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
% 1. Verify Input
%
% BEGIN CODE
import XPlaneConnect.*
status = 0;
%% Handle Input
p = inputParser;
addRequired(p,'dataRef');
addRequired(p,'Value');
addOptional(p,'IP','127.0.0.1',@ischar);
addOptional(p,'port',49009,@isnumeric);
parse(p,dataRef, Value ,varargin{:});
%% BODY
dataStream = zeros(1,7+length(p.Results.dataRef)+length(p.Results.Value)*4);
% Build Header
dataStream(1:4) = 'DREF'-0;
% Add DREF
dataStream(6) = uint8(length(p.Results.dataRef));
len = 6+length(p.Results.dataRef);
dataStream(7:len)=p.Results.dataRef-0;
% Add Value
dataStream(len+1) =uint8(length(p.Results.Value));
dataStream(len+2:end)=typecast(single(p.Results.Value),'uint8');
% Send DREF
if length(dataStream) > 5
status = sendUDP(dataStream, p.Results.IP, p.Results.port);
end
end

View File

@@ -0,0 +1,66 @@
function [ status ] = sendPOSI( posi, varargin )
% sendPOSI Send X-Plane Aircraft Position over UDP
% Version 0.25
%
% Inputs
% posi: Position array where the elements are as follows:
% 1. Latitiude (deg)
% 2. Longitude (deg)
% 3. Altitude (m above MSL)
% 4. Roll (deg)
% 5. Pitch (deg)
% 6. True Heading (deg)
% 7. Gear (0=up, 1=down)
% acft (optional): Aircraft # (default is 0; 0 = own aircraft)
% IP Address (optional): IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)
% port (optional): 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
%
% Outputs
% status: If there was an error. Status<0 means there was an error.
%
% Use
% 1. import XPlaneConnect.*;
% 2. #Send the data array to port 49009 on the computer at IP address 172.0.100.54.
% 3. status = sendPOSI([37.5242422, -122.06899, 2500, 0, 0, 0, 1], 1, '172.0.100.54');
%
% 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
%
% Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 09/25/14: [CT] Code created
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
%
% BEGIN CODE
import XPlaneConnect.*
%% Handle Input
p = inputParser;
addRequired(p,'posi');
addOptional(p,'acft',0,@isnumeric);
addOptional(p,'IP','127.0.0.1',@ischar);
addOptional(p,'port',49009,@isnumeric);
parse(p,posi,varargin{:});
%% BODY
header = ['POSI'-0,0];
dataStream = [header, p.Results.acft];
% Deal with position update
position = [37.4185718,-121.935565,500,0,0,0, 0];
for i=1:min(length(position),length(p.Results.posi))
position(i) = p.Results.posi(i);
end
dataStream = [dataStream, typecast(single(position),'uint8')];
% Send POSI
status = sendUDP(dataStream, p.Results.IP, p.Results.port);
end

View File

@@ -0,0 +1,63 @@
function [ status ] = sendSTRU( STRU, varargin )
%sendSTRU Send a MATLAB structure over UDP
% Version 0.25
%
%Inputs
% stru: A MATLAB structure
% IP Address (optional): IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)
% port (optional): Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin
%
%Outputs
% status: If there was an error. Status<0 means there was an error.
%
%Use
% 1. import XPlaneConnect.*;
% 2. data = struct('a',[1:20],'b',1.853,'name','Example Structure');
% 3. #Send the data structure to port 49005 on the computer at IP address 172.0.100.54
% 4. status = sendUDP( data, '172.0.100.54', 49005 );
%
%Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 04/18/14: [CT] V0.2: Added Versioning
% 08/01/13: [CT] Code created
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
%
%BEGIN CODE
import XPlaneConnect.*
%% Handle Input
p = inputParser;
addRequired(p,'STRU');
addOptional(p,'IP','127.0.0.1',@ischar);
addOptional(p,'port',49009,@isnumeric);
parse(p,STRU,varargin{:});
%% Form Data Array representing the structure
DATA = ['STRU'-0,0]; %array header
fieldName = fieldnames(p.Results.STRU); %all Struct fields
for i=1:length(fieldName) %for each field
field = getfield(p.Results.STRU,fieldName{i}); %get field
if ischar(field) %String
dim1 = 0; %Indicates string
dim2 = length(field); %length
data = field-0; %data
else %Numeric
dim1 = size(field,1); %Array Dim1
dim2 = size(field,2); %Array Dim2
data = typecast(single(reshape(field',1,dim1*dim2)),'uint8'); %Data
end
DATA = [DATA,length(fieldName{i}),fieldName{i}-0,dim1,dim2,data]; %add to array
end
%% Send Array
status = sendUDP(DATA, p.Results.IP, p.Results.port);
end

View File

@@ -0,0 +1,64 @@
function [ status ] = sendUDP( data, IP, port )
%sendUDP Send an one dimensional array of type uint8 data over an UDP connection using a java DatagramSocket
% Version 0.25
%
%Inputs
% Data: 1-D array of type uint8 data to be sent
% IP Address (optional): IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)
% port (optional): Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin
%
%Outputs
% status: If there was an error. Status<0 means there was an error.
%
%Use
% 1. import XPlaneConnect.*;
% 2. data = uint8([1:20]);
% 3. #Send the data array to port 49005 on the computer at IP address 172.0.100.54.
% 4. status = sendUDP( data, '172.0.100.54', 49005 );
%
%Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 09/25/14: [CT] V0.24: Added persistant socket
% 04/21/14: [CT] V0.2:Added Versioning, support for DREF/SIMU/GETD/CONN
% 06/10/13: [CT] Code created
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
% 1. Verify Input
%
%BEGIN CODE
import java.net.DatagramSocket
import java.net.DatagramPacket
import java.net.InetAddress
data(5) = length(data);
status = 0;
%% Send array
persistent socket
if isempty(socket)
try
socket = DatagramSocket;
catch err
status = 1;
disp(err)
end
end
try
IP = InetAddress.getByName(IP);
packet = DatagramPacket(data, length(data), IP, port); %create packet
socket.send(packet);
catch err
status = 1;
disp(err)
end
end

View File

@@ -0,0 +1,52 @@
function status = setConn( recvPort, IP, port )
% setConn Send a command to set up the port where you will receive data on
% this computer.
% Version 0.25
%
% Inputs
% Receiving Port: Port that data will be sent to in the future for this connection
% IP Address (optional): IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)
% port (optional): 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
%
% Outputs
% status: If there was an error. status<0 means there was an error.
%
% Use
% 1. import XPlaneConnect.*
% 2. status = setConn(49011);
%
% Change Log
% 10/02/14: [CT] V0.25: Updated to work with updated xpcPlugin
% 04/21/14: [CT] V0.2: First Version
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
% 1. Verify Input
%
% BEGIN CODE
import XPlaneConnect.*
status = 0;
message = zeros(1,9);
%% Handle Input
% Optional parameters
if ~exist('IP','var'), IP = "127.0.0.1"; end
if ~exist('port','var'), port = 49009; end
% Check format of input-TODO
%% BODY
% Header
message(1:4) = 'CONN'-0;
% RecvPort
message(6:9) = typecast(uint32(recvPort),'uint8');
% Send
sendUDP(IP,port,message);
end

View File

@@ -0,0 +1,122 @@
<!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>
Version 0.25 September 29, 2014<br />
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>
<a id="Changes"><h2>Change Log</h2></a>
-October 16, 2014 (Chris Teubert): Added Notices and Disclaimers<br />
-September 29, 2014 (Chris Teubert): Updated documentation to use new plugin</br />
-September 11, 2013 (Chris Teubert): Updated for Version 0.7<br />
-February 13, 2013 (Chris Teubert): Hello World!
</body>
</html>

View File

@@ -0,0 +1,37 @@
<!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

@@ -0,0 +1,36 @@
<!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>

39
MATLAB/pages/openUDP.html Normal file
View File

@@ -0,0 +1,39 @@
<!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

@@ -0,0 +1,36 @@
<!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

@@ -0,0 +1,59 @@
<!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>

43
MATLAB/pages/readUDP.html Normal file
View File

@@ -0,0 +1,43 @@
<!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

@@ -0,0 +1,37 @@
<!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

@@ -0,0 +1,39 @@
<!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

@@ -0,0 +1,48 @@
<!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

@@ -0,0 +1,46 @@
<!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

@@ -0,0 +1,48 @@
<!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

@@ -0,0 +1,50 @@
<!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

@@ -0,0 +1,39 @@
<!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>

39
MATLAB/pages/sendUDP.html Normal file
View File

@@ -0,0 +1,39 @@
<!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>

37
MATLAB/pages/setConn.html Normal file
View File

@@ -0,0 +1,37 @@
<!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>