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

Fix issue #48

parent c392fc8d
Branches
Tags
No related merge requests found
...@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment