/usr/share/psychtoolbox-3/PsychHardware/PR670Toolbox/PR670measspd.m is in psychtoolbox-3-common 3.0.11.20131230.dfsg1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | function [spd, qual] = PR670measspd(S, syncMode)
% PR670measspd - Make a measurement measurement.
%
% Syntax:
% [spd, qual] = PR670measspd(S)
% [spd, qual] = PR670measspd(S, syncMode)
%
% Input:
% S (1x3) - Desired wavelength sampling. Default: [380 5 81]
% syncMode (string) - Toggles syncronization with the light source. Set
% using the strings 'on' or 'off'. Default: 'on'
%
% Output:
% spd (Mx1) - Light source spectrum.
% qual (scalar) - Measurement quality code. See the PR-670 manual.
% Handle defaults
if nargin < 2 || isempty(syncMode)
syncMode = 'on';
end
% Set wavelength sampling if passed.
if nargin < 1 || isempty(S)
S = [380 5 81];
end
% Initialize
timeout = 300;
% See if we can sync to the source and set sync mode appropriately.
if strcmp(syncMode, 'on')
syncFreq = PR670getsyncfreq;
if ~isempty(syncFreq)
PR670setsyncfreq(1);
else
PR670setsyncfreq(0);
end
else
PR670setsyncfreq(0);
end
% Get the meter response.
readStr = PR670rawspd(timeout);
% Extract the result code.
qual = sscanf(readStr, '%f', 1);
switch qual
% Measurement OK
case 0
spd = PR670parsespdstr(readStr, S);
% Too dark
case -8
spd = zeros(S(3), 1);
% Light source sync failure
case {-1, -10}
disp('Could not sync to source, turning off sync mode and remeasuring');
PR670write('SS0');
readStr = PR670rawspd(timeout);
qual = sscanf(readStr,'%f',1);
if qual == -8
spd = zeros(S(3), 1);
elseif qual == 0
spd = PR670parsespdstr(readStr, S);
else
error('Received unhandled error code %d\n', qual);
end
otherwise
error('Bad return code %g from meter', qual);
end
|