-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d47b5c
commit 7c813f0
Showing
18 changed files
with
126 additions
and
16 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,24 @@ | ||
tic; | ||
functionNames = {... | ||
'iioReadDevAttrLonglong.m',... | ||
'iioWriteDevAttrLonglong.m',... | ||
}; | ||
cfg = coder.config('dll'); | ||
cfg.TargetLang = 'C'; | ||
cfg.FilePartitionMethod = 'SingleFile'; | ||
cfg.RuntimeChecks = true; | ||
cfg.GenCodeOnly = true; | ||
cfg.EnableAutoExtrinsicCalls = false; | ||
cfg.MATLABSourceComments = true; | ||
% cfg.GenerateReport = true; | ||
% cfg.LaunchReport = true; | ||
cfg.HighlightPotentialDataTypeIssues = true; | ||
|
||
outputLIBName = 'mlibiio'; | ||
cfg.HardwareImplementation.TargetHWDeviceType = 'Intel->x86-64 (Linux 64)'; %'Generic->32-bit Embedded Processor'; | ||
result = codegen('-config','cfg',functionNames{:},'-O ','disable:openmp','-o',outputLIBName); | ||
% result = codegen('-config','cfg',functionNames{:},... | ||
% '-args',coder.opaque('const struct iio_context_params *'),... | ||
% '-O ','disable:openmp','-o',outputLIBName); | ||
assert(result.summary.passed) | ||
toc; |
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,28 @@ | ||
function [status, attrName, value] = iioReadDevAttrLonglong(uri, phyDevName, devAttrName) | ||
assert(isa(uri,'char') && all(size(uri) <= [1,20])); | ||
assert(isa(phyDevName,'char') && all(size(phyDevName) <= [1,20])); | ||
assert(isa(devAttrName,'char') && all(size(devAttrName) <= [1,20])); | ||
|
||
% Get Context | ||
iioCtxPtr = adi.libiio.context.iio_create_context(uri); | ||
status = -int32(iioCtxPtr==coder.opaque('struct iio_context*', 'NULL')); | ||
if status ~= 0 | ||
value = int64(0); | ||
return; | ||
end | ||
|
||
% Get PhyDev Pointer | ||
iioPhyDevPtr = adi.libiio.context.iio_context_find_device(iioCtxPtr, phyDevName); | ||
|
||
% Get Attribute Pointer | ||
iioPhyDevAttrPtr = adi.libiio.device.iio_device_find_attr(iioPhyDevPtr, devAttrName); | ||
|
||
% get Attribute Name | ||
attrName = adi.libiio.attribute.iio_attr_get_name(iioPhyDevAttrPtr); | ||
|
||
% Read Attribute | ||
[status, value] = adi.libiio.attribute.iio_attr_read_longlong(iioPhyDevAttrPtr); | ||
|
||
% 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,25 @@ | ||
function status = iioWriteDevAttrLonglong(uri, phyDevName, devAttrName, value) | ||
assert(isa(uri,'char') && all(size(uri) <= [1,20])); | ||
assert(isa(phyDevName,'char') && all(size(phyDevName) <= [1,20])); | ||
assert(isa(devAttrName,'char') && all(size(devAttrName) <= [1,20])); | ||
assert(isa(value,'int64') && 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 Attribute Pointer | ||
iioPhyDevAttrPtr = adi.libiio.device.iio_device_find_attr(iioPhyDevPtr, devAttrName); | ||
|
||
% Write Attribute | ||
status = adi.libiio.attribute.iio_attr_write_longlong(iioPhyDevAttrPtr, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
clc; | ||
clear; | ||
|
||
mfilepath = fileparts(mfilename('fullpath')); | ||
cd(mfilepath); | ||
addpath(strcat("..", filesep, "codegen")); | ||
suite = testsuite("test"); | ||
import matlab.unittest.plugins.CodeCoveragePlugin | ||
import matlab.unittest.plugins.codecoverage.CoverageReport | ||
runner = testrunner("textoutput"); | ||
reportFormat = CoverageReport("coverageReport"); | ||
p = CodeCoveragePlugin.forFolder(strcat("..", filesep, "+adi", filesep, "+libiio"),"Producing",reportFormat); | ||
runner.addPlugin(p); | ||
results = runner.run(suite); |
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,35 @@ | ||
classdef testDeviceAttributes < matlab.unittest.TestCase | ||
properties(TestParameter) | ||
uri = {'ip:pluto.local'} | ||
phyDev = {'ad9361-phy'} | ||
devAttr = {'xo_correction'} | ||
value = {int64(40000005)} | ||
end | ||
|
||
methods(Test) | ||
function testPlutoDeviceAttributes(testCase) | ||
% Read from Device Attribute | ||
[status, attrName, result] = iioReadDevAttrLonglong(testCase.uri{1}, testCase.phyDev{1}, testCase.devAttr{1}); | ||
assert(strcmp(attrName, testCase.devAttr{1})); | ||
assert(status==0); | ||
OrigValue = result; | ||
|
||
% Write to Device Attribute and Verify Value is Written | ||
status = iioWriteDevAttrLonglong(testCase.uri{1}, testCase.phyDev{1}, testCase.devAttr{1}, testCase.value{1}); | ||
assert(status==0); | ||
[status, attrName, result] = iioReadDevAttrLonglong(testCase.uri{1}, testCase.phyDev{1}, testCase.devAttr{1}); | ||
assert(status==0); | ||
assert(result==testCase.value{1}); | ||
|
||
% Write Original Value to Device Attribute and Verify Value is Written | ||
status = iioWriteDevAttrLonglong(testCase.uri{1}, testCase.phyDev{1}, testCase.devAttr{1}, OrigValue); | ||
assert(status==0); | ||
[status, attrName, result] = iioReadDevAttrLonglong(testCase.uri{1}, testCase.phyDev{1}, testCase.devAttr{1}); | ||
assert(status==0); | ||
assert(result==OrigValue); | ||
|
||
% Unload Library | ||
adi.libiio.helpers.unloadLibIIO(); | ||
end | ||
end | ||
end |