Completed Preliminary MATLAB Test Scripts

This commit is contained in:
Chris Teubert
2014-11-28 17:08:41 -08:00
parent 2cb1d541d5
commit 4bfe4fe88d
21 changed files with 256 additions and 19 deletions

View File

@@ -23,4 +23,6 @@ function [socket] = closeUDP(socket)
socket.close;
assert(isequal(socket.isClosed(),1),'closeUDP: Error- Could not close socket');
end

View File

@@ -36,4 +36,6 @@ if ~isempty(varargin)
end
end
assert(isequal(socket.isClosed(),0),'openUDP: Error- Could not open port');
end

View File

@@ -67,7 +67,7 @@ function [ sensor ] = readDATA( socket )
dim1 = sensor.raw(a);
dim2 = sensor.raw(a+1);
if dim1 == 0 %String
value = char(sensor.raw(a+2:a+1+dim2));
value = char(sensor.raw(a+2:a+1+dim2))';
a = a + dim2 + 2;
else
value = [];

View File

@@ -50,7 +50,7 @@ function [ data ] = readUDP( input )
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

View File

@@ -36,7 +36,7 @@ import XPlaneConnect.*
%% Handle Input
% Optional parameters
if ~exist('IP','var'), IP = "127.0.0.1"; end
if ~exist('IP','var'), IP = '127.0.0.1'; end
if ~exist('port','var'), port = 49009; end
if ~exist('acft','var'), acft = 0; end
@@ -44,7 +44,7 @@ import XPlaneConnect.*
%%BODY
header = ['CTRL'-0,0];
dataStream = [header, acft];
dataStream = header; %TODO-ADD ACFT
% Deal with position update
control = [0, 0, 0, 0.8, 0, 1];
@@ -55,7 +55,7 @@ import XPlaneConnect.*
dataStream = [dataStream, typecast(single(control),'uint8')];
% Send DATA
status = sendUDP(IP, port, dataStream);
status = sendUDP(dataStream, IP, port);
end

View File

@@ -42,16 +42,8 @@ function [ status ] = sendUDP( data, IP, port )
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
IP = InetAddress.getByName(IP);
packet = DatagramPacket(data, length(data), IP, port); %create packet
socket.send(packet);
end