Skip to content
Snippets Groups Projects
Commit 78b368d2 authored by Tim Stadtmann's avatar Tim Stadtmann
Browse files

Merge branch 'develop' into issue-highLevelDispatch

parents 4f27b3c3 87f86bc0
Branches
Tags
No related merge requests found
%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
...@@ -170,7 +170,8 @@ classdef EV3 < MaskedHandle ...@@ -170,7 +170,8 @@ classdef EV3 < MaskedHandle
if ev3.isConnected if ev3.isConnected
if isCommInterfaceValid(ev3.commInterface) if isCommInterfaceValid(ev3.commInterface)
error('EV3::connect: Already connected.'); warning('EV3::connect: Already connected. Resetting connection now...');
ev3.disconnect();
else else
warning(['EV3::connect: EV3.isConnected is set to ''True'', but ',... warning(['EV3::connect: EV3.isConnected is set to ''True'', but ',...
'comm handle is invalid. Deleting invalid handle and ' ,... 'comm handle is invalid. Deleting invalid handle and ' ,...
...@@ -241,8 +242,16 @@ classdef EV3 < MaskedHandle ...@@ -241,8 +242,16 @@ classdef EV3 < MaskedHandle
% b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| % b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br|
% % do stuff |br| % % do stuff |br|
% b.disconnect(); % |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 % Disconnect motors and sensors
% -> set references to comm handle to 0 % -> set references to comm handle to 0
...@@ -432,9 +441,10 @@ classdef EV3 < MaskedHandle ...@@ -432,9 +441,10 @@ classdef EV3 < MaskedHandle
warning('off', 'all'); % Turn off warnings while reading values warning('off', 'all'); % Turn off warnings while reading values
for i = 1:length(props) for i = 1:length(props)
p = props{i}; p = props{i};
member = ev3.(p);
if strcmp(class(ev3.(p)),'Sensor') || strcmp(class(ev3.(p)), 'Motor')
fprintf('\t%15s [Type: %s]\n', p, char(ev3.(p).type)); if strcmp(class(member),'Sensor') || strcmp(class(member), 'Motor')
fprintf('\t%15s [Type: %s]\n', p, char(member.type));
end end
end end
warning('on', 'all'); warning('on', 'all');
......
...@@ -46,15 +46,15 @@ for i = 1:length(dependentProps) ...@@ -46,15 +46,15 @@ for i = 1:length(dependentProps)
value = device.(p); value = device.(p);
if ~isempty(enumeration(value)) % Test if parameter is enumeration if ~isempty(enumeration(value)) % Test if parameter is enumeration
fprintf('\t%15s: %s\n', p, char(value)); fprintf('\t%15s: %s\n', p, char(value));
elseif isnumeric(device.(p)) || islogical(value) elseif isnumeric(value) || islogical(value)
if isfloat(value) if isfloat(value)
fprintf('\t%15s: %1.1f\n', p, value); fprintf('\t%15s: %1.1f\n', p, value);
else else
fprintf('\t%15s: %d\n', p, value); fprintf('\t%15s: %d\n', p, value);
end end
elseif ischar(device.(p)) elseif ischar(value)
fprintf('\t%15s: %s\n', p, value); fprintf('\t%15s: %s\n', p, value);
elseif islogical(device.(p)) elseif islogical(value)
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment