File: spoll.m

package info (click to toggle)
octave-instrument-control 0.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 860 kB
  • sloc: cpp: 5,846; makefile: 436; ansic: 18; sh: 4
file content (65 lines) | stat: -rw-r--r-- 1,759 bytes parent folder | download | duplicates (2)
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
## Copyright (C) 2013 Stefan Mahr <dac922@gmx.de>
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn {Function File} {@var{out} =} spoll (@var{obj})
## @deftypefnx {Function File} {[@var{out},@var{statusByte}] =} spoll (@var{obj})
## Serial polls GPIB instruments.
##
## @var{obj} is a GPIB object or a cell array of GPIB objects
##
## @var{out} GPIB objects ready for service
## @var{statusByte} status Byte
##
## @end deftypefn

## TODO: 

function [out,statusByte] = spoll (obj)
#

if (nargin < 1)
  print_usage ();
end

if iscell (obj) && numel (obj) > 0
  if ~all (cellfun (@(x) isa (x,'octave_gpib'),obj))
    error ("obj contains wrong elements");
  end
  
  out = {};
  statusByte = [];
  for i = 1:numel (obj)
    tmp_status = uint8 (__gpib_spoll__ (obj{i}));
    if (bitget (tmp_status,7) == 0)
      out{end+1} = obj{i};
      statusByte(end+1) = tmp_status;
    end
  end
  
  return
  
elseif (!isa (obj,'octave_gpib'))
  error ('spoll: need octave_gpib object');
end

out = [];
statusByte = [];

tmp_status = uint8 (__gpib_spoll__ (obj));
if (bitget (tmp_status,7) == 0)
  out = obj;
  statusByte = tmp_status;
end