Skip to content
Snippets Groups Projects
Commit c55f886d authored by Maximilian Schnabel's avatar Maximilian Schnabel
Browse files

Revert "disabled warning when using connect() with an established connection, because..."

This reverts commit 1358c13c
parent d398f5e1
No related branches found
No related tags found
2 merge requests!7Keep going if mountpoint exists (persistent),!6Docs NXT compatibility
...@@ -35,19 +35,20 @@ classdef EV3 < MaskedHandle ...@@ -35,19 +35,20 @@ classdef EV3 < MaskedHandle
% batteryValue (numeric): Current battery charge. Depending on batteryMode, the reading is either in percentage or voltage. See also :attr:`batteryMode`. *[READ-ONLY]* % batteryValue (numeric): Current battery charge. Depending on batteryMode, the reading is either in percentage or voltage. See also :attr:`batteryMode`. *[READ-ONLY]*
% isConnected (bool): True if virtual brick-object is connected to physical one. *[READ-ONLY]* % isConnected (bool): True if virtual brick-object is connected to physical one. *[READ-ONLY]*
% %
% ::
% %
% Example: % Example:
% % This example expects a motor at port A and a (random) sensor at port 1 |br| % # This example expects a motor at port A and a (random) sensor at port 1
% b = EV3(); % |br| % brick = EV3();
% b.connect('usb'); % |br| % brick.connect('usb');
% ma = b.motorA; % |br| % motorA = brick.motorA;
% ma.setProperties('power', 50, 'limitValue', 720); % |br| % motorA.setProperties('power', 50, 'limitValue', 720);
% ma.start(); % |br| % motorA.start();
% % fun |br| % motorA.waitFor();
% ma.waitFor(); % |br| % disp(brick.sensor1.value);
% disp(b.sensor1.value); % |br| % brick.beep();
% b.beep(); % |br| % delete brick;
% delete b; % |br| %
properties properties
% batteryMode (string in {'Percentage', 'Voltage'}): Mode for reading battery charge. [WRITABLE] % batteryMode (string in {'Percentage', 'Voltage'}): Mode for reading battery charge. [WRITABLE]
...@@ -158,21 +159,22 @@ classdef EV3 < MaskedHandle ...@@ -158,21 +159,22 @@ classdef EV3 < MaskedHandle
% (necessary if connectionType is 'bt'). *[OPTIONAL]* % (necessary if connectionType is 'bt'). *[OPTIONAL]*
% beep (bool): If true, EV3 beeps if connection has been established. *[OPTIONAL]* % beep (bool): If true, EV3 beeps if connection has been established. *[OPTIONAL]*
% %
%
% ::
%
% Example: % Example:
% % Setup bluetooth connection via com-port 0 |br| % % Setup bluetooth connection via com-port 0
% b = EV3(); % |br| % brick = EV3();
% b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| % brick.connect('bt', 'serPort', '/dev/rfcomm0');
% % Setup usb connection, beep when connection has been established % % Setup usb connection, beep when connection has been established
% b = EV3(); % |br| % brick = EV3();
% b.connect('usb', 'beep', 'on', ); % |br| % brick.connect('usb', 'beep', 'on', );
% %
% See also ISCONNECTED / :attr:`isConnected` % See also ISCONNECTED / :attr:`isConnected`
if ev3.isConnected if ev3.isConnected
if isCommInterfaceValid(ev3.commInterface) if isCommInterfaceValid(ev3.commInterface)
% Warning lead to confusion of students. Since brick connection is still working warning('EV3::connect: Already connected. Resetting connection now...');
% even if calling connect() multiple times, it is disabled.
% warning('EV3::connect: Already connected. Resetting connection now...');
ev3.disconnect(); ev3.disconnect();
else else
warning(['EV3::connect: EV3.isConnected is set to ''True'', but ',... warning(['EV3::connect: EV3.isConnected is set to ''True'', but ',...
...@@ -228,11 +230,14 @@ classdef EV3 < MaskedHandle ...@@ -228,11 +230,14 @@ classdef EV3 < MaskedHandle
% Notes: % Notes:
% * Gets called automatically when EV3-object is destroyed. % * Gets called automatically when EV3-object is destroyed.
% %
%
% ::
%
% Example: % Example:
% b = EV3(); % |br| % brick = EV3();
% b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| % brick.connect('bt', 'serPort', '/dev/rfcomm0');
% % do stuff |br| % % do stuff
% b.disconnect(); % |br| % brick.disconnect();
% Resetting needs a working connection in order to send reset-commands % Resetting needs a working connection in order to send reset-commands
% to the Brick. If the connection has been aborted (e.g. by pulling the % to the Brick. If the connection has been aborted (e.g. by pulling the
...@@ -274,10 +279,13 @@ classdef EV3 < MaskedHandle ...@@ -274,10 +279,13 @@ classdef EV3 < MaskedHandle
% Notes: % Notes:
% * This equals playTone(10, 1000, 100). % * This equals playTone(10, 1000, 100).
% %
%
% ::
%
% Example: % Example:
% b = EV3(); % |br| % brick = EV3();
% b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| % brick.connect('bt', 'serPort', '/dev/rfcomm0');
% b.beep(); % |br| % brick.beep();
% %
ev3.handleCommand(@soundPlayTone, 10, 1000, 100); ev3.handleCommand(@soundPlayTone, 10, 1000, 100);
end end
...@@ -290,11 +298,13 @@ classdef EV3 < MaskedHandle ...@@ -290,11 +298,13 @@ classdef EV3 < MaskedHandle
% frequency (numeric in [250, 10000]): in Hertz % frequency (numeric in [250, 10000]): in Hertz
% duration (numeric > 0): in milliseconds % duration (numeric > 0): in milliseconds
% %
%
% ::
%
% Example: % Example:
% b = EV3(); % |br| % brick = EV3();
% b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| % brick.connect('bt', 'serPort', '/dev/rfcomm0');
% b.playTone(40, 5000, 1000); % Plays tone with 40% volume and 5000Hz for 1 % brick.playTone(40, 5000, 1000); % Plays tone with 40% volume and 5000Hz for 1 second.
% second. |br|
% %
ev3.handleCommand(@soundPlayTone, volume, frequency, duration); ev3.handleCommand(@soundPlayTone, volume, frequency, duration);
end end
...@@ -302,11 +312,14 @@ classdef EV3 < MaskedHandle ...@@ -302,11 +312,14 @@ classdef EV3 < MaskedHandle
function stopTone(ev3) function stopTone(ev3)
% Stops tone currently played. % Stops tone currently played.
% %
%
% ::
%
% Example: % Example:
% b = EV3(); % |br| % brick = EV3();
% b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| % brick.connect('bt', 'serPort', '/dev/rfcomm0');
% b.playTone(10,100,100000000); % Accidentally given wrong tone duration :) |br| % brick.playTone(10,100,100000000);
% b.stopTone(); % Stops tone immediately. |br| % brick.stopTone(); % Stops tone immediately.
% %
ev3.handleCommand(@soundStopTone); ev3.handleCommand(@soundStopTone);
end end
...@@ -317,12 +330,16 @@ classdef EV3 < MaskedHandle ...@@ -317,12 +330,16 @@ classdef EV3 < MaskedHandle
% Returns: % Returns:
% status (bool): True if a tone is being played % status (bool): True if a tone is being played
% %
% Example %
% b = EV3(); % |br| % ::
% b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| %
% b.playTone(10, 100, 1000); % |br| % Example:
% pause(0.5); % Small pause is necessary as tone does not start instantaneously |br| % brick = EV3();
% b.tonePlayed(); % -> Outputs 1 to console. |br| % brick.connect('bt', 'serPort', '/dev/rfcomm0');
% brick.playTone(10, 100, 1000);
% pause(0.5);
% % Small pause necessary since tone not startong immediately
% brick.tonePlayed(); % -> Outputs 1 to console.
% %
status = ev3.handleCommand(@soundTest); status = ev3.handleCommand(@soundTest);
end end
...@@ -374,11 +391,14 @@ classdef EV3 < MaskedHandle ...@@ -374,11 +391,14 @@ classdef EV3 < MaskedHandle
% debug (numeric in {0,1,2}): see EV3.debug *[OPTIONAL]* % debug (numeric in {0,1,2}): see EV3.debug *[OPTIONAL]*
% batteryMode (string in {'Voltage'/'Percentage'}): see EV3.batteryMode *[OPTIONAL]* % batteryMode (string in {'Voltage'/'Percentage'}): see EV3.batteryMode *[OPTIONAL]*
% %
%
% ::
%
% Example: % Example:
% b = EV3(); % |br| % brick = EV3();
% b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| % brick.connect('bt', 'serPort', '/dev/rfcomm0');
% b.setProperties('debug', 'on', 'batteryMode', 'Voltage'); % |br| % brick.setProperties('debug', 'on', 'batteryMode', 'Voltage');
% % Instead of: b.debug = 'on'; b.batteryMode = 'Voltage'; % |br| % % Instead of: b.debug = 'on'; b.batteryMode = 'Voltage';
% %
% See also EV3.DEBUG, EV3.BATTERYMODE / :attr:`debug`, :attr:`batteryMode` % See also EV3.DEBUG, EV3.BATTERYMODE / :attr:`debug`, :attr:`batteryMode`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment