2008-01-24 01:32:41 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
|
|
|
|
<!ENTITY % comedilib_entities SYSTEM "comedilib.ent">
|
|
|
|
%comedilib_entities;
|
|
|
|
]>
|
|
|
|
|
|
|
|
<section id="comedireference" xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
|
|
<title>
|
2008-02-11 15:50:36 +00:00
|
|
|
&comedi; reference
|
2008-01-24 01:32:41 +00:00
|
|
|
</title>
|
2002-01-21 11:15:31 +00:00
|
|
|
|
2003-07-07 22:34:18 +00:00
|
|
|
<section id="comedi-comedilib-h">
|
|
|
|
<title>
|
|
|
|
Headerfiles: <filename>comedi.h</filename> and <filename>comedilib.h</filename>
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
All <link linkend="writingprograms">application programs</link> must
|
|
|
|
include the header file <filename>comedilib.h</filename>. (This file
|
|
|
|
itself includes <filename>comedi.h</filename>.) They contain the full
|
|
|
|
interface of &comedi;: defines, function prototypes, data structures.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
The following Sections give more details.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="constantsmacros">
|
2002-01-21 11:15:31 +00:00
|
|
|
<title>
|
2008-02-11 15:50:36 +00:00
|
|
|
Constants and macros
|
2002-01-21 11:15:31 +00:00
|
|
|
</title>
|
|
|
|
|
|
|
|
<section id="ref-macro-CR-PACK">
|
|
|
|
<title>
|
|
|
|
CR_PACK
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
<function>CR_PACK<parameter>chan</parameter><parameter>rng</parameter>
|
|
|
|
<parameter>aref</parameter></function> is used to initialize the elements of the
|
2003-07-07 22:34:18 +00:00
|
|
|
<parameter>chanlist</parameter> array in the
|
2012-05-04 18:10:55 +01:00
|
|
|
<type><link linkend="ref-type-comedi-cmd">comedi_cmd</link></type> data structure,
|
2006-09-08 19:40:15 +00:00
|
|
|
and the <parameter>chanspec</parameter> member of the
|
2012-05-04 18:10:55 +01:00
|
|
|
<type><link linkend="ref-type-comedi-insn">comedi_insn</link></type> structure.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
2003-07-07 22:34:18 +00:00
|
|
|
<programlisting>
|
|
|
|
<![CDATA[
|
2006-09-08 19:40:15 +00:00
|
|
|
#define CR_PACK(chan,rng,aref) ( (((aref)&0x3)<<24) | (((rng)&0xff)<<16) | (chan) )
|
2003-07-07 22:34:18 +00:00
|
|
|
]]>
|
|
|
|
</programlisting>
|
2002-01-21 11:15:31 +00:00
|
|
|
<para>
|
2003-07-07 22:34:18 +00:00
|
|
|
The <parameter>chan</parameter> argument is the channel you wish to
|
|
|
|
use, with the channel numbering starting at zero.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2003-07-07 22:34:18 +00:00
|
|
|
The range <parameter>rng</parameter> is an index, starting at zero,
|
2006-09-08 19:40:15 +00:00
|
|
|
whose meaning is device dependent. The
|
2012-05-04 18:10:55 +01:00
|
|
|
<function><link linkend="func-ref-comedi-get-n-ranges">comedi_get_n_ranges</link></function>
|
2003-07-07 22:34:18 +00:00
|
|
|
and
|
2012-05-04 18:10:55 +01:00
|
|
|
<function><link linkend="func-ref-comedi-get-range">comedi_get_range</link></function>
|
2003-07-07 22:34:18 +00:00
|
|
|
functions are useful in discovering information about the available
|
|
|
|
ranges.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2003-07-07 22:34:18 +00:00
|
|
|
The <parameter>aref</parameter> argument indicates what reference you
|
|
|
|
want the device to use. It can be any of the following:
|
2002-01-21 11:15:31 +00:00
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
2012-05-04 18:10:55 +01:00
|
|
|
<term><constant>AREF_GROUND</constant> <anchor id="aref-ground"/> </term>
|
2002-01-21 11:15:31 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-07-07 22:34:18 +00:00
|
|
|
is for inputs/outputs referenced to ground.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
2012-05-04 18:10:55 +01:00
|
|
|
<term><constant>AREF_COMMON</constant> <anchor id="aref-common"/> </term>
|
2002-01-21 11:15:31 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-07-11 22:53:40 +00:00
|
|
|
is for a <quote>common</quote> reference (the low inputs of all the
|
2003-07-07 22:34:18 +00:00
|
|
|
channels are tied together, but are isolated from ground).
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
2012-05-04 18:10:55 +01:00
|
|
|
<term><constant>AREF_DIFF</constant> <anchor id="aref-diff"/> </term>
|
2002-01-21 11:15:31 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-07-07 22:34:18 +00:00
|
|
|
is for differential inputs/outputs.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
2012-05-04 18:10:55 +01:00
|
|
|
<term><constant>AREF_OTHER</constant> <anchor id="aref-other"/> </term>
|
2002-01-21 11:15:31 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-07-07 22:34:18 +00:00
|
|
|
is for any reference that does not fit into the above categories.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
Particular drivers may or may not use the AREF flags. If they are
|
|
|
|
not supported, they are silently ignored.
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
2012-05-09 17:12:23 +01:00
|
|
|
<section id="ref-macro-CR-PACK-FLAGS">
|
|
|
|
<title>
|
|
|
|
CR_PACK_FLAGS
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
<function>CR_PACK_FLAGS<parameter>chan</parameter><parameter>range</parameter>
|
|
|
|
<parameter>aref</parameter><parameter>flags</parameter></function>
|
|
|
|
is similar to
|
|
|
|
<function><link linkend="ref-macro-CR-PACK">CR_PACK</link></function>
|
|
|
|
but can be used to combine one or more flag bits (bitwise-ORed together in
|
|
|
|
the <parameter class="function">flags</parameter> parameter) with the other
|
|
|
|
parameters.
|
|
|
|
<programlisting>
|
|
|
|
<![CDATA[
|
|
|
|
#define CR_PACK_FLAGS(chan, range, aref, flags) \
|
|
|
|
(CR_PACK(chan, range, aref) | ((flags) & CR_FLAGS_MASK))
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
Depending on context, the
|
|
|
|
<parameter class="function">chan</parameter> parameter might not be a channel;
|
|
|
|
it could be a trigger source, clock source, gate source etc. (in which case,
|
|
|
|
the <parameter class="function">range</parameter> and
|
|
|
|
<parameter class="function">aref</parameter> parameters would probably be set
|
|
|
|
to <literal>0</literal>), and the flags would modify the source in some
|
|
|
|
device-dependant way.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The following flag values are defined:
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>CR_ALT_FILTER</constant><anchor id="cr-alt-filter"/></term>
|
|
|
|
<term><constant>CR_DITHER</constant></term>
|
|
|
|
<term><constant>CR_DEGLITCH</constant></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
(all the same) specify that some sort of filtering is to be done
|
|
|
|
on the channel, trigger source, etc.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>CR_ALT_SOURCE</constant><anchor id="cr-alt-source"/></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
specifies that some alternate source is to be used for the channel
|
|
|
|
(usually a calibration source).
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>CR_EDGE</constant><anchor id="cr-edge"/></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
is usually combined with a trigger source number to specify that the
|
|
|
|
trigger source is edge-triggered if the hardware and driver supports
|
|
|
|
both edge-triggering and level-triggering. If both are supported,
|
|
|
|
not asserting this flag specifies level-triggering.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>CR_INVERT</constant><anchor id="cr-invert"/></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
specifies that the trigger source, gate source, etc. is to be inverted.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
2002-01-21 11:15:31 +00:00
|
|
|
<section id="ref-macro-RANGE-LENGTH">
|
|
|
|
<title>
|
|
|
|
RANGE_LENGTH (deprecated)
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Rangetype values are library-internal tokens that represent an
|
|
|
|
array of range information structures. These numbers are primarily
|
|
|
|
used for communication between the kernel and library.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
The <function>RANGE_LENGTH<parameter>rangetype</parameter></function>
|
|
|
|
macro returns the length of the array that is
|
|
|
|
specified by the <parameter>rangetype</parameter> token.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
The <function>RANGE_LENGTH</function> macro is deprecated, and should not be used in
|
2002-01-21 11:15:31 +00:00
|
|
|
new applications. It is scheduled to be removed from the header
|
|
|
|
file at version 1.0. Binary compatibility may be broken for version
|
|
|
|
1.1.
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
2006-09-08 19:40:15 +00:00
|
|
|
<section id="ref-enum-comedi-conversion-direction">
|
|
|
|
<title>
|
|
|
|
enum comedi_conversion_direction
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
<programlisting>
|
|
|
|
enum comedi_conversion_direction
|
|
|
|
{
|
|
|
|
COMEDI_TO_PHYSICAL,
|
|
|
|
COMEDI_FROM_PHYSICAL
|
|
|
|
};
|
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
A <type>comedi_conversion_direction</type> is used to choose between converting data
|
|
|
|
from Comedi's integer sample values to a physical value
|
|
|
|
(<constant>COMEDI_TO_PHYSICAL</constant>),
|
|
|
|
and converting from a physical value to Comedi's integer sample values
|
|
|
|
(<constant>COMEDI_FROM_PHYSICAL</constant>).
|
2006-09-08 19:40:15 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
2008-03-28 18:16:45 +00:00
|
|
|
<section id="ref-enum-comedi-io-direction">
|
|
|
|
<title>
|
|
|
|
enum comedi_io_direction
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
<programlisting>
|
|
|
|
enum comedi_io_direction
|
|
|
|
{
|
|
|
|
COMEDI_INPUT,
|
|
|
|
COMEDI_OUTPUT
|
|
|
|
};
|
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
A <type>comedi_io_direction</type> is used to select between input or output. For example,
|
|
|
|
<function><link linkend="func-ref-comedi-dio-config">comedi_dio_config</link></function>
|
|
|
|
uses the <constant>COMEDI_INPUT</constant> and <constant>COMEDI_OUTPUT</constant> values to specify
|
2008-03-28 18:16:45 +00:00
|
|
|
whether a configurable digital i/o channel should be configured as an input
|
|
|
|
or output.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
2008-02-08 21:42:25 +00:00
|
|
|
<section id="ref-enum-comedi-subdevice-type">
|
|
|
|
<title>
|
|
|
|
enum comedi_subdevice_type
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
<programlisting>
|
|
|
|
enum comedi_subdevice_type {
|
|
|
|
COMEDI_SUBD_UNUSED, /* subdevice is unused by driver */
|
|
|
|
COMEDI_SUBD_AI, /* analog input */
|
|
|
|
COMEDI_SUBD_AO, /* analog output */
|
|
|
|
COMEDI_SUBD_DI, /* digital input */
|
|
|
|
COMEDI_SUBD_DO, /* digital output */
|
|
|
|
COMEDI_SUBD_DIO, /* digital input/output */
|
|
|
|
COMEDI_SUBD_COUNTER, /* counter */
|
|
|
|
COMEDI_SUBD_TIMER, /* timer */
|
|
|
|
COMEDI_SUBD_MEMORY, /* memory, EEPROM, DPRAM */
|
|
|
|
COMEDI_SUBD_CALIB, /* calibration DACs and pots*/
|
|
|
|
COMEDI_SUBD_PROC, /* processor, DSP */
|
|
|
|
COMEDI_SUBD_SERIAL, /* serial IO */
|
|
|
|
COMEDI_SUBD_PWM /* pulse width modulation */
|
|
|
|
};
|
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
The <type>comedi_subdevice_type</type> enumeration specifies the possible values for
|
2008-02-08 21:42:25 +00:00
|
|
|
a subdevice type. These values are used by the functions
|
2012-05-04 18:10:55 +01:00
|
|
|
<function><link linkend="func-ref-comedi-get-subdevice-type">comedi_get_subdevice_type</link></function> and
|
|
|
|
<function><link linkend="func-ref-comedi-find-subdevice-by-type">comedi_find_subdevice_by_type</link></function>.
|
2008-02-08 21:42:25 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
2002-01-21 11:15:31 +00:00
|
|
|
</section>
|
|
|
|
|
2003-07-07 22:34:18 +00:00
|
|
|
<section id="datatypesstructures">
|
2002-01-21 11:15:31 +00:00
|
|
|
<title>
|
2008-02-11 15:50:36 +00:00
|
|
|
Data types and structures
|
2002-01-21 11:15:31 +00:00
|
|
|
</title>
|
2003-07-07 22:34:18 +00:00
|
|
|
<para>
|
|
|
|
This Section explains the data structures that users of the &comedi;
|
|
|
|
API are confronted with:
|
|
|
|
<programlisting>
|
|
|
|
typedef struct comedi_devinfo_struct <link linkend="ref-type-comedi-devinfo">comedi_devinfo</link>;
|
|
|
|
typedef struct comedi_t_struct <link linkend="ref-type-comedi-t">comedi_t</link>;
|
|
|
|
typedef struct sampl_t_struct <link linkend="ref-type-sampl-t">sampl_t</link>;
|
|
|
|
typedef struct lsampl_t_struct <link linkend="ref-type-lsampl-t">lsampl_t</link>;
|
|
|
|
typedef struct comedi_sv_t_struct <link linkend="ref-type-comedi-sv-t">comedi_sv_t</link>;
|
|
|
|
typedef struct comedi_cmd_struct <link linkend="ref-type-comedi-cmd">comedi_cmd</link>;
|
|
|
|
typedef struct comedi_insn_struct <link linkend="ref-type-comedi-insn">comedi_insn</link>;
|
|
|
|
typedef struct comedi_range_struct <link linkend="ref-type-comedi-range">comedi_range</link>;
|
|
|
|
typedef struct comedi_krange_struct <link linkend="ref-type-comedi-krange">comedi_krange</link>;
|
|
|
|
typedef struct comedi_insnlist_struct <link linkend="ref-type-comedi-insnlist">comedi_insnlist</link>;
|
|
|
|
</programlisting>
|
|
|
|
The data structures used in the implementation of the &comedi; drivers
|
2012-05-08 14:04:55 +01:00
|
|
|
are described in <xref linkend="driverdatastructures"/>.
|
2003-07-07 22:34:18 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
<section id="ref-type-comedi-devinfo">
|
|
|
|
<title>
|
|
|
|
comedi_devinfo
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
The data type <type>comedi_devinfo</type> is used to store
|
2003-07-07 22:34:18 +00:00
|
|
|
information about a device. This structure is usually filled in
|
2003-07-11 22:53:40 +00:00
|
|
|
automatically when the driver is loaded (<quote>attached</quote>), so
|
2003-07-07 22:34:18 +00:00
|
|
|
programmers need not access this data structure directly.
|
|
|
|
<programlisting>
|
|
|
|
typedef struct comedi_devinfo_struct comedi_devinfo;
|
|
|
|
|
|
|
|
struct comedi_devinfo_struct{
|
|
|
|
unsigned int version_code; // version number of the Comedi code
|
|
|
|
unsigned int n_subdevs; // number of subdevices on this device
|
|
|
|
char driver_name[COMEDI_NAMELEN];
|
|
|
|
char board_name[COMEDI_NAMELEN];
|
2007-07-16 14:01:40 +00:00
|
|
|
int read_subdevice; // index of subdevice whose buffer is read by read(), etc. on file descriptor from comedi_fileno() (negative means none)
|
|
|
|
int write_subdevice; // index of subdevice whose buffer is written by write(), etc. on file descriptor from comedi_fileno() (negatove means none).
|
2003-07-07 22:34:18 +00:00
|
|
|
int unused[30];
|
|
|
|
};
|
|
|
|
|
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
2002-01-21 11:15:31 +00:00
|
|
|
|
|
|
|
<section id="ref-type-comedi-t">
|
|
|
|
<title>
|
|
|
|
comedi_t
|
|
|
|
</title>
|
|
|
|
|
2003-07-07 22:34:18 +00:00
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
The data type <type>comedi_t</type> is used to represent an
|
2003-07-07 22:34:18 +00:00
|
|
|
open &comedi; device:
|
2002-01-21 15:17:12 +00:00
|
|
|
<programlisting>
|
|
|
|
typedef struct comedi_t_struct comedi_t;
|
2003-07-07 22:34:18 +00:00
|
|
|
</programlisting>
|
2012-05-04 18:20:42 +01:00
|
|
|
A valid <type>comedi_t</type> pointer is returned by a
|
2003-07-07 22:34:18 +00:00
|
|
|
successful call to
|
2012-05-04 18:10:55 +01:00
|
|
|
<function><link linkend="func-ref-comedi-open">comedi_open</link></function>,
|
2003-07-07 22:34:18 +00:00
|
|
|
and should be used for subsequent access to the device.
|
2012-05-04 18:20:42 +01:00
|
|
|
It is an opaque type, and pointers to type
|
2003-07-07 22:34:18 +00:00
|
|
|
<parameter>comedi_t</parameter>
|
2002-01-21 11:15:31 +00:00
|
|
|
should not be dereferenced by the application.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
<section id="ref-type-sampl-t">
|
|
|
|
<title>
|
|
|
|
sampl_t
|
|
|
|
</title>
|
|
|
|
|
2002-01-21 15:17:12 +00:00
|
|
|
<programlisting>
|
|
|
|
typedef unsigned short sampl_t;
|
|
|
|
</programlisting>
|
2002-01-21 11:15:31 +00:00
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
The data type <type>sampl_t</type> is one
|
2003-07-07 22:34:18 +00:00
|
|
|
of the generic
|
|
|
|
types used to represent data values in Comedilib. It is used in a few
|
|
|
|
places where a data type
|
2012-05-04 18:10:55 +01:00
|
|
|
shorter than <type><link linkend="ref-type-lsampl-t">lsampl_t</link></type> is
|
|
|
|
useful. On most architectures it is a 16-bit, unsigned integer.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
Most drivers represent data transferred by <function>read</function> and
|
|
|
|
<function>write</function> functions using <type>sampl_t</type>.
|
2003-07-07 22:34:18 +00:00
|
|
|
Applications should check the subdevice flag
|
2012-05-04 18:10:55 +01:00
|
|
|
<constant>SDF_LSAMPL</constant> to determine if the subdevice uses
|
|
|
|
<type>sampl_t</type> or
|
|
|
|
<type><link linkend="ref-type-lsampl-t">lsampl_t</link></type>.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="ref-type-lsampl-t">
|
|
|
|
<title>
|
|
|
|
lsampl_t
|
|
|
|
</title>
|
|
|
|
|
2002-01-21 15:17:12 +00:00
|
|
|
<programlisting>
|
|
|
|
typedef unsigned int lsampl_t;
|
|
|
|
</programlisting>
|
|
|
|
|
2002-01-21 11:15:31 +00:00
|
|
|
<para>
|
2006-09-08 19:40:15 +00:00
|
|
|
The data type
|
2012-05-04 18:10:55 +01:00
|
|
|
<type><link linkend="ref-type-lsampl-t">lsampl_t</link></type>
|
2003-07-07 22:34:18 +00:00
|
|
|
is the data type typically used to represent
|
2012-05-04 18:10:55 +01:00
|
|
|
data values in Comedilib. On most architectures it is a 32-bit,
|
|
|
|
unsigned integer.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
<section id="ref-type-comedi-trig">
|
|
|
|
<title>
|
|
|
|
comedi_trig (deprecated)
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<programlisting>
|
2002-01-21 15:17:12 +00:00
|
|
|
typedef struct comedi_trig_struct comedi_trig;
|
|
|
|
|
2002-01-21 11:15:31 +00:00
|
|
|
struct comedi_trig_struct{
|
2003-07-07 22:34:18 +00:00
|
|
|
unsigned int subdev; /* subdevice */
|
|
|
|
unsigned int mode; /* mode */
|
|
|
|
unsigned int flags;
|
|
|
|
unsigned int n_chan; /* number of channels */
|
|
|
|
unsigned int *chanlist; /* channel/range list */
|
|
|
|
<link linkend="ref-type-sampl-t">sampl_t</link> *data; /* data list, size depends on subd flags */
|
|
|
|
unsigned int n; /* number of scans */
|
|
|
|
unsigned int trigsrc;
|
|
|
|
unsigned int trigvar;
|
|
|
|
unsigned int trigvar1;
|
|
|
|
unsigned int data_len;
|
|
|
|
unsigned int unused[3];
|
2002-01-21 15:17:12 +00:00
|
|
|
};
|
2002-01-21 11:15:31 +00:00
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
The <type>comedi_trig</type> structure is a control structure used by the
|
|
|
|
<constant>COMEDI_TRIG</constant> ioctl, an older method of communicating
|
|
|
|
instructions to the driver and hardware. Use of <type>comedi_trig</type> is
|
2012-05-04 18:45:33 +01:00
|
|
|
deprecated, and is no longer implemented by the &comedi; kernel layer.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="ref-type-comedi-sv-t">
|
|
|
|
<title>
|
2008-02-08 21:42:25 +00:00
|
|
|
comedi_sv_t (deprecated)
|
2002-01-21 11:15:31 +00:00
|
|
|
</title>
|
|
|
|
|
|
|
|
<programlisting>
|
2002-01-21 15:17:12 +00:00
|
|
|
typedef struct comedi_sv_struct comedi_sv_t;
|
|
|
|
|
2002-01-21 11:15:31 +00:00
|
|
|
struct comedi_sv_struct{
|
2003-07-07 22:34:18 +00:00
|
|
|
comedi_t *dev;
|
|
|
|
unsigned int subdevice;
|
|
|
|
unsigned int chan;
|
2002-01-21 11:15:31 +00:00
|
|
|
|
2003-07-07 22:34:18 +00:00
|
|
|
/* range policy */
|
|
|
|
int range;
|
|
|
|
int aref;
|
2002-01-21 11:15:31 +00:00
|
|
|
|
2003-07-07 22:34:18 +00:00
|
|
|
/* number of measurements to average (for ai) */
|
|
|
|
int n;
|
2002-01-21 11:15:31 +00:00
|
|
|
|
2003-07-07 22:34:18 +00:00
|
|
|
<link linkend="ref-type-lsampl-t">lsampl_t</link> maxdata;
|
2002-01-21 15:17:12 +00:00
|
|
|
};
|
2002-01-21 11:15:31 +00:00
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
The <type>comedi_sv_t</type> structure is used by the <function>comedi_sv_…</function>
|
2002-01-21 11:15:31 +00:00
|
|
|
functions to provide a simple method of accurately measuring
|
2012-05-04 18:45:33 +01:00
|
|
|
slowly varying inputs. This relies on the <constant>COMEDI_TRIG</constant>
|
|
|
|
ioctl and is no longer by the &comedi; kernel layer.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="ref-type-comedi-cmd">
|
|
|
|
<title>
|
|
|
|
comedi_cmd
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
typedef struct comedi_cmd_struct comedi_cmd;
|
|
|
|
|
|
|
|
struct comedi_cmd_struct{
|
2003-07-07 22:34:18 +00:00
|
|
|
unsigned int subdev;
|
|
|
|
unsigned int flags;
|
2002-01-21 11:15:31 +00:00
|
|
|
|
2003-07-07 22:34:18 +00:00
|
|
|
unsigned int start_src;
|
|
|
|
unsigned int start_arg;
|
2002-01-21 11:15:31 +00:00
|
|
|
|
2003-07-07 22:34:18 +00:00
|
|
|
unsigned int scan_begin_src;
|
|
|
|
unsigned int scan_begin_arg;
|
2002-01-21 11:15:31 +00:00
|
|
|
|
2003-07-07 22:34:18 +00:00
|
|
|
unsigned int convert_src;
|
|
|
|
unsigned int convert_arg;
|
2002-01-21 11:15:31 +00:00
|
|
|
|
2003-07-07 22:34:18 +00:00
|
|
|
unsigned int scan_end_src;
|
|
|
|
unsigned int scan_end_arg;
|
2002-01-21 11:15:31 +00:00
|
|
|
|
2003-07-07 22:34:18 +00:00
|
|
|
unsigned int stop_src;
|
|
|
|
unsigned int stop_arg;
|
2002-01-21 11:15:31 +00:00
|
|
|
|
2003-07-07 22:34:18 +00:00
|
|
|
unsigned int *chanlist;
|
|
|
|
unsigned int chanlist_len;
|
2002-01-21 11:15:31 +00:00
|
|
|
|
2003-07-07 22:34:18 +00:00
|
|
|
<link linkend="ref-type-sampl-t">sampl_t</link> *data;
|
|
|
|
unsigned int data_len;
|
2002-01-21 11:15:31 +00:00
|
|
|
};
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
More information on using commands can be found in the
|
2012-05-04 18:10:55 +01:00
|
|
|
<link linkend="commandsstreaming">command section</link>.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="ref-type-comedi-insn">
|
|
|
|
<title>
|
|
|
|
comedi_insn
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
typedef struct comedi_insn_struct comedi_insn;
|
|
|
|
|
|
|
|
struct comedi_insn_struct{
|
2003-07-07 22:34:18 +00:00
|
|
|
unsigned int insn;
|
|
|
|
unsigned int n;
|
|
|
|
<link linkend="ref-type-lsampl-t">lsampl_t</link>*data;
|
|
|
|
unsigned int subdev;
|
|
|
|
unsigned int chanspec;
|
|
|
|
unsigned int unused[3];
|
2002-01-21 11:15:31 +00:00
|
|
|
};
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
Comedi instructions are described by the <type>comedi_insn</type> structure.
|
2003-07-07 22:34:18 +00:00
|
|
|
Applications send instructions to the driver in order to perform
|
2002-01-21 11:15:31 +00:00
|
|
|
control and measurement operations that are done immediately or
|
|
|
|
synchronously, i.e., the operations complete before program control
|
|
|
|
returns to the application. In particular, instructions cannot
|
|
|
|
describe acquisition that involves timers or external events.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The field insn determines the type of instruction that is sent
|
2003-07-07 22:34:18 +00:00
|
|
|
to the driver. Valid instruction types are:
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term>
|
2008-01-24 01:32:41 +00:00
|
|
|
<anchor id="insn-read"/>
|
2012-05-04 18:10:55 +01:00
|
|
|
<constant>INSN_READ</constant>
|
2002-01-21 11:15:31 +00:00
|
|
|
</term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
read values from an input channel
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>
|
2008-01-24 01:32:41 +00:00
|
|
|
<anchor id="insn-write"/>
|
2012-05-04 18:10:55 +01:00
|
|
|
<constant>INSN_WRITE</constant>
|
2002-01-21 11:15:31 +00:00
|
|
|
</term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
write values to an output channel
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>
|
2008-01-24 01:32:41 +00:00
|
|
|
<anchor id="insn-bits"/>
|
2012-05-04 18:10:55 +01:00
|
|
|
<constant>INSN_BITS</constant>
|
2002-01-21 11:15:31 +00:00
|
|
|
</term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
read/write values on multiple digital I/O channels
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>
|
2008-01-24 01:32:41 +00:00
|
|
|
<anchor id="insn-config"/>
|
2012-05-04 18:10:55 +01:00
|
|
|
<constant>INSN_CONFIG</constant>
|
2002-01-21 11:15:31 +00:00
|
|
|
</term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
configure a subdevice
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>
|
2008-01-24 01:32:41 +00:00
|
|
|
<anchor id="insn-gtod"/>
|
2012-05-04 18:10:55 +01:00
|
|
|
<constant>INSN_GTOD</constant>
|
2002-01-21 11:15:31 +00:00
|
|
|
</term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
read a timestamp, identical to <function>gettimeofday</function> except the seconds
|
2016-06-20 11:09:55 +01:00
|
|
|
and microseconds values are unsigned values of type <type><link linkend="ref-type-lsampl-t">lsampl_t</link></type>.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>
|
2008-01-24 01:32:41 +00:00
|
|
|
<anchor id="insn-wait"/>
|
2012-05-04 18:10:55 +01:00
|
|
|
<constant>INSN_WAIT</constant>
|
2002-01-21 11:15:31 +00:00
|
|
|
</term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
wait a specified number of nanoseconds
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The number of samples to read or write, or the size of the configuration
|
|
|
|
structure is specified by the field n, and the buffer for those
|
|
|
|
samples by data. The field subdev is the subdevice index
|
|
|
|
that the instruction is sent to. The field chanspec specifies
|
|
|
|
the channel, range, and analog reference (if applicable).
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
Instructions can be sent to drivers using
|
|
|
|
<function><link linkend="func-ref-comedi-do-insn">comedi_do_insn</link></function>.
|
|
|
|
Multiple instructions can be sent to drivers in the same system call using
|
|
|
|
<function><link linkend="func-ref-comedi-do-insnlist">comedi_do_insnlist</link></function>.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="ref-type-comedi-range">
|
|
|
|
<title>
|
|
|
|
comedi_range
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<programlisting>
|
2002-01-21 15:17:12 +00:00
|
|
|
typedef struct comedi_range_struct comedi_range;
|
|
|
|
|
|
|
|
struct comedi_range_struct{
|
2003-07-07 22:34:18 +00:00
|
|
|
double min;
|
|
|
|
double max;
|
|
|
|
unsigned int unit;
|
2002-01-21 11:15:31 +00:00
|
|
|
}comedi_range;
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
The <type>comedi_range</type> structure conveys part of the information
|
2002-01-21 11:15:31 +00:00
|
|
|
necessary to translate sample values to physical units, in particular,
|
|
|
|
the endpoints of the range and the physical unit type. The
|
|
|
|
physical unit type is specified by the field unit, which may
|
2012-05-04 18:10:55 +01:00
|
|
|
take the values <constant>UNIT_volt</constant> for volts,
|
|
|
|
<constant>UNIT_mA</constant> for milliamps,
|
|
|
|
or <constant>UNIT_none</constant> for unitless. The endpoints are specified by
|
2002-01-21 11:15:31 +00:00
|
|
|
the fields min and max.
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="ref-type-comedi-krange">
|
|
|
|
<title>
|
|
|
|
comedi_krange
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<programlisting>
|
2002-01-21 15:17:12 +00:00
|
|
|
typedef struct comedi_krange_struct comedi_krange;
|
|
|
|
|
2002-01-21 11:15:31 +00:00
|
|
|
struct comedi_krange_struct{
|
2003-07-07 22:34:18 +00:00
|
|
|
int min;
|
|
|
|
int max;
|
|
|
|
unsigned int flags;
|
2002-01-21 11:15:31 +00:00
|
|
|
};
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
The <type>comedi_krange</type> structure is used to transfer range information
|
2002-01-21 11:15:31 +00:00
|
|
|
between the driver and Comedilib, and should not normally be used
|
|
|
|
by applications. The structure conveys the same information as the
|
|
|
|
comedi_range structure, except the fields min and max
|
|
|
|
are integers, multiplied by a factor of 1000000 compared to the
|
2012-05-04 18:10:55 +01:00
|
|
|
counterparts in <type>comedi_range</type>.
|
2002-01-21 11:15:31 +00:00
|
|
|
</para>
|
2002-01-21 15:17:12 +00:00
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
In addition, <systemitem>kcomedilib</systemitem> uses the
|
|
|
|
<type>comedi_krange</type> structure in place
|
|
|
|
of the <type>comedi_range</type> structure.
|
2002-01-21 15:17:12 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="ref-type-comedi-insnlist">
|
|
|
|
<title>
|
|
|
|
comedi_insnlist
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
typedef struct comedi_insnlist_struct comedi_insnlist;
|
|
|
|
|
|
|
|
struct comedi_insnlist_struct{
|
2003-07-07 22:34:18 +00:00
|
|
|
unsigned int n_insns;
|
|
|
|
comedi_insn *insns;
|
2002-01-21 15:17:12 +00:00
|
|
|
};
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:29:47 +01:00
|
|
|
A <type>comedi_insnlist</type> structure is used to communicate
|
|
|
|
a list of instructions to the driver using the
|
|
|
|
<function><link linkend="func-ref-comedi-do-insnlist">comedi_do_insnlist</link></function>
|
|
|
|
function.
|
|
|
|
|
2002-01-21 15:17:12 +00:00
|
|
|
</para>
|
|
|
|
|
2002-01-21 11:15:31 +00:00
|
|
|
</section>
|
|
|
|
|
2012-04-20 13:28:15 +01:00
|
|
|
<section id="ref-type-comedi-polynomial-t">
|
|
|
|
<title>
|
|
|
|
comedi_polynomial_t
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
#define COMEDI_MAX_NUM_POLYNOMIAL_COEFFICIENTS 4
|
|
|
|
typedef struct {
|
|
|
|
double coefficients[COMEDI_MAX_NUM_POLYNOMIAL_COEFFICIENTS];
|
|
|
|
double expansion_origin;
|
|
|
|
unsigned order;
|
|
|
|
} comedi_polynomial_t;
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
<para>
|
2012-05-04 18:10:55 +01:00
|
|
|
A <type>comedi_polynomial_t</type> holds calibration data for a channel of a
|
2012-04-20 13:28:15 +01:00
|
|
|
subdevice. It is initialized by the
|
2012-05-04 18:10:55 +01:00
|
|
|
<function><link linkend="func-ref-comedi-get-hardcal-converter">comedi_get_hardcal_converter</link></function>
|
|
|
|
or <function><link linkend="func-ref-comedi-get-softcal-converter">comedi_get_softcal_converter</link></function>
|
2012-04-20 13:28:15 +01:00
|
|
|
calibration functions and is passed to the
|
2012-05-04 18:10:55 +01:00
|
|
|
<function><link linkend="func-ref-comedi-to-physical">comedi_to_physical</link></function>
|
|
|
|
and <function><link linkend="func-ref-comedi-from-physical">comedi_from_physical</link></function>
|
2012-04-20 13:28:15 +01:00
|
|
|
raw/physical conversion functions.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
2008-01-24 01:32:41 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="functionreference">
|
|
|
|
<title>Functions</title>
|
|
|
|
<xi:include href="funcref.xml"/>
|
|
|
|
<xi:include href="command_funcref.xml"/>
|
|
|
|
<xi:include href="calibration_funcref.xml"/>
|
|
|
|
<xi:include href="dio_funcref.xml"/>
|
|
|
|
<xi:include href="error_funcref.xml"/>
|
|
|
|
<xi:include href="extensions_funcref.xml"/>
|
|
|
|
<xi:include href="deprecated_funcref.xml"/>
|
|
|
|
</section>
|
2012-10-29 17:08:09 +00:00
|
|
|
<xi:include href="bindings.xml"/>
|
2008-02-11 15:50:36 +00:00
|
|
|
<xi:include href="drivers.xml"/>
|
2002-01-21 11:15:31 +00:00
|
|
|
</section>
|