File: DaqGetStatus.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (59 lines) | stat: -rw-r--r-- 2,105 bytes parent folder | download | duplicates (7)
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
function status=DaqGetStatus(daq)
% status=DaqGetStatus(DeviceIndex)
% USB-1208FS: Retrieve device status.
% "status.master" =0 sync slave; 1 sync master.
% "status.rising" =0 trigger on falling edge; 1 trigger on rising edge.
% "status.program" =1 program memory update mode.
% "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.
% See also Daq, DaqFunctions, DaqPins, DaqTest, PsychHIDTest.

% 4/15/05 dgp Wrote it.
% 12/17/07  mpr allowed empty input to have meaning
% 1/11/08   mpr swept through trying to improve consistency across daq
%                 functions

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

err=PsychHID('ReceiveReports',daq);
err=PsychHID('ReceiveReportsStop',daq);
err=PsychHID('GiveMeReports',daq);
err=PsychHID('SetReport',daq,2,68,uint8(68)); % GetStatus
if err.n
    fprintf('GetStatus SetReport error 0x%s. %s: %s\n',hexstr(err.n),err.name,err.description);
end
if 0
    [report,err]=PsychHID('GetReport',daq,1,68,3); % GetStatus
    if err.n
        fprintf('DaqGetStatus GetReport error 0x%s. %s: %s\n',hexstr(err.n),err.name,err.description);
    end
else
    err=PsychHID('ReceiveReports',daq);
    if err.n
        fprintf('DaqGetStatus ReceiveReports error 0x%s. %s: %s\n',hexstr(err.n),err.name,err.description);
    end
    [reports,err]=PsychHID('GiveMeReports',daq);
    if err.n
        fprintf('DaqGetStatus GiveMeReports error 0x%s. %s: %s\n',hexstr(err.n),err.name,err.description);
    end
    report=[];
    for i=1:length(reports)
        if reports(i).report(1)==68
            report=reports(1).report;
        end
    end
end
if length(report)==3 && report(1)==68
    % 16 bits, only 3 of which are assigned.
    status.master=bitget(report(2),1); % 0 sync slave; 1 sync master.
    status.rising=bitget(report(2),2); % 0 trigger on falling edge; 1 trigger on rising edge
    status.program=bitget(report(3),8); % 1 program memory update mode.
else
    status=[];
end
err=PsychHID('ReceiveReportsStop',daq);

return;