Skip to content

Commit

Permalink
python: added documentation for iio_readdev and iio_writedev.
Browse files Browse the repository at this point in the history
Documented the methods from iio_readdev.py and iio_writedev.py.

Signed-off-by: Cristi Iacob <[email protected]>
  • Loading branch information
cristi-iacob committed Apr 9, 2020
1 parent d28dd36 commit 2cd5a0f
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
29 changes: 29 additions & 0 deletions bindings/python/examples/iio_readdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@


def read_arguments():
"""
Method for reading the command line parameters and setting the corresponding variables.
"""
global arg_ip, arg_uri, scan_for_context, buffer_size, num_samples, timeout, device_name, channels

args = parser.parse_args()
Expand Down Expand Up @@ -76,6 +79,20 @@ def read_arguments():


def create_context(scan_for_context, arg_uri, arg_ip):
"""
Method for creating the corresponding context.
parameters:
scan_for_context: type=bool
Scan for available contexts and if only one is available use it.
arg_uri: type=string
The URI on which the program should look for a Context.
arg_ip: type=string
The IP on which the program should look for a Network Context.
returns: type:iio.Context
The resulted context.
"""
ctx = None

try:
Expand Down Expand Up @@ -113,6 +130,18 @@ def keyboard_interrupt_handler(signal, frame):


def read_data(buffer, num_samples):
"""
Method for reading data from the buffer.
parameters:
buffer: type=iio.Buffer
Current buffer.
num_samples: type=int
Number of samples to capture, 0 = infinite. Default is 0.
returns: type=None
Reads data from buffer.
"""
if buffer is None:
sys.stderr.write('Unable to create buffer!\n')
exit(1)
Expand Down
35 changes: 35 additions & 0 deletions bindings/python/examples/iio_writedev.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@


def read_arguments():
"""
Method for reading the command line parameters and setting the corresponding variables.
"""
global arg_ip, arg_uri, scan_for_context, buffer_size, num_samples, timeout, cyclic, device_name, channels

args = parser.parse_args()
Expand Down Expand Up @@ -83,6 +86,20 @@ def read_arguments():


def create_context(scan_for_context, arg_uri, arg_ip):
"""
Method for creating the corresponding context.
parameters:
scan_for_context: type=bool
Scan for available contexts and if only one is available use it.
arg_uri: type=string
The URI on which the program should look for a Context.
arg_ip: type=string
The IP on which the program should look for a Network Context.
returns: type:iio.Context
The resulted context.
"""
ctx = None

try:
Expand Down Expand Up @@ -120,6 +137,24 @@ def keyboard_interrupt_handler(signal, frame):


def write_data(dev, buffer, num_samples, buffer_size, cyclic):
"""
Method for pushing data to the buffer.
parameters:
dev: type=iio.Device
Current device.
buffer: type=iio.Buffer
Current buffer.
num_samples: type=int
Number of samples to capture, 0 = infinite. Default is 0.
buffer_size: type=int
Size of the capture buffer. Default is 256.
cyclic: type=bool
Use cyclic buffer mode.
returns: type=None
Push data to buffer.
"""
app_running = True
num_samples_set = num_samples > 0

Expand Down

0 comments on commit 2cd5a0f

Please sign in to comment.