From 2cd5a0f258f47553badc1905322cefae99d46fe2 Mon Sep 17 00:00:00 2001 From: Cristi Iacob Date: Wed, 8 Apr 2020 14:25:36 +0300 Subject: [PATCH] python: added documentation for iio_readdev and iio_writedev. Documented the methods from iio_readdev.py and iio_writedev.py. Signed-off-by: Cristi Iacob --- bindings/python/examples/iio_readdev.py | 29 ++++++++++++++++++++ bindings/python/examples/iio_writedev.py | 35 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/bindings/python/examples/iio_readdev.py b/bindings/python/examples/iio_readdev.py index 27d19b752..bfd875776 100644 --- a/bindings/python/examples/iio_readdev.py +++ b/bindings/python/examples/iio_readdev.py @@ -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() @@ -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: @@ -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) diff --git a/bindings/python/examples/iio_writedev.py b/bindings/python/examples/iio_writedev.py index a7d048dbe..b35400d0a 100644 --- a/bindings/python/examples/iio_writedev.py +++ b/bindings/python/examples/iio_writedev.py @@ -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() @@ -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: @@ -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