File: examples.rst

package info (click to toggle)
libiio 0.26-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,832 kB
  • sloc: ansic: 21,880; python: 1,844; cs: 1,232; sh: 1,062; cpp: 688; yacc: 441; xml: 192; lex: 172; makefile: 40
file content (31 lines) | stat: -rw-r--r-- 601 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Examples
==================


Complete Application Examples
------------------------------
.. toctree::
   iio_readdev
   iio_writedev
   iio_attr
   iio_info


Code Snippets
-----------------------------

Scan contexts and list channels of each device

.. code-block:: python

 import iio

 for ctxname in iio.scan_contexts():
     ctx = iio.Context(ctxname)
     for dev in ctx.devices:
         if dev.channels:
             for chan in dev.channels:
                 print("{} - {} - {}".format(ctxname, dev.name, chan._id))
         else:
             print("{} - {}".format(ctxname, dev.name))