~ubuntu-branches/ubuntu/trusty/psychtoolbox-3/trusty-proposed

« back to all changes in this revision

Viewing changes to Psychtoolbox/PsychHardware/PR670Toolbox/PR670read.m

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-11-19 23:34:50 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20131119233450-f7nf92vb8qavjmk8
Tags: 3.0.11.20131017.dfsg1-3
Upload to unsable since fresh glew has arrived to sid!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function serialData = PR670read
 
2
% PR670read - Read data from the PR-670.
 
3
%
 
4
% Syntax:
 
5
% serialData = PR670read
 
6
%
 
7
% Description:
 
8
% Reads data chars from PR-670 until there is nothing left.  Returns an
 
9
% empty matrix if there is nothing to read.
 
10
 
11
% Output:
 
12
% serialData (1xN char) - Data read from the PR-50.
 
13
 
 
14
global g_serialPort;
 
15
 
 
16
if isempty(g_serialPort)
 
17
        error('Meter has not been initialized.');
 
18
end
 
19
 
 
20
% Look for any data on the serial port.
 
21
serialData = char(IOPort('Read', g_serialPort));
 
22
 
 
23
% If data exists keep reading off the port until there's nothing left.
 
24
if ~isempty(serialData)
 
25
    tmpData = 1;
 
26
    while ~isempty(tmpData)
 
27
        WaitSecs(0.050);
 
28
        tmpData = char(IOPort('Read', g_serialPort));
 
29
        serialData = [serialData, tmpData]; %#ok<AGROW>
 
30
    end
 
31
end