-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDebugAttribute.m
80 lines (75 loc) · 3.19 KB
/
DebugAttribute.m
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
classdef (Abstract) DebugAttribute < adi.common.Debug
methods (Hidden)
function setDebugAttributeLongLong(obj,attr,value,skipCheck,phydev)
if nargin < 4
phydev = getDev(obj, obj.phyDevName);
skipCheck = false;
end
if nargin < 5
phydev = getDev(obj, obj.phyDevName);
end
if (nargin == 1)
iio_device_debug_attr_write_longlong(obj,phydev, 'initialize',1);
return;
end
status = iio_device_debug_attr_write_longlong(obj,phydev,attr,value);
cstatus(obj,status,['Attribute write failed for : ' attr ' with value ' num2str(value)]);
% Check
if ~skipCheck
[status, rValue] = iio_device_debug_attr_read_longlong(obj,phydev,attr);
cstatus(obj,status,['Error reading attribute: ' attr]);
if (value ~= rValue)
status = -1;
cstatus(obj,status,['Attribute ' attr ' return value ' num2str(rValue) ', expected ' num2str(value)]);
end
end
end
function rValue = getDebugAttributeLongLong(obj,attr)
phydev = getDev(obj, obj.phyDevName);
[status, rValue] = iio_device_debug_attr_read_longlong(obj,phydev,attr);
cstatus(obj,status,['Error reading attribute: ' attr]);
end
function setDebugAttributeBool(obj,attr,value,skipCheck,phydev)
if nargin < 4
phydev = getDev(obj, obj.phyDevName);
skipCheck = false;
end
if nargin < 5
phydev = getDev(obj, obj.phyDevName);
end
if (nargin == 1)
iio_device_debug_attr_write_bool(obj,phydev, 'initialize',1);
return;
end
status = iio_device_debug_attr_write_bool(obj,phydev,attr,value);
cstatus(obj,status,['Attribute write failed for : ' attr]);
% Check (Not implemented yet)
% [status, rValue] = iio_device_debug_attr_read_bool(obj,phydev,attr);
% cstatus(obj,status,['Error reading attribute: ' attr]);
% if value ~= rValue
% status = -1;
% cstatus(obj,status,['Attribute ' attr ' return value ' num2str(rValue) ', expected ' num2str(value)]);
% end
end
function setDebugAttributeRAW(obj,attr,value,phydev)
if nargin < 4
phydev = getDev(obj, obj.phyDevName);
end
status = iio_device_debug_attr_write(obj,phydev,attr,value);
if status < 1
cstatus(obj,status,['Attribute write failed for : ' attr]);
end
end
function data = getDebugAttributeRAW(obj,attr,phydev)
if nargin < 3
phydev = getDev(obj, obj.phyDevName);
end
len = 1024;
[nBytes,data] = iio_device_debug_attr_read(obj,phydev,attr,len);
if nBytes <= 0
status = -1;
cstatus(obj,status,['Attribute read failed for : ' attr]);
end
end
end
end