-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
matlab bindings: [WIP] Added more tests to cover device and channel a…
…ttributes
- Loading branch information
1 parent
dab52a0
commit 2e7c64c
Showing
10 changed files
with
222 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
function [PhyDevName, ChnId, ChnType, ModType, IsOutput, ... | ||
IsScanElement, AttrsCount, AttrNameGet, AttrNameFind] = ... | ||
iioContextGetChannelInfo(uri, phyDevName, ... | ||
chnName, isOutput, AttrIndex) | ||
|
||
assert(isa(uri,'char') && all(size(uri) <= [1,20])); | ||
assert(isa(phyDevName,'char') && all(size(phyDevName) <= [1,50])); | ||
assert(isa(chnName,'char') && all(size(chnName) <= [1,50])); | ||
assert(isa(isOutput,'logical') && all(size(isOutput) <= [1,1])); | ||
assert(isa(AttrIndex,'uint16') && all(size(AttrIndex) <= [1,1])); | ||
|
||
% Get Context | ||
iioCtxPtr = adi.libiio.context.iio_create_context(uri); | ||
status = -int32(iioCtxPtr==coder.opaque('struct iio_context*', 'NULL')); | ||
if status ~= 0 | ||
PhyDevName = uint8('xyz'); | ||
ChnId = uint8('abc'); | ||
ChnType = uint8('IIO_XYZ'); | ||
ModType = uint8('IIO_MOD_ABC'); | ||
IsOutput = true; | ||
IsScanElement = true; | ||
AttrsCount = 0; | ||
AttrNameGet = uint8('pqr'); | ||
AttrNameFind = uint8('pqr'); | ||
return; | ||
end | ||
|
||
% Get PhyDev Pointer | ||
iioPhyDevPtr = adi.libiio.context.iio_context_find_device(iioCtxPtr, phyDevName); | ||
|
||
% Get Channel Pointer | ||
iioPhyDevChnPtr = adi.libiio.device.iio_device_find_channel(iioPhyDevPtr, chnName, isOutput); | ||
|
||
% Get PhyDev Name Associated with the Channel Pointer | ||
iioPhyDevPtrFromChnPtr = adi.libiio.channel.iio_channel_get_device(iioPhyDevChnPtr); | ||
PhyDevName = adi.libiio.device.iio_device_get_name(iioPhyDevPtrFromChnPtr); | ||
|
||
% Get Channel Id Associated with the Channel Pointer | ||
ChnId = adi.libiio.channel.iio_channel_get_id(iioPhyDevChnPtr); | ||
|
||
% Get Channel Type Associated with the Channel Pointer | ||
ChnType = adi.libiio.channel.iio_channel_get_type(iioPhyDevChnPtr); | ||
|
||
% Get Modifier Type Associated with the Channel Pointer | ||
ModType = adi.libiio.channel.iio_channel_get_modifier(iioPhyDevChnPtr); | ||
|
||
% Is Channel Associated with the Channel Pointer an Output Channel? | ||
IsOutput = adi.libiio.channel.iio_channel_is_output(iioPhyDevChnPtr); | ||
|
||
% Is Channel Associated with the Channel Pointer a Scan Element? | ||
IsScanElement = adi.libiio.channel.iio_channel_is_scan_element(iioPhyDevChnPtr); | ||
|
||
% Get Channel Attributes Count Associated with the Channel Pointer | ||
AttrsCount = adi.libiio.channel.iio_channel_get_attrs_count(iioPhyDevChnPtr); | ||
|
||
AttrPtrGet = adi.libiio.channel.iio_channel_get_attr(iioPhyDevChnPtr, AttrIndex); | ||
AttrNameGet = adi.libiio.attribute.iio_attr_get_name(AttrPtrGet); | ||
|
||
AttrPtrFind = adi.libiio.channel.iio_channel_find_attr(iioPhyDevChnPtr, AttrNameGet); | ||
AttrNameFind = adi.libiio.attribute.iio_attr_get_name(AttrPtrFind); | ||
|
||
% Destroy Context | ||
adi.libiio.context.iio_context_destroy(iioCtxPtr); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function [PhyDevName, DevId] = ... | ||
iioContextGetDeviceInfo(uri, phyDevName) | ||
|
||
assert(isa(uri,'char') && all(size(uri) <= [1,20])); | ||
assert(isa(phyDevName,'char') && all(size(phyDevName) <= [1,50])); | ||
|
||
% Get Context | ||
iioCtxPtr = adi.libiio.context.iio_create_context(uri); | ||
status = -int32(iioCtxPtr==coder.opaque('struct iio_context*', 'NULL')); | ||
if status ~= 0 | ||
PhyDevName = uint8('xyz'); | ||
DevId = uint8('abc'); | ||
return; | ||
end | ||
|
||
% Get PhyDev Pointer | ||
iioPhyDevPtr = adi.libiio.context.iio_context_find_device(iioCtxPtr, phyDevName); | ||
|
||
% Get PhyDev Name | ||
PhyDevName = adi.libiio.device.iio_device_get_name(iioPhyDevPtr); | ||
|
||
% Get Device Id Associated with the PhyDev Pointer | ||
DevId = adi.libiio.device.iio_device_get_id(iioPhyDevPtr); | ||
|
||
% Destroy Context | ||
adi.libiio.context.iio_context_destroy(iioCtxPtr); | ||
end |
45 changes: 45 additions & 0 deletions
45
bindings/matlab/test/codegen/iioReadChannelAttributeBool.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function [status, chnDataFormatPtr, ... | ||
attrName, value] = iioReadChannelAttributeBool(... | ||
uri, ... | ||
phyDevName, ... | ||
chnName, ... | ||
isOutput, ... | ||
chnAttrName) | ||
|
||
assert(isa(uri,'char') && all(size(uri) <= [1,20])); | ||
assert(isa(phyDevName,'char') && all(size(phyDevName) <= [1,50])); | ||
assert(isa(chnName,'char') && all(size(chnName) <= [1,50])); | ||
assert(isa(isOutput,'logical') && all(size(isOutput) <= [1,1])); | ||
assert(isa(chnAttrName,'char') && all(size(chnAttrName) <= [1,50])); | ||
|
||
% Get Context | ||
iioCtxPtr = adi.libiio.context.iio_create_context(uri); | ||
status = -int32(iioCtxPtr==coder.opaque('struct iio_context*', 'NULL')); | ||
if status ~= 0 | ||
chnDataFormatPtr = libpointer; | ||
attrName = char(zeros(1,1,'uint8')); | ||
value = bool(0); | ||
return; | ||
end | ||
|
||
% Get PhyDev Pointer | ||
iioPhyDevPtr = adi.libiio.context.iio_context_find_device(iioCtxPtr, phyDevName); | ||
|
||
% Get Channel Pointer | ||
iioPhyDevChnPtr = adi.libiio.device.iio_device_find_channel(iioPhyDevPtr, chnName, isOutput); | ||
|
||
% Get Channel Pointer | ||
chnDataFormatPtr = adi.libiio.lowlevel.iio_channel_get_data_format(iioPhyDevChnPtr); | ||
|
||
% Get Channel Attribute Pointer | ||
iioPhyDevChnAttrPtr = adi.libiio.channel.iio_channel_find_attr(iioPhyDevChnPtr, chnAttrName); | ||
|
||
% get Attribute Name | ||
attrName = adi.libiio.attribute.iio_attr_get_name(iioPhyDevChnAttrPtr); | ||
|
||
% Read Attribute | ||
[status, value] = adi.libiio.attribute.iio_attr_read_bool(iioPhyDevChnAttrPtr); | ||
|
||
% Destroy Context | ||
adi.libiio.context.iio_context_destroy(iioCtxPtr); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
bindings/matlab/test/codegen/iioReadDeviceAttributeLonglong.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
bindings/matlab/test/codegen/iioWriteChannelAttributeBool.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
function status = iioWriteChannelAttributeBool(uri, ... | ||
phyDevName, ... | ||
chnName, ... | ||
isOutput, ... | ||
chnAttrName, ... | ||
value) | ||
|
||
assert(isa(uri,'char') && all(size(uri) <= [1,20])); | ||
assert(isa(phyDevName,'char') && all(size(phyDevName) <= [1,50])); | ||
assert(isa(chnName,'char') && all(size(chnName) <= [1,50])); | ||
assert(isa(isOutput,'logical') && all(size(isOutput) <= [1,1])); | ||
assert(isa(chnAttrName,'char') && all(size(chnAttrName) <= [1,50])); | ||
assert(isa(value,'logical') && isreal(value) && all(size(value) == [1,1])); | ||
|
||
% Get Context | ||
iioCtxPtr = adi.libiio.context.iio_create_context(uri); | ||
status = -int32(iioCtxPtr==coder.opaque('struct iio_context*', 'NULL')); | ||
if status ~= 0 | ||
return; | ||
end | ||
|
||
% Get PhyDev Pointer | ||
iioPhyDevPtr = adi.libiio.context.iio_context_find_device(iioCtxPtr, phyDevName); | ||
|
||
% Get Channel Pointer | ||
iioPhyDevChnPtr = adi.libiio.device.iio_device_find_channel(iioPhyDevPtr, chnName, isOutput); | ||
|
||
% Get Channel Attribute Pointer | ||
iioPhyDevChnAttrPtr = adi.libiio.channel.iio_channel_find_attr(iioPhyDevChnPtr, chnAttrName); | ||
|
||
% Write Attribute | ||
status = adi.libiio.attribute.iio_attr_write_bool(iioPhyDevChnAttrPtr, value); | ||
|
||
% Destroy Context | ||
adi.libiio.context.iio_context_destroy(iioCtxPtr); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
bindings/matlab/test/codegen/iioWriteDeviceAttributeLonglong.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters