Refactored MATLAB client to use the Java client internally.
- Still need to implement selectDATA for all languages.
This commit is contained in:
@@ -1,51 +1,35 @@
|
||||
function status = setConn( recvPort, IP, port )
|
||||
function setConn(port, socket)
|
||||
% setConn Send a command to set up the port where you will receive data on
|
||||
% this computer.
|
||||
%
|
||||
% 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.
|
||||
% port: Port that data will be sent to in the future for this connection.
|
||||
% socket (optional): The client to use when sending the command.
|
||||
%
|
||||
% Use
|
||||
% 1. import XPlaneConnect.*
|
||||
% 2. status = setConn(49011);
|
||||
%
|
||||
% Contributors
|
||||
% [CT] Christopher Teubert (SGT, Inc.)
|
||||
% christopher.a.teubert@nasa.gov
|
||||
%
|
||||
% To Do
|
||||
% 1. Verify Input
|
||||
%
|
||||
% BEGIN CODE
|
||||
import XPlaneConnect.*
|
||||
% Christopher Teubert (SGT, Inc.) <christopher.a.teubert@nasa.gov>
|
||||
% Jason Watkins <jason.w.watkins@nasa.gov>
|
||||
|
||||
status = 0;
|
||||
message = zeros(1,7);
|
||||
|
||||
%% Handle Input
|
||||
% Optional parameters
|
||||
if ~exist('IP','var'), IP = '127.0.0.1'; end
|
||||
if ~exist('port','var'), port = 49009; end
|
||||
import XPlaneConnect.*
|
||||
|
||||
% Check format of input-TODO
|
||||
%% Get client
|
||||
global clients;
|
||||
if ~exist('socket', 'var')
|
||||
assert(istrue(length(clients) < 2), '[sendCTRL] ERROR: Multiple clients open. You must specify which client to use.');
|
||||
if isempty(clients)
|
||||
openUDP();
|
||||
end
|
||||
socket = clients(1);
|
||||
end
|
||||
|
||||
%% BODY
|
||||
% Header
|
||||
message(1:4) = 'CONN'-0;
|
||||
|
||||
% RecvPort
|
||||
message(6:7) = typecast(uint16(recvPort),'uint8');
|
||||
|
||||
% Send
|
||||
sendUDP(message,IP,port);
|
||||
|
||||
global udpReadPort;
|
||||
udpReadPort = recvPort;
|
||||
readUDP(); % Read and discard CONF message
|
||||
%% Validate input
|
||||
port = int32(port);
|
||||
|
||||
%% Send command
|
||||
socket.setCONN(port);
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user