This file is indexed.

/usr/share/doc/libcomedi-dev/html/languagebindings.html is in libcomedi-dev 0.10.2-4build7.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>5.5. Language bindings</title><link rel="stylesheet" type="text/css" href="comedilib.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="index.html" title="Comedi"><link rel="up" href="comedireference.html" title="5.  Comedi reference"><link rel="prev" href="func-ref-comedi-trigger.html" title="comedi_trigger"><link rel="next" href="lowleveldrivers.html" title="5.6.  Kernel drivers"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.5. Language bindings</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="func-ref-comedi-trigger.html">Prev</a> </td><th width="60%" align="center">5. 
		<acronym class="acronym">Comedi</acronym> reference
	</th><td width="20%" align="right"> <a accesskey="n" href="lowleveldrivers.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="languagebindings"></a>5.5. Language bindings</h3></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="languagebindings.html#pythonbindings">5.5.1. Python bindings</a></span></dt></dl></div><p>
    Comedilib is a C library but comes also with bindings for Python, Perl, and Ruby.
    This enables usage of a DAQ device directly from these higher level languages.
    </p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="pythonbindings"></a>5.5.1. Python bindings</h4></div></div></div><p>
        Python bindings are automatically generated by SWIG. So always keep in mind that
        for precise information the <a class="ulink" href="http://www.swig.org/Doc2.0/index.html" target="_top">SWIG documentation</a>
        can come in handy in addition to the <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> documentation.
        </p><p>
        The name of the module is called <code class="filename">comedi</code>. All the C functions, structs, and
        constants are directly available as is. So you can refer directly to the C
        documentation for most of the usage. Note that, as in C, the functions either return the
        successful result or an error code.  Unlike typical Python functions,
        no exceptions are generated on errors (excepted type-checking
        performed by SWIG). For example, to open a <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> device you can write in
        Python:
        </p><pre class="programlisting">
import comedi
device = comedi.comedi_open("/dev/comedi0")
if device is None:
    errno = comedi.comedi_errno()
    print "Error (%d) %s" % (errno, comedi.comedi_strerror(errno))
    return
        </pre><p>
        </p><p>
        There are a few things to be aware of. The SWIG bindings automatically take care
        of converting functions with output parameters to function returning multiple
        values, if the type of the output parameter is simple. For example
        <code class="function">comedi_data_read</code> takes as argument a
        <em class="parameter"><code>lsampl_t *data</code></em> which will contain the data
        read after the function returns. So in C it is used like this:
        </p><pre class="programlisting">
lsampl_t data;
rc = comedi_data_read(device, subdevice, channel, range, aref, &amp;data);
        </pre><p>

        As <em class="parameter"><code>lsampl_t</code></em> is a 32-bit
        <em class="parameter"><code>unsigned int</code></em>, in Python, the function is used like this:
        </p><pre class="programlisting">
rc, data = comedi.comedi_data_read(device, subdevice, channel, range, aref)
        </pre><p>
        </p><p>
        SWIG takes care of converting simple types between Python and C, but does not
        convert more complex types such as arrays or structs. Special Python classes are
        created for these. Moreover, <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> also provides a few macros. These macros
        are available in Python as functions with similar names, but lowercase: <code class="function">comedi.cr_pack</code>,
        <code class="function">comedi.cr_range</code>, etc.
        So to create and modify a command, one can do in Python:
        </p><pre class="programlisting">
cmd = comedi.comedi_cmd_struct()
comedi.comedi_get_cmd_generic_timed(device, subdevice, cmd, nchans, period_ns)
cmd.stop_src = comedi.TRIG_COUNT
cmd.stop_arg = nscans
# create and add the channel list
clist = comedi.chanlist(nchans)
for i, channel in range(nchans):
    clist[i] = comedi.cr_pack(channel, range, comedi.AREF_GROUND)
cmd.chanlist = clist
        </pre><p>
        </p><p>
        One unfortunate consequence is that the objects to represent arrays are as low-level
        as C arrays (i.e., a pointer with an addition). They have no range checking and
        no iterator. In addition, they have to be <code class="function">cast</code> from the Python object to the
        C object. So to create an instruction to call the internal trigger, you would
        write in Python:
        </p><pre class="programlisting">
insn = comedi.comedi_insn_struct()
insn.subdev = subdevice
insn.insn = comedi.INSN_INTTRIG
insn.n = 1
data = comedi.lsampl_array(insn.n)
data[0] = num
insn.data = data.cast()
rc = comedi.comedi_do_insn(device, insn)
        </pre><p>
        </p><p>
        When you need to convert from a raw SWIG object to a proxy
        object, the <code class="function">.frompointer</code> of the Python object can be used. Also note that by default
        when the proxy object is deleted, SWIG frees the memory associated to it. To
        still be able to use the memory, you need to set
        <em class="parameter"><code>.thisown</code></em> to <em class="parameter"><code>False</code></em>.
        </p><p>
        Reading (or writing) a large set of data from a <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> device is done via a file.
        In C, this is done by using a file number, but in Python you need a
        <em class="parameter"><code>File</code></em> object.
        You can get a <em class="parameter"><code>File</code></em> object via
        <code class="function">os.fdopen</code>. For example, to read an array of input data
        from a <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> device into a numpy array, one could do:
        </p><pre class="programlisting">
fileno = comedi.comedi_fileno(device)
file = os.fdopen(fileno, 'r+')
buf = numpy.fromfile(file, dtype=numpy.uint32, count=(nscans * nchans))
        </pre><p>
        </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="func-ref-comedi-trigger.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="comedireference.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="lowleveldrivers.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">comedi_trigger </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.6. 
    Kernel drivers
  </td></tr></table></div></body></html>