From 15df14d3346ada693441787fe0451afeb9b70c91 Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Tue, 7 Apr 2015 10:37:23 -0700 Subject: [PATCH] Added multiplayer sendCTRL support to MATLAB client - Also fixed a bug in the message format where gear was sent as a single rather than a byte. --- MATLAB/+XPlaneConnect/sendCTRL.m | 5 ++++- TestScripts/MATLAB Tests/CTRLTest.m | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/MATLAB/+XPlaneConnect/sendCTRL.m b/MATLAB/+XPlaneConnect/sendCTRL.m index 8e8ed0b..821efd0 100644 --- a/MATLAB/+XPlaneConnect/sendCTRL.m +++ b/MATLAB/+XPlaneConnect/sendCTRL.m @@ -52,7 +52,10 @@ import XPlaneConnect.* for i=1:min(length(ctrl),length(control)) control(i) = ctrl(i); end - dataStream = [dataStream, typecast(single(control),'uint8')]; + dataStream = [dataStream, typecast(single(control(1:4)),'uint8')]; + dataStream = [dataStream, uint8(control(5))]; + dataStream = [dataStream, typecast(single(control(6)),'uint8')]; + dataStream = [dataStream, uint8(acft)]; % Send DATA status = sendUDP(dataStream, IP, port); diff --git a/TestScripts/MATLAB Tests/CTRLTest.m b/TestScripts/MATLAB Tests/CTRLTest.m index 9bacf13..6ba5386 100644 --- a/TestScripts/MATLAB Tests/CTRLTest.m +++ b/TestScripts/MATLAB Tests/CTRLTest.m @@ -22,5 +22,23 @@ for i=1:length(CTRL)-1 assert(abs(result{i}(1)-CTRL(i))<1e-4,['CTRLTest: DATA set unsucessful-',num2str(i)]); end +DREFS = {'sim/multiplayer/position/plane1_yolk_pitch',... + 'sim/multiplayer/position/plane1_yolk_roll',... + 'sim/multiplayer/position/plane1_yolk_yaw',... + 'sim/multiplayer/position/plane1_throttle',... + 'sim/multiplayer/position/plane1_gear_deploy',... + 'sim/multiplayer/position/plane1_flap_ratio'}; +THROT = rand(); +CTRL = [0.0, 0.0, 1.0, THROT, 0.0, 1.0]; + +sendCTRL(CTRL, 1); +result = requestDREF(DREFS); + +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)'); +for i=1:length(CTRL)-1 + assert(abs(result{i}(1)-CTRL(i))<1e-4,['CTRLTest: DATA set unsucessful-',num2str(i)]); +end + end