-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbrl_get_AxonMP285.m
82 lines (61 loc) · 2.62 KB
/
brl_get_AxonMP285.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
function success = brl_get_AxonMP285(axonPortNumber)
% © 2015 Allen Institute.
% This file is part of smartACT.
% smartACT is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or (at your option)
% any later version. smartACT is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
% General Public License for more details.
% You should have received a copy of the GNU General Public License along with smartACT.
% If not, see <http://www.gnu.org/licenses/>.
%
% This package is currently not maintained and no support is implied.
% Questions may be directed to Brian Long
% <brianl@alleninstitute.org> with 'smartACT' in the subject line.
%
% BRL code to get control of axon MP285...2014.01.1X
%
% optional input is COM port number for the sutter serial control of interest, here
%labeled `Axon'
% THIS FUNCTION DECLARES A GLOBAL VARIABLE axon285 that is used to control
% a Sutter MP285.
% output
% success = 0 means axon285 initialization failed
% 1 means successful initialization
% 2 global variable axon285 already exists
if nargin==0
axonPortNumber = 4;
end
axonPortNumberString=['COM',num2str(axonPortNumber)];
fprintf(['* * * * * * * * * * * * * * * * * * * \n'])
fprintf(['Getting Axon MP-285 from ' , axonPortNumberString, '\n'])
if ~isempty(whos('global','axon285'))
fprintf('axon285 already exists as a global variable...\n')
success = 2;
return
end
nothingOnAxonCom = isempty(instrfind('Port', axonPortNumberString));
if nothingOnAxonCom
global axon285
axon285 = dabs.sutter.MP285('comPort', 4,'baudrate', 9600)
if strcmp('dabs.sutter.MP285', class(axon285))
fprintf(['DECLARED GLOBAL axon285 of class ', class(axon285), '\n'])
success=1;
return
else
fprintf(['failed to acquire Axon MP-285 from COM ', num2str(axonPortNumber),'\n'])
fprintf(['could not initialize dabs.sutter.MP285\n'])
clear global axon285
success =0;
return
end
else
fprintf( ['failed to acquire Axon MP-285 from COM ', num2str(axonPortNumber),'\n'])
fprintf( [axonPortNumberString, ' has already been opened\n'])
fprintf( ['use ''a=instrfind'' and ''delete(a(1))'' if ''a(1)'' is a serial port object at the desired port '])
fprintf( [axonPortNumberString, ' has already been opened\n'])
success =0;
return
end