This file is indexed.

/usr/share/psychtoolbox-3/PsychHardware/Daq/DaqDIn.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
84
85
86
87
88
89
90
91
92
93
94
95
function data=DaqDIn(daq,NumberOfPorts, port)
% data=DaqDIn([DeviceIndex],[NumberOfPorts])
% USB-1208FS: Read digital ports. This command reads the current state of
% the DIO ports.  The return value will be the value seen at the port pins.
% data(1) is the 8-bit value read from port A.
% data(2) is the 8-bit value read from port B.
% "DeviceIndex" is a small integer, the array index specifying which HID
%       device in the array returned by PsychHID('Devices') is interface 0
%       of the desired USB-1208FS box.
%
% USB-1608FS: There is only one port, so only one meaningful return value.  
% First argument is optional if you have only one DAQ device, but code will
% run faster if DeviceIndex is specified.  Second argument is optional; if
% it is not specified, software will attempt to determine if it should be 1
% or 2 based on the type of device.  Specifying it explicitly speeds up
% code about 1 to 2  milliseconds per call on a dual core MacI with 2.67
% GHz processors. -- mpr 
%
% USB-1024LS: Has three ports, probably numbered: 1 = port A, 4 = port B,
% 10 = port C (the sum of: 8 = portC low, 2 = portC high). Maybe you'll
% need to read port C separately in two calls for low- and high- part.
%
% See also Daq, DaqFunctions, DaqPins, DaqTest, PsychHIDTest.
% DaqDeviceIndex, DaqDOut, DaqAIn, DaqAOut, DaqAInScan,DaqAOutScan.
%
% 4/15/05 dgp Wrote it.
% 12/18/07  mpr   added second argument and made first optional
% 1/11/08   mpr   swept through trying to improve consistency across daq
%                     functions
% 5/22/08   mk  Add (untested!) support for USB-1024LS box. 
% 5/23/08   mk  Add caching for HID device list. 

% Perform internal caching of list of HID devices in 'TheDevices'
% to speedup call:
persistent TheDevices;
if isempty(TheDevices)
    TheDevices = PsychHIDDAQS;
end

% Default reportId for 1x08FS devices is 3:
reportId = 3;
TheReport = uint8(0);

if ~nargin || isempty(daq)
  daq=DaqFind;
end

if nargin < 2 || isempty(NumberOfPorts)
  if strcmp(TheDevices(daq).product(1:6),'USB-16')
    NumberOfPorts = 1;
  else
    NumberOfPorts = 2;
  end
end

% Is this a USB-1024LS or similar?
if ismember(TheDevices(daq).productID, [ 118, 127 ])
    % Yes. Need different reportId and report:
    Is1024LS=1;
    reportId = 0;
    NumberOfPorts = 0; % Hack: Want exactly 1 byte from device...
    TheReport=uint8([0 port 0 0 0 0 0 0]);    
else
    Is1024LS=0;
end

PsychHID('ReceiveReports',daq);
PsychHID('GiveMeReports',daq);

err=PsychHID('SetReport',daq,2,reportId, TheReport); % DIn: Read digital ports

if err.n
    fprintf('DaqDIn SetReport error 0x%s. %s: %s\n',hexstr(err.n),err.name,err.description);
end
[report,err]=PsychHID('GetReport',daq,1,reportId,NumberOfPorts+1); % Get report
if err.n
    fprintf('DaqDIn GetReport error 0x%s. %s: %s\n',hexstr(err.n),err.name,err.description);
end

if ~Is1024LS
    % Default 1x08 devices:
    if length(report)==NumberOfPorts+1 && report(1)==reportId
        % 2 bytes for 1208FS or 1408FS, but only 1 byte for 1608FS
        data=double(report(2:end));
    else
        data=[];
    end
else
    % USB-1024LS: Only 1 byte with the port value:
    data = double(report(1));
end

PsychHID('ReceiveReportsStop',daq);

return;