Skip to content

Commit

Permalink
matlab bindings: validate input parameters where applicable
Browse files Browse the repository at this point in the history
Signed-off-by: Pagadarai <[email protected]>
  • Loading branch information
SrikanthPagadarai committed Sep 6, 2024
1 parent e7e30da commit 320439c
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 294 deletions.
32 changes: 16 additions & 16 deletions bindings/matlab/attribute.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
% Read the content of the given attribute
%
% Args:
% attrPtr: A pointer to an iio_attr structure
% attrPtr: A pointer to an iio_attr structure.
% dstPtr: A pointer to the memory area where the read data
% will be stored
% len: The available length of the memory area, in bytes
% will be stored.
% len: The available length of the memory area, in bytes.
%
% Returns:
% On success, the number of bytes written to the buffer
% On error, a negative errno code is returned
% On success, the number of bytes written to the buffer.
% On error, a negative errno code is returned.
%
% libiio function: iio_attr_read_raw
validateattributes(len, { 'double','single' }, ...
Expand All @@ -30,13 +30,13 @@
% Read the content of the given attribute
%
% Args:
% attrPtr: A pointer to an iio_attr structure
% srcPtr: A pointer to the data to be written
% len: The number of bytes that should be written
% attrPtr: A pointer to an iio_attr structure.
% srcPtr: A pointer to the data to be written.
% len: The number of bytes that should be written.
%
% Returns:
% On success, the number of bytes written
% On error, a negative errno code is returned
% On success, the number of bytes written.
% On error, a negative errno code is returned.
%
% libiio function: iio_attr_write_raw
validateattributes(len, { 'double','single' }, ...
Expand All @@ -54,10 +54,10 @@
% Retrieve the name of an attribute
%
% Args:
% attrPtr: A pointer to an iio_attr structure
% attrPtr: A pointer to an iio_attr structure.
%
% Returns:
% A pointer to a static NULL-terminated string
% A pointer to a static NULL-terminated string.
%
% libiio function: iio_attr_get_name

Expand All @@ -72,10 +72,10 @@
% Retrieve the filename of an attribute
%
% Args:
% attrPtr: A pointer to an iio_attr structure
% attrPtr: A pointer to an iio_attr structure.
%
% Returns:
% A pointer to a static NULL-terminated string
% A pointer to a static NULL-terminated string.
%
% libiio function: iio_attr_get_filename

Expand All @@ -90,10 +90,10 @@
% Retrieve the static value of an attribute
%
% Args:
% attrPtr: A pointer to an iio_attr structure
% attrPtr: A pointer to an iio_attr structure.
%
% Returns:
% On success, a pointer to a static NULL-terminated string
% On success, a pointer to a static NULL-terminated string.
% If the attribute does not have a static value, NULL is returned.
%
% libiio function: iio_attr_get_filename
Expand Down
56 changes: 30 additions & 26 deletions bindings/matlab/block.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
% Create a data block for the given buffer
%
% Args:
% buffPtr: A pointer to an iio_buffer structure
% size: The size of the block to create, in bytes
% buffPtr: A pointer to an iio_buffer structure.
% size: The size of the block to create, in bytes.
%
% Returns:
% On success, a pointer to an iio_block structure
% On failure, a pointer-encoded error is returned
% On success, a pointer to an iio_block structure.
% On failure, a pointer-encoded error is returned.
%
% libiio function: iio_buffer_create_block

Expand All @@ -26,7 +26,7 @@ function iio_block_destroy(blockPtr)
% Destroy the given block
%
% Args:
% blockPtr: A pointer to an iio_block structure
% blockPtr: A pointer to an iio_block structure.
%
% libiio function: iio_block_destroy

Expand All @@ -41,10 +41,10 @@ function iio_block_destroy(blockPtr)
% Get the start address of the block
%
% Args:
% blockPtr: A pointer to an iio_block structure
% blockPtr: A pointer to an iio_block structure.
%
% Returns:
% A pointer corresponding to the start address of the block
% A pointer corresponding to the start address of the block.
%
% libiio function: iio_block_start

Expand All @@ -60,8 +60,8 @@ function iio_block_destroy(blockPtr)
% Find the first sample of a channel in a block
%
% Args:
% blockPtr: A pointer to an iio_block structure
% chnPtr: A pointer to an iio_channel structure
% blockPtr: A pointer to an iio_block structure.
% chnPtr: A pointer to an iio_channel structure.
%
% Returns:
% A pointer to the first sample found, or to the end of the
Expand Down Expand Up @@ -97,11 +97,11 @@ function iio_block_destroy(blockPtr)
% Get the address after the last sample in a block
%
% Args:
% blockPtr: A pointer to an iio_block structure
% blockPtr: A pointer to an iio_block structure.
%
% Returns:
% A pointer corresponding to the address that follows the
% last sample present in the buffer
% last sample present in the buffer.
%
% libiio function: iio_block_end

Expand All @@ -117,21 +117,23 @@ function iio_block_destroy(blockPtr)
% Call the supplied callback for each sample found in a block
%
% Args:
% blockPtr: A pointer to an iio_block structure
% blockPtr: A pointer to an iio_block structure.
% maskPtr: A pointer to the iio_channels_mask structure that
% represents the list of channels for which we want samples
% callback: A pointer to a function to call for each sample found
% dataPtr: A user-specified pointer that will be passed to the callback
% represents the list of channels for which we want samples.
% callback: A pointer to a function to call for each sample
% found.
% dataPtr: A user-specified pointer that will be passed to
% the callback.
%
% Returns:
% Number of bytes processed
%
% NOTE:
% The callback receives four arguments:
% A pointer to the iio_channel structure corresponding to the sample,
% A pointer to the sample itself,
% The length of the sample in bytes,
% The user-specified pointer passed to iio_block_foreach_sample.
% a pointer to the iio_channel structure corresponding to the sample,
% a pointer to the sample itself,
% the length of the sample in bytes,
% the user-specified pointer passed to iio_block_foreach_sample.
%
% libiio function: iio_block_foreach_sample
Expand Down Expand Up @@ -192,12 +194,12 @@ function iio_block_destroy(blockPtr)
end
end

function status = iio_block_dequeue(blockPtr, nonblock)
function status = iio_block_dequeue(blockPtr, nonBlock)
% Dequeue the given iio_block from the buffer's queue
%
% Args:
% blockPtr: A pointer to an iio_block structure
% nonblock: if True, the operation won't block and return
% blockPtr: A pointer to an iio_block structure.
% nonBlock: if True, the operation won't block and return
% -EBUSY if the block is not ready for dequeue.
%
% Returns:
Expand All @@ -206,21 +208,23 @@ function iio_block_destroy(blockPtr)
%
% libiio function: iio_block_dequeue

validateattributes(nonBlock, { 'logical' }, {'scalar', 'nonempty'});

if coder.target('MATLAB')
status = adi.libiio.helpers.calllibADI('iio_block_dequeue', blockPtr, nonblock);
status = adi.libiio.helpers.calllibADI('iio_block_dequeue', blockPtr, nonBlock);
else
status = coder.ceval('iio_block_dequeue', blockPtr, nonblock);
status = coder.ceval('iio_block_dequeue', blockPtr, nonBlock);
end
end

function buffPtr = iio_block_get_buffer(blockPtr)
% Retrieve a pointer to the iio_buffer structure
%
% Args:
% blockPtr: A pointer to an iio_block structure
% blockPtr: A pointer to an iio_block structure.
%
% Returns:
% A pointer to an iio_buffer structure
% A pointer to an iio_buffer structure.
%
% libiio function: iio_block_get_buffer

Expand Down
Loading

0 comments on commit 320439c

Please sign in to comment.