Fixed errors in MATLAB client and updated tests.
This commit is contained in:
Binary file not shown.
@@ -24,14 +24,15 @@ import XPlaneConnect.*
|
|||||||
%% Get client
|
%% Get client
|
||||||
global clients;
|
global clients;
|
||||||
if ~exist('socket', 'var')
|
if ~exist('socket', 'var')
|
||||||
assert(istrue(length(clients) < 2), '[getDREFs] ERROR: Multiple clients open. You must specify which client to use.');
|
assert(isequal(length(clients) < 2, 1), '[getDREFs] ERROR: Multiple clients open. You must specify which client to use.');
|
||||||
if isempty(clients)
|
if isempty(clients)
|
||||||
openUDP();
|
socket = openUDP();
|
||||||
|
else
|
||||||
|
socket = clients(1);
|
||||||
end
|
end
|
||||||
socket = clients(1);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
%% Send command
|
%% Send command
|
||||||
result = socket.getDREF(drefs);
|
result = socket.getDREFs(drefs);
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -29,7 +29,8 @@ addOptional(p,'port',0,@isnumeric);
|
|||||||
parse(p,varargin{:});
|
parse(p,varargin{:});
|
||||||
|
|
||||||
%% Create client
|
%% Create client
|
||||||
javaaddpath('XPlaneConnect.jar');
|
[folder, ~, ~] = fileparts(which('XPlaneConnect.openUDP'));
|
||||||
|
javaaddpath([folder, '\XPlaneConnect.jar']);
|
||||||
import gov.nasa.xpc.*;
|
import gov.nasa.xpc.*;
|
||||||
socket = XPlaneConnect(p.Results.xpHost, p.Results.xpPort, p.Results.port);
|
socket = XPlaneConnect(p.Results.xpHost, p.Results.xpPort, p.Results.port);
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ import XPlaneConnect.*
|
|||||||
%% Get client
|
%% Get client
|
||||||
global clients;
|
global clients;
|
||||||
if ~exist('socket', 'var')
|
if ~exist('socket', 'var')
|
||||||
assert(istrue(length(clients) < 2), '[pauseSim] ERROR: Multiple clients open. You must specify which client to use.');
|
assert(isequal(length(clients) < 2, 1), '[pauseSim] ERROR: Multiple clients open. You must specify which client to use.');
|
||||||
if isempty(clients)
|
if isempty(clients)
|
||||||
openUDP();
|
socket = openUDP();
|
||||||
|
else
|
||||||
|
socket = clients(1);
|
||||||
end
|
end
|
||||||
socket = clients(1);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
%% Validate input
|
%% Validate input
|
||||||
|
|||||||
@@ -37,11 +37,12 @@ import XPlaneConnect.*
|
|||||||
%% Get client
|
%% Get client
|
||||||
global clients;
|
global clients;
|
||||||
if ~exist('socket', 'var')
|
if ~exist('socket', 'var')
|
||||||
assert(istrue(length(clients) < 2), '[sendDATA] ERROR: Multiple clients open. You must specify which client to use.');
|
assert(istrue(length(clients) < 2), '[readDATA] ERROR: Multiple clients open. You must specify which client to use.');
|
||||||
if isempty(clients)
|
if isempty(clients)
|
||||||
openUDP();
|
socket = openUDP();
|
||||||
|
else
|
||||||
|
socket = clients(1);
|
||||||
end
|
end
|
||||||
socket = clients(1);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
%% Get data
|
%% Get data
|
||||||
|
|||||||
@@ -19,11 +19,12 @@ import XPlaneConnect.*
|
|||||||
%% Get client
|
%% Get client
|
||||||
global clients;
|
global clients;
|
||||||
if ~exist('socket', 'var')
|
if ~exist('socket', 'var')
|
||||||
assert(istrue(length(clients) < 2), '[sendDATA] ERROR: Multiple clients open. You must specify which client to use.');
|
assert(istrue(length(clients) < 2), '[selectDATA] ERROR: Multiple clients open. You must specify which client to use.');
|
||||||
if isempty(clients)
|
if isempty(clients)
|
||||||
openUDP();
|
socket = openUDP();
|
||||||
|
else
|
||||||
|
socket = clients(1);
|
||||||
end
|
end
|
||||||
socket = clients(1);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
%% Validate input
|
%% Validate input
|
||||||
|
|||||||
@@ -32,11 +32,12 @@ import XPlaneConnect.*
|
|||||||
%% Get client
|
%% Get client
|
||||||
global clients;
|
global clients;
|
||||||
if ~exist('socket', 'var')
|
if ~exist('socket', 'var')
|
||||||
assert(istrue(length(clients) < 2), '[sendCTRL] ERROR: Multiple clients open. You must specify which client to use.');
|
assert(isequal(length(clients) < 2, 1), '[sendCTRL] ERROR: Multiple clients open. You must specify which client to use.');
|
||||||
if isempty(clients)
|
if isempty(clients)
|
||||||
openUDP();
|
socket = openUDP();
|
||||||
|
else
|
||||||
|
socket = clients(1);
|
||||||
end
|
end
|
||||||
socket = clients(1);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
%% Validate input
|
%% Validate input
|
||||||
|
|||||||
@@ -28,11 +28,12 @@ import XPlaneConnect.*
|
|||||||
%% Get client
|
%% Get client
|
||||||
global clients;
|
global clients;
|
||||||
if ~exist('socket', 'var')
|
if ~exist('socket', 'var')
|
||||||
assert(istrue(length(clients) < 2), '[sendDATA] ERROR: Multiple clients open. You must specify which client to use.');
|
assert(isequal(length(clients) < 2, 1), '[sendDATA] ERROR: Multiple clients open. You must specify which client to use.');
|
||||||
if isempty(clients)
|
if isempty(clients)
|
||||||
openUDP();
|
socket = openUDP();
|
||||||
|
else
|
||||||
|
socket = clients(1);
|
||||||
end
|
end
|
||||||
socket = clients(1);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
%% Validate input
|
%% Validate input
|
||||||
|
|||||||
@@ -31,11 +31,12 @@ import XPlaneConnect.*
|
|||||||
%% Get client
|
%% Get client
|
||||||
global clients;
|
global clients;
|
||||||
if ~exist('socket', 'var')
|
if ~exist('socket', 'var')
|
||||||
assert(istrue(length(clients) < 2), '[pauseSim] ERROR: Multiple clients open. You must specify which client to use.');
|
assert(isequal(length(clients) < 2, 1), '[sendPOSI] ERROR: Multiple clients open. You must specify which client to use.');
|
||||||
if isempty(clients)
|
if isempty(clients)
|
||||||
openUDP();
|
socket = openUDP();
|
||||||
|
else
|
||||||
|
socket = clients(1);
|
||||||
end
|
end
|
||||||
socket = clients(1);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
%% Validate input
|
%% Validate input
|
||||||
@@ -46,6 +47,6 @@ end
|
|||||||
ac = logical(ac);
|
ac = logical(ac);
|
||||||
|
|
||||||
%% Send command
|
%% Send command
|
||||||
socket.sendCTRL(ctrl, ac);
|
socket.sendPOSI(posi, ac);
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -24,11 +24,12 @@ import XPlaneConnect.*
|
|||||||
%% Get client
|
%% Get client
|
||||||
global clients;
|
global clients;
|
||||||
if ~exist('socket', 'var')
|
if ~exist('socket', 'var')
|
||||||
assert(istrue(length(clients) < 2), '[sendCTRL] ERROR: Multiple clients open. You must specify which client to use.');
|
assert(isequal(length(clients) < 2, 1), '[sendTEXT] ERROR: Multiple clients open. You must specify which client to use.');
|
||||||
if isempty(clients)
|
if isempty(clients)
|
||||||
openUDP();
|
socket = openUDP();
|
||||||
|
else
|
||||||
|
socket = clients(1);
|
||||||
end
|
end
|
||||||
socket = clients(1);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
%% Validate input
|
%% Validate input
|
||||||
|
|||||||
@@ -25,19 +25,31 @@ import XPlaneConnect.*
|
|||||||
%% Get client
|
%% Get client
|
||||||
global clients;
|
global clients;
|
||||||
if ~exist('socket', 'var')
|
if ~exist('socket', 'var')
|
||||||
assert(istrue(length(clients) < 2), '[sendCTRL] ERROR: Multiple clients open. You must specify which client to use.');
|
assert(isequal(length(clients) < 2, 1), '[sendWYPT] ERROR: Multiple clients open. You must specify which client to use.');
|
||||||
if isempty(clients)
|
if isempty(clients)
|
||||||
openUDP();
|
socket = openUDP();
|
||||||
|
else
|
||||||
|
socket = clients(1);
|
||||||
end
|
end
|
||||||
socket = clients(1);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
%% Get WaypointOp class
|
||||||
|
[folder, ~, ~] = fileparts(which('XPlaneConnect.openUDP'));
|
||||||
|
javaaddpath([folder, '\XPlaneConnect.jar']);
|
||||||
|
import gov.nasa.xpc.*;
|
||||||
|
|
||||||
%% Validate input
|
%% Validate input
|
||||||
len = uint32(length(points));
|
len = uint32(length(points));
|
||||||
assert(op > 0 && op < 4);
|
assert(op > 0 && op < 4);
|
||||||
|
wyptOp = WaypointOp.Add;
|
||||||
|
if isequal(op, 2)
|
||||||
|
wyptOp = WaypointOp.Del;
|
||||||
|
elseif isequal(op, 3)
|
||||||
|
wyptOp = WaypointOp.Clr;
|
||||||
|
end
|
||||||
assert(mod(len, 3) == 0);
|
assert(mod(len, 3) == 0);
|
||||||
|
|
||||||
%% Send command
|
%% Send command
|
||||||
socket.sendCTRL(ctrl, ac);
|
socket.sendWYPT(wyptOp, points);
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -19,11 +19,12 @@ import XPlaneConnect.*
|
|||||||
%% Get client
|
%% Get client
|
||||||
global clients;
|
global clients;
|
||||||
if ~exist('socket', 'var')
|
if ~exist('socket', 'var')
|
||||||
assert(istrue(length(clients) < 2), '[sendCTRL] ERROR: Multiple clients open. You must specify which client to use.');
|
assert(isequal(length(clients) < 2, 1), '[setCONN] ERROR: Multiple clients open. You must specify which client to use.');
|
||||||
if isempty(clients)
|
if isempty(clients)
|
||||||
openUDP();
|
socket = openUDP();
|
||||||
|
else
|
||||||
|
socket = clients(1);
|
||||||
end
|
end
|
||||||
socket = clients(1);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
%% Validate input
|
%% Validate input
|
||||||
|
|||||||
@@ -23,11 +23,12 @@ import XPlaneConnect.*
|
|||||||
%% Get client
|
%% Get client
|
||||||
global clients;
|
global clients;
|
||||||
if ~exist('socket', 'var')
|
if ~exist('socket', 'var')
|
||||||
assert(istrue(length(clients) < 2), '[setDREF] ERROR: Multiple clients open. You must specify which client to use.');
|
assert(isequal(length(clients) < 2, 1), '[setDREF] ERROR: Multiple clients open. You must specify which client to use.');
|
||||||
if isempty(clients)
|
if isempty(clients)
|
||||||
openUDP();
|
socket = openUDP();
|
||||||
|
else
|
||||||
|
socket = clients(1);
|
||||||
end
|
end
|
||||||
socket = clients(1);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
%% Validate input
|
%% Validate input
|
||||||
|
|||||||
@@ -348,14 +348,17 @@ public class XPlaneConnectTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void testSendDREF_MessageTooLong() throws IOException
|
public void testSendDREF_MessageTooLong() throws IOException
|
||||||
{
|
{
|
||||||
|
// NOTE: This test originally ensured that the client restricted messages to 255 bytes in length.
|
||||||
|
// This restriction is no longer necessary, however removing it uncovered a bug that caused
|
||||||
|
// the plugin to do a bad memcpy and crash. This test is left here to ensure that X-Plane
|
||||||
|
// does not crash when given erroneously large value arrays.
|
||||||
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.setDREF(dref, new float[200]);
|
||||||
fail();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
function CTRLTest( )
|
function CTRLTest( )
|
||||||
%CTRLTest Summary of this function goes here
|
%CTRLTest Summary of this function goes here
|
||||||
% Detailed explanation goes here
|
% Detailed explanation goes here
|
||||||
|
%% Test player aircraft
|
||||||
addpath('../../MATLAB')
|
addpath('../../MATLAB')
|
||||||
import XPlaneConnect.*
|
import XPlaneConnect.*
|
||||||
|
|
||||||
@@ -14,14 +15,15 @@ THROT = rand();
|
|||||||
CTRL = [0.0, 0.0, 1.0, THROT, 0.0, 1.0];
|
CTRL = [0.0, 0.0, 1.0, THROT, 0.0, 1.0];
|
||||||
|
|
||||||
sendCTRL(CTRL);
|
sendCTRL(CTRL);
|
||||||
result = requestDREF(DREFS);
|
result = getDREFs(DREFS);
|
||||||
|
|
||||||
assert(isequal(length(result),6),'CTRLTest: requestDREF unsucessful-wrong number of elements returned');
|
assert(isequal(length(result),6),'CTRLTest: getDREFs unsucessful-wrong number of elements returned');
|
||||||
assert(isequal(length(result{4}),8),'CTRLTest: requestDREF unsucessful- element 1 incorrect size (should be size 8)');
|
assert(isequal(length(result{4}),8),'CTRLTest: getDREFs unsucessful- element 1 incorrect size (should be size 8)');
|
||||||
for i=1:length(CTRL)-1
|
for i=1:length(CTRL)-1
|
||||||
assert(abs(result{i}(1)-CTRL(i))<1e-4,['CTRLTest: DATA set unsucessful-',num2str(i)]);
|
assert(abs(result{i}(1)-CTRL(i))<1e-4,['CTRLTest: DATA set unsucessful-',num2str(i)]);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
%% Test NPC aircraft
|
||||||
DREFS = {'sim/multiplayer/position/plane1_yolk_pitch',...
|
DREFS = {'sim/multiplayer/position/plane1_yolk_pitch',...
|
||||||
'sim/multiplayer/position/plane1_yolk_roll',...
|
'sim/multiplayer/position/plane1_yolk_roll',...
|
||||||
'sim/multiplayer/position/plane1_yolk_yaw',...
|
'sim/multiplayer/position/plane1_yolk_yaw',...
|
||||||
@@ -32,7 +34,7 @@ THROT = rand();
|
|||||||
CTRL = [0.0, 0.0, 1.0, THROT, 0.0, 1.0];
|
CTRL = [0.0, 0.0, 1.0, THROT, 0.0, 1.0];
|
||||||
|
|
||||||
sendCTRL(CTRL, 1);
|
sendCTRL(CTRL, 1);
|
||||||
result = requestDREF(DREFS);
|
result = getDREFs(DREFS);
|
||||||
|
|
||||||
assert(isequal(length(result),6),'CTRLTest: requestDREF unsucessful-wrong number of elements returned');
|
assert(isequal(length(result),6),'CTRLTest: requestDREF unsucessful-wrong number of elements returned');
|
||||||
assert(isequal(length(result{4}),8),'CTRLTest: requestDREF unsucessful- element 1 incorrect size (should be size 8)');
|
assert(isequal(length(result{4}),8),'CTRLTest: requestDREF unsucessful- element 1 incorrect size (should be size 8)');
|
||||||
|
|||||||
@@ -10,11 +10,10 @@ value = rand();
|
|||||||
data = struct('h',25,'d',[value,-998,-998,-998,-998,-998,-998,-998]);
|
data = struct('h',25,'d',[value,-998,-998,-998,-998,-998,-998,-998]);
|
||||||
|
|
||||||
sendDATA(data);
|
sendDATA(data);
|
||||||
result = requestDREF(DREFS);
|
result = getDREFs(DREFS);
|
||||||
|
|
||||||
assert(isequal(length(result),1),'DATATest: requestDREF unsucessful-wrong number of elements returned');
|
assert(isequal(length(result),8),'DATATest: getDREFs unsucessful-wrong number of elements returned');
|
||||||
assert(isequal(length(result{1}),8),'DATATest: requestDREF unsucessful- element 1 incorrect size (should be size 8)');
|
assert(abs(result(1)-value)<1e-4,'DATATest: DATA set unsucessful');
|
||||||
assert(abs(result{1}(1)-value)<1e-4,'DATATest: DATA set unsucessful');
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ DREFS = {'sim/flightmodel/position/latitude', ...
|
|||||||
POSI = [37.524, -122.06899, 2500, 0, 0, 0, 1]; % Gear
|
POSI = [37.524, -122.06899, 2500, 0, 0, 0, 1]; % Gear
|
||||||
|
|
||||||
sendPOSI(POSI);
|
sendPOSI(POSI);
|
||||||
result = requestDREF(DREFS);
|
result = getDREFs(DREFS);
|
||||||
|
|
||||||
assert(isequal(length(result),7),'POSITest: requestDREF unsucessful-wrong number of elements returned');
|
assert(isequal(length(result),7),'POSITest: getDREFs unsucessful-wrong number of elements returned');
|
||||||
for i=1:length(POSI)
|
for i=1:length(POSI)
|
||||||
if i==3
|
if i==3
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
assert(abs(result{i}(1)-POSI(i))<1e-4,['POSITest: DATA set unsucessful-',num2str(i)]);
|
assert(abs(result(i)-POSI(i))<1e-4,['POSITest: DATA set unsucessful-',num2str(i)]);
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
function requestDREFTest( )
|
function getDREFsTest( )
|
||||||
%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',...
|
||||||
'sim/cockpit2/switches/panel_brightness_ratio'};
|
'sim/cockpit2/switches/panel_brightness_ratio'};
|
||||||
|
|
||||||
result = requestDREF(DREFS);
|
result = getDREFs(DREFS);
|
||||||
|
|
||||||
assert(isequal(length(result),2));
|
assert(isequal(length(result),2));
|
||||||
assert(isequal(length(result{1}),1));
|
assert(isequal(length(result{1}),1));
|
||||||
@@ -4,13 +4,10 @@ function openCloseTest()
|
|||||||
addpath('../../MATLAB')
|
addpath('../../MATLAB')
|
||||||
import XPlaneConnect.*
|
import XPlaneConnect.*
|
||||||
|
|
||||||
socket = openUDP( 49007 );
|
socket = openUDP();
|
||||||
|
closeUDP(socket);
|
||||||
closeUDP( socket );
|
socket = openUDP();
|
||||||
assert(isequal(socket.isClosed(),1),'openCloseTest: socket is still open');
|
closeUDP(socket);
|
||||||
|
|
||||||
socket = openUDP( 49007 );
|
|
||||||
closeUDP( socket );
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -9,17 +9,15 @@ DREFS = {'sim/operation/override/override_planepath'};
|
|||||||
value = 1; % Pause
|
value = 1; % Pause
|
||||||
|
|
||||||
pauseSim(value);
|
pauseSim(value);
|
||||||
result = requestDREF(DREFS);
|
result = getDREFs(DREFS);
|
||||||
|
|
||||||
assert(isequal(length(result),1),'pauseTest: requestDREF unsucessful-wrong number of elements returned');
|
assert(abs(result(1)-value)<1e-4,'pauseTest: Pause Unsuccessful');
|
||||||
assert(abs(result{1}(1)-value)<1e-4,'pauseTest: Pause Unsuccessful');
|
|
||||||
value = 0; % Resume
|
value = 0; % Resume
|
||||||
|
|
||||||
pauseSim(value);
|
pauseSim(value);
|
||||||
result = requestDREF(DREFS);
|
result = getDREFs(DREFS);
|
||||||
|
|
||||||
assert(isequal(length(result),1),'pauseTest: requestDREF unsucessful-wrong number of elements returned');
|
assert(abs(result(1)-value)<1e-4,'pauseTest: Pause Unsuccessful');
|
||||||
assert(abs(result{1}(1)-value)<1e-4,'pauseTest: Pause Unsuccessful');
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
function sendDREFTest( )
|
|
||||||
%SENDREADTEST Summary of this function goes here
|
|
||||||
% Detailed explanation goes here
|
|
||||||
addpath('../../MATLAB')
|
|
||||||
import XPlaneConnect.*
|
|
||||||
|
|
||||||
DREFS = {'sim/cockpit/switches/gear_handle_status'};
|
|
||||||
value = randi([0 10]);
|
|
||||||
|
|
||||||
sendDREF(DREFS{1},value);
|
|
||||||
result = requestDREF(DREFS);
|
|
||||||
|
|
||||||
assert(isequal(length(result),1),'sendDREFTest: requestDREF unsucessful-wrong number of elements returned');
|
|
||||||
assert(isequal(length(result{1}),1),'sendDREFTest: requestDREF unsucessful- element 1 incorrect size (should be size 1)');
|
|
||||||
|
|
||||||
assert(isequal(result{1},value),'sendDREFTest: DREF set unsucessful');
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
function sendReadTest( )
|
|
||||||
%SENDREADTEST Summary of this function goes here
|
|
||||||
% Detailed explanation goes here
|
|
||||||
addpath('../../MATLAB')
|
|
||||||
import XPlaneConnect.*
|
|
||||||
|
|
||||||
recvPortNum = 49074;
|
|
||||||
recvPort = openUDP(49074);
|
|
||||||
|
|
||||||
sendUDP('test2'-0,'127.0.0.1',49074);
|
|
||||||
result = readUDP(recvPort);
|
|
||||||
closeUDP(recvPort);
|
|
||||||
|
|
||||||
assert(~isequal(result,-998), 'no data received');
|
|
||||||
assert(all(result(1:4)'=='test'-0));
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ import XPlaneConnect.*
|
|||||||
DREFS = {'sim/cockpit/switches/gear_handle_status'};
|
DREFS = {'sim/cockpit/switches/gear_handle_status'};
|
||||||
|
|
||||||
setConn(49055);
|
setConn(49055);
|
||||||
result = requestDREF(DREFS);
|
result = getDREFs(DREFS);
|
||||||
|
|
||||||
assert(isequal(length(result),1),'setConnTest: requestDREF unsucessful-wrong number of elements returned');
|
assert(isequal(length(result),1),'setConnTest: requestDREF unsucessful-wrong number of elements returned');
|
||||||
|
|
||||||
|
|||||||
18
TestScripts/MATLAB Tests/setDREFTest.m
Normal file
18
TestScripts/MATLAB Tests/setDREFTest.m
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
function setDREFTest( )
|
||||||
|
%SENDREADTEST Summary of this function goes here
|
||||||
|
% Detailed explanation goes here
|
||||||
|
addpath('../../MATLAB')
|
||||||
|
import XPlaneConnect.*
|
||||||
|
|
||||||
|
DREFS = {'sim/cockpit/switches/gear_handle_status'};
|
||||||
|
value = randi([0 10]);
|
||||||
|
|
||||||
|
setDREF(DREFS{1},value);
|
||||||
|
result = getDREFs(DREFS);
|
||||||
|
|
||||||
|
assert(isequal(length(result),1),'setDREFTest: requestDREF unsucessful-wrong number of elements returned');
|
||||||
|
|
||||||
|
assert(isequal(result(1),value),'setDREFTest: DREF set unsucessful');
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
function struTest( )
|
|
||||||
%STRUTEST Summary of this function goes here
|
|
||||||
% Detailed explanation goes here
|
|
||||||
addpath('../../MATLAB')
|
|
||||||
import XPlaneConnect.*
|
|
||||||
|
|
||||||
recvNum = 49076;
|
|
||||||
recvPort = openUDP(recvNum);
|
|
||||||
|
|
||||||
testSTRU = struct('h',15,'d',[12, 34, 55, 99, 1, 0],'test','theTest');
|
|
||||||
|
|
||||||
sendSTRU(testSTRU,'127.0.0.1',recvNum);
|
|
||||||
resultSTRU = readDATA(recvPort);
|
|
||||||
closeUDP(recvPort);
|
|
||||||
resultSTRU = rmfield(resultSTRU,'raw');
|
|
||||||
assert(isequal(testSTRU,resultSTRU),'struTest: Error-structs are not equal');
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
@@ -11,16 +11,14 @@ end
|
|||||||
disp(['XPC Tests-MATLAB (', os, ')']);
|
disp(['XPC Tests-MATLAB (', os, ')']);
|
||||||
|
|
||||||
theTests = {{@openCloseTest, 'Open/Close Test', 0},...
|
theTests = {{@openCloseTest, 'Open/Close Test', 0},...
|
||||||
{@sendReadTest,'Send/Read Test', 0},...
|
|
||||||
{@sendTEXTTest,'TEXT Test', 0},...
|
{@sendTEXTTest,'TEXT Test', 0},...
|
||||||
{@requestDREFTest,'Request DREF Test', 0},...
|
{@getDREFsTest,'Request DREF Test', 0},...
|
||||||
{@sendDREFTest,'Send DREF Test', 0},...
|
{@setDREFTest,'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},...
|
||||||
{@sendWYPTTest,'WYPT Test', 0},...
|
{@sendWYPTTest,'WYPT Test', 0},...
|
||||||
{@pauseTest,'Pause Test', 0},...
|
{@pauseTest,'Pause Test', 0},...
|
||||||
{@struTest,'Struct Test', 0},...
|
|
||||||
{@setConnTest, 'setConn Test', 0}};
|
{@setConnTest, 'setConn Test', 0}};
|
||||||
|
|
||||||
for i=1:length(theTests)
|
for i=1:length(theTests)
|
||||||
|
|||||||
@@ -382,8 +382,7 @@ namespace XPC
|
|||||||
std::string dref = std::string((char*)buffer + 6, len);
|
std::string dref = std::string((char*)buffer + 6, len);
|
||||||
|
|
||||||
std::uint8_t valueCount = buffer[6 + len];
|
std::uint8_t valueCount = buffer[6 + len];
|
||||||
float values[40];
|
float* values = (float*)(buffer + 7 + len);
|
||||||
memcpy(values, buffer + len + 7, valueCount * sizeof(float));
|
|
||||||
|
|
||||||
#if LOG_VERBOSITY > 1
|
#if LOG_VERBOSITY > 1
|
||||||
Log::FormatLine("[DREF] Request to set DREF value received (Conn %i): %s", connection.id, dref.c_str());
|
Log::FormatLine("[DREF] Request to set DREF value received (Conn %i): %s", connection.id, dref.c_str());
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user