diff --git a/source/Device.m b/source/Device.m deleted file mode 100644 index ba1b61c9d75eef20d543fd42a46fa1be1cc27c47..0000000000000000000000000000000000000000 --- a/source/Device.m +++ /dev/null @@ -1,121 +0,0 @@ -%Device Device enumeration for the brick -% -% Notes:: -% - Collection of enumeration constants used for the brick - -classdef Device < uint8 - enumeration - % motor types and modes - LargeMotor (7) - MediumMotor (8) - MotorDegrees (0) - MotorRotation (1) - MotorSpeed (2) - % motor definitions for setting and starting the motor (found in c_output.c => NOS DATA8) - MotorA (1) - MotorB (2) - MotorC (4) - MotorD (8) - % motor definitions for reading motor data with output functions (found in c_output.c) - % e.g. outputGetCount(...), outputRead(...) (the latter is yet to be implemented) - MotorA_PORT (0) - MotorB_PORT (1) - MotorC_PORT (2) - MotorD_PORT (3) - % motor definitions for input functions (found in (?)) - % e.g. inputDeviceGetConnection(...), inputDeviceGetName(...), ... - MotorA_INPUT (16) - MotorB_INPUT (17) - MotorC_INPUT (18) - MotorD_INPUT (19) - % mode of braking (found in c_output.c) - Coast (0) - Brake (1) - % sensor ports (found in c_output.c) - Port1 (0) - Port2 (1) - Port3 (2) - Port4 (3) - % LED patterns (found in bytecodes.h) - LedBlack (0) - LedGreen (1) - LedRed (2) - LedOrange (3) - LedGreenFlash (4) - LedRedFlash (5) - LedOrangeFlash (6) - LedGreenPulse (7) - LedRedPulse (8) - LedOrangePulse (9) - % colors (found in bytecodes.h) - NoColor (0) - BlackColor (1) - BlueColor (2) - GreenColor (3) - YellowColor (4) - RedColor (5) - WhiteColor (6) - BrownColor (7) - % ultrasonic sensor definitions (found in types.html) - Ultrasonic (30) - USDistCM (0) - USDistIN (1) - USListen (2) - % gyro sensor definitions (found in types.html) - Gyro (32) - GyroAng (0) - GyroRate (1) - % touch sensor definitions (found in types.html) - Touch (16) - Pushed (0) - Bumps (1) - % color sensor definitions (found in types.html) - Color (29) - ColReflect (0) - ColAmbient (1) - ColColor (2) - % input & output connection types (found in lms2012.h) - ConnUnknown (111) - ConnDaisyChain (117) - ConnNXTColor (118) - ConnNXTDumb (119) - ConnNXTIIC (120) - ConnInputDumb (121) - ConnInputUART (122) - ConnOutputDumb (123) - ConnOutputIntelligent (124) - ConnOutputTacho (125) - ConnNone (126) - ConnError (127) - % NXT sound sensor definitions (found in types.html) - Sound (3) - SoundDB (0) - SoundDBA (1) - % NXT light sensor definitions (found in types.html) - NXTLight (2) - NXTReflect (0) - NXTAmbient (1) - % NXT touch sensor definitions - NXTTouch (1) - % NXT color sensor definitions - NXTColor (4) - NXTColReflect (0) - NXTColAmbient (1) - NXTColCol (2) - NXTColGreen (3) - NXTColBlue (4) - NXTColRaw (5) - % NXT ultrasonic sensor definitions - NXTUltrasonic (5) - NXTUSDistCM (0) - NXTUSDistIN (1) - % NXT temperature sensor definitions - NXTTemperature (6) - NXTTempC (0) - NXTTempF (1) - % additional device types - TypeUnknown (125) - TypeNone (126) - TypeError (127) - end -end diff --git a/source/EV3.m b/source/EV3.m index 239698e4aa5eecd9b9df2d2d187256fec30a2428..0832ca49d3049d5c7148befe7fb378dff12e2e55 100644 --- a/source/EV3.m +++ b/source/EV3.m @@ -170,7 +170,8 @@ classdef EV3 < MaskedHandle if ev3.isConnected if isCommInterfaceValid(ev3.commInterface) - error('EV3::connect: Already connected.'); + warning('EV3::connect: Already connected. Resetting connection now...'); + ev3.disconnect(); else warning(['EV3::connect: EV3.isConnected is set to ''True'', but ',... 'comm handle is invalid. Deleting invalid handle and ' ,... @@ -241,8 +242,16 @@ classdef EV3 < MaskedHandle % b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| % % do stuff |br| % b.disconnect(); % |br| - - ev3.resetPhysicalBrick(); + + % 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 + % USB-cord), the reset-methods would fail -> catch this error and for + % now do nothing. + try + ev3.resetPhysicalBrick(); + catch ME + % For now: ignore + end % Disconnect motors and sensors % -> set references to comm handle to 0 @@ -432,9 +441,10 @@ classdef EV3 < MaskedHandle warning('off', 'all'); % Turn off warnings while reading values for i = 1:length(props) p = props{i}; - - if strcmp(class(ev3.(p)),'Sensor') || strcmp(class(ev3.(p)), 'Motor') - fprintf('\t%15s [Type: %s]\n', p, char(ev3.(p).type)); + member = ev3.(p); + + if strcmp(class(member),'Sensor') || strcmp(class(member), 'Motor') + fprintf('\t%15s [Type: %s]\n', p, char(member.type)); end end warning('on', 'all'); diff --git a/source/displayProperties.m b/source/displayProperties.m index 7b39943844cc380e259cf5628f5a6a0c5ee37ba4..3c7a8effc06ea6405ae93749063f30a77b89f940 100644 --- a/source/displayProperties.m +++ b/source/displayProperties.m @@ -46,15 +46,15 @@ for i = 1:length(dependentProps) value = device.(p); if ~isempty(enumeration(value)) % Test if parameter is enumeration fprintf('\t%15s: %s\n', p, char(value)); - elseif isnumeric(device.(p)) || islogical(value) + elseif isnumeric(value) || islogical(value) if isfloat(value) fprintf('\t%15s: %1.1f\n', p, value); else fprintf('\t%15s: %d\n', p, value); end - elseif ischar(device.(p)) + elseif ischar(value) fprintf('\t%15s: %s\n', p, value); - elseif islogical(device.(p)) + elseif islogical(value) end end