diff --git a/source/CommunicationInterface.m b/source/CommunicationInterface.m index 07fe1ad377cca4ff4a4f1b831ecdde5be815eb2f..4972fe03401721930c88412d73b644b5f2fc7997 100755 --- a/source/CommunicationInterface.m +++ b/source/CommunicationInterface.m @@ -123,9 +123,9 @@ classdef CommunicationInterface < handle methods %% Constructor, Destructor, Setter... function commInterface = CommunicationInterface(varargin) - % Brick.Brick Create a Brick object + % CommunicationInterface.CommunicationInterface Create a CommunicationInterface object % - % b = Brick(OPTIONS) is an object that represents a connection + % b = CommunicationInterface(...) is an object that represents a connection % interface to a Lego Mindstorms EV3 brick. % % Options:: @@ -137,10 +137,12 @@ classdef CommunicationInterface < handle % % Notes:: % - Can connect through: usbBrickIO, btBrickIO - % - For usbBrickIO: - % b = Brick('ioType','usb') - % - For btBrickIO: - % b = Brick('ioType','bt','serPort','/dev/rfcomm0') + % - For USB connection: + % b = CommunicationInterface('usb') + % - For BT connection on linux/mac: + % b = CommunicationInterface('bt','serPort','/dev/rfcomm0') + % - For BT conenction on windows: + % b = CommunicationInterface('bt','backend','instrumentControl,'channel',1,'deviceName','EV3') props = commInterface.evaluateProperties(varargin{:}); commInterface.ioType = props.ioType; @@ -153,7 +155,7 @@ classdef CommunicationInterface < handle if(strcmp(props.backend, 'serial')) commInterface.conn = btBrickIO('debug', props.debug, 'serPort', props.serPort); else - commInterface.conn = btBrickIO('debug', props.debug, 'channel', props.channel, 'deviceName', props.deviceName); + commInterface.conn = btBrickIO('debug', props.debug, 'backend', props.backend, 'channel', props.channel, 'deviceName', props.deviceName); end end catch ME @@ -177,6 +179,7 @@ classdef CommunicationInterface < handle brick.debug = debug; brick.conn.debug = debug; end + function set.timeOut(brick, timeOut) if ~isnumeric(timeOut) || timeOut < 0 error(ID(), 'timeOut-period of USB-handle can only be set to positive numerical values.'); diff --git a/source/btBrickIO.m b/source/btBrickIO.m index ede4c665562cccf8207c88775559a79de1f833e7..a11bfc891fce51e9494a8f8a72f0843f057f78af 100755 --- a/source/btBrickIO.m +++ b/source/btBrickIO.m @@ -31,9 +31,9 @@ classdef btBrickIO < BrickIO % bluetooth serial port (used if backend == 'serial') serialPort; % bluetooth brick device name (used if backend == 'instrumentControl') - btDevice; + deviceName; % bluetooth connection channel (used if backend == 'instrumentControl') - btChannel; + channel; % time-out period in seconds (if 0, no time-out) timeOut; % use implementation based on the serial-connection implementation by MATLAB (should @@ -61,8 +61,8 @@ classdef btBrickIO < BrickIO p.addOptional('debug', 0); p.addOptional('serPort', '/dev/rfcomm0'); - p.addOptional('btDevice', 'EV3'); - p.addOptional('btChannel', 1); + p.addOptional('deviceName', 'EV3'); + p.addOptional('channel', 1); p.addOptional('timeOut', 10); p.addOptional('backend', 'serial'); @@ -70,29 +70,11 @@ classdef btBrickIO < BrickIO brickIO.debug = p.Results.debug; brickIO.serialPort = p.Results.serPort; - brickIO.btDevice = p.Results.btDevice; - brickIO.btChannel = p.Results.btChannel; + brickIO.deviceName = p.Results.deviceName; + brickIO.channel = p.Results.channel; brickIO.timeOut = p.Results.timeOut; brickIO.backend = p.Results.backend; -% if nargin > 1 -% brickIO.debug = debug; -% brickIO.serialPort = serialPort; -% if nargin >= 3 -% if ~strcmp(backend, 'serial') && ~strcmp(backend, 'instrumentControl') -% msg = 'btBrickIO''s backend-parameter has to be either ''serial'' or ''instrumentControl''.'; -% id = [ID(), ':', 'InvalidParameter']; -% throw(MException(id, msg)); -% elseif ~license('test', 'instr_control_toolbox') -% msg = 'Cannot use Instrument-Control-Toolbox for Bluetooth: Toolbox not installed.'; -% id = [ID(), ':', 'AssetNotAvailable']; -% throw(MException(id, msg)); -% end -% -% brickIO.backend = backend; -% end -% end - if brickIO.debug > 0 fprintf('btBrickIO init\n'); end @@ -102,7 +84,7 @@ classdef btBrickIO < BrickIO if strcmp(brickIO.backend, 'serial') brickIO.handle = serial(brickIO.serialPort); else - brickIO.handle = Bluetooth(brickIO.btDevice,brickIO.btChannel); + brickIO.handle = Bluetooth(brickIO.deviceName,brickIO.channel); end catch ME if ~isempty(strfind(ME.identifier, 'invalidPORT'))