/usr/share/psychtoolbox-3/PsychHardware/PR650Toolbox/PR650init.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 74 75 76 77 78 79 80 81 82 83 | function retval = PR650init(portNumber, enableHandshaking)
% retval = PR650init(portNumber, [enableHandshaking])
%
% Initialize serial port for talking to colorimeter.
% Returns whatever character is sent by colorimeter
%
% 'enableHandshaking' allows you to enable handshaking. By default,
% handshaking is disabled. To enable handshaking, set this value to 1 or
% true.
%
% 11/26/07 mpr added timeout if nothing is returned within 10 seconds.
%
% In my experience, calling this function directly leads to poor performance
% (usually no communication is ever established). You should find the function
% CMCheckInit in the PsychHardware folder, one folder up the tree from this one
% (which is presumably PR650Toolbox). Calling this function from CMCheckInit
% should provide more reliable establishment of contact and hints on what to
% try if contact fails. -- MPR
global g_serialPort g_useIOPort;
if nargin == 1
enableHandshaking = 0;
end
if ~g_useIOPort
if enableHandshaking
handshakeCode = 'h';
else
handshakeCode = 'n';
end
% Only open if we haven't already.
if isempty(g_serialPort)
SerialComm('open', portNumber, '9600,n,8,1');
SerialComm('hshake', portNumber, handshakeCode);
SerialComm('close', portNumber);
WaitSecs(0.5);
SerialComm('open', portNumber, '9600,n,8,1');
SerialComm('hshake', portNumber, handshakeCode);
g_serialPort = portNumber;
end
StartTime = GetSecs;
% Send set backlight command to high level to check
% whether we are talking to the meter.
SerialComm('write', g_serialPort, ['b3' char(10)]);
retval = [];
while isempty(retval) && GetSecs-StartTime < 10
retval = PR650serialread;
end
end
if g_useIOPort
if enableHandshaking
handshakeCode = 'Lenient DontFlushOnWrite=1 FlowControl=Hardware ';
else
handshakeCode = 'Lenient DontFlushOnWrite=1 FlowControl=None ';
end
% Only open if we haven't already.
if isempty(g_serialPort)
oldverbo = IOPort('Verbosity', 2);
hPort = IOPort('OpenSerialPort', portNumber, handshakeCode);
IOPort('Close', hPort);
WaitSecs(0.5);
hPort = IOPort('OpenSerialPort', portNumber, handshakeCode);
IOPort('Verbosity', oldverbo);
g_serialPort = hPort;
end
StartTime = GetSecs;
% Send set backlight command to high level to check
% whether we are talking to the meter.
IOPort('write', g_serialPort, ['b3' char(10)]);
% Make sure the meter responds.
retval = [];
while isempty(retval) && GetSecs-StartTime < 10
retval = PR650serialread;
end
end
|