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
96
97
98
99
|
classdef lgpib
properties
handle
end
methods
function [obj] = lgpib(name)
if exist('gpib_function')~=3
lgpib.Compile();
end
obj.handle = gpib_function('ibfind',name);
if (obj.handle<0)
fprintf('lgpib Error: Could not open device ''%s''\n',name);
end
end
function [status,write_count] = write(obj,message)
[gpib_status,gpib_count] = gpib_function('ibwrt',obj.handle,message);
if nargout>=1
status = gpib_status;
end
if nargout>=2
write_count=gpib_count;
end
end
function [reply,status,read_count] = read(obj,l)
if nargin==1
l=8192;
end
[gpib_reply,gpib_status,gpib_count] = gpib_function('ibrdl',obj.handle,l);
reply = gpib_reply;
if nargout>=2
status = gpib_status;
end
if nargout>=3
write_count=gpib_count;
end
end
function [reply] = query(obj,message,l)
if nargin==2
l = 8192;
end
obj.write(message);
reply = obj.read(l);
end
function [reply] = set_timeout(obj,tmo)
reply = gpib_function('ibtmo',obj.handle,tmo);
end
function [reply] = serial_poll(obj)
reply = gpib_function('ibrsp',obj.handle);
end
function [status] = get_status(obj)
status = gpib_function('ibsta',obj.handle);
end
function [cntl] = get_counter(obj)
status = gpib_function('ibcntl',obj.handle);
end
function [status] = clear(obj)
status = gpib_function('ibclr',obj.handle);
end
function [status] = interface_clear(obj)
status = obj.clear();
end
end
methods (Static)
function Compile
fprintf('Compiling gpib_function.c\n');
mex gpib_function.c dispatch.c -lgpib
end
end
end
|