generated in the release script now.
+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
- <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.8.1">
- <TITLE>Comedi Documentation: Introduction</TITLE>
- <LINK HREF="comedilib-2.html" REL=next>
-
- <LINK HREF="comedilib.html#toc1" REL=contents>
-</HEAD>
-<BODY>
-<A HREF="comedilib-2.html">Next</A>
-Previous
-<A HREF="comedilib.html#toc1">Contents</A>
-<HR>
-<H2><A NAME="s1">1.</A> <A HREF="comedilib.html#toc1">Introduction</A></H2>
-
-<P>This is preliminary documentation for Comedi and Comedilib.</P>
-
-<HR>
-<A HREF="comedilib-2.html">Next</A>
-Previous
-<A HREF="comedilib.html#toc1">Contents</A>
-</BODY>
-</HTML>
+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
- <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.8.1">
- <TITLE>Comedi Documentation: Installation and configuration</TITLE>
- <LINK HREF="comedilib-3.html" REL=next>
- <LINK HREF="comedilib-1.html" REL=previous>
- <LINK HREF="comedilib.html#toc2" REL=contents>
-</HEAD>
-<BODY>
-<A HREF="comedilib-3.html">Next</A>
-<A HREF="comedilib-1.html">Previous</A>
-<A HREF="comedilib.html#toc2">Contents</A>
-<HR>
-<H2><A NAME="s2">2.</A> <A HREF="comedilib.html#toc2">Installation and configuration</A></H2>
-
-
-<P>This section covers compiling, installing, and configuring
-comedi and comedlib.</P>
-
-
-<H2><A NAME="ss2.1">2.1 Compiling and Installing</A>
-</H2>
-
-
-<P>This section has not been written.</P>
-
-
-<H2><A NAME="ss2.2">2.2 Insmod'ding the kernel module</A>
-</H2>
-
-
-<P>This section has not been written.</P>
-
-
-<H2><A NAME="ss2.3">2.3 Configuring comedi for your hardware</A>
-</H2>
-
-
-
-<P>I assume that your hardware device is in your computer, and that
-you know the relevant details about it, i.e., what kind of card
-it is, the I/O base, the IRQ, jumper settings related to input
-ranges, etc.</P>
-<P>To tell the comedi kernel module that you have a particular device, and
-some information about it, you will be running the <CODE>comedi_config</CODE>
-command. Perhaps you should read the man page now.</P>
-<P>In this tutorial, I will go through the process of configuring comedi
-for two devices, a National Instruments AT-MIO-16E-10
-and a Data Translation DT2821-F-8DI.</P>
-<P>The NI board is plug-and-play, and the man page tells me that I need
-to configure the PnP part of the board with isapnptools. The isapnptools
-package is a little cryptic, but the concepts are simple. Once I
-learned how to use it, I settled on a /etc/isapnp.conf file that
-contained the lines:</P>
-
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-# ANSI string -->National Instruments, AT-MIO-16E-10<--
-(CONFIGURE NIC2400/10725401 (LD 0
- (IO 0 (BASE 0x0260))
- (INT 0 (IRQ 3 (MODE +E)))
-# (DMA 0 (CHANNEL 5))
-# (DMA 1 (CHANNEL 6))
- (ACT Y)
-))
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-
-<P>It also contains a few lines about overall configuration and about my
-sound card. I found out after a bit of trial-and-error that the NI
-board does not always work with interrupts other than IRQ 3. YMMV.
-Currently, the driver doesn't use DMA, but it may in the future, so
-I commented out the DMA lines. It is a curious fact that the device
-ignores the IRQ and DMA information given here, however, I keep the
-information here to remind myself that the numbers aren't arbitrary.</P>
-<P>When I run comedi_config (as root, of course), I provide the same
-information. Since I want to have the board configured every time
-I boot, I put the line</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-/usr/sbin/comedi_config /dev/comedi0 atmio-E 0x260,3
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>into <CODE>/etc/rc.d/rc.local</CODE>. You can, of course, run this command at
-a command prompt. The man page tells me that the option list
-is supposed to be "(I/O base),(IRQ)", so I used the same numbers
-as I put in /etc/isapnp.conf, i.e., 0x260,3.</P>
-<P>For the Data Translation board, I need to have a list of the
-jumper settings. Fortunately, I wrote them all down in the
-manual -- I hope they are still correct. However, I had to
-open the case to figure out which board in the series I had.
-It is a DT2821-f-8di. The man page of comedi_config tells
-me that I need to know the I/O base, IRQ, DMA 1, DMA 2. However,
-since I wrote the driver, I know that it also recognizes the
-differential/single-ended and unipolar/bipolar jumpers. As always,
-the source is the final authority, and looking in module/dt282x.c
-tells me that the options list is interpreted as:</P>
-<P>
-<UL>
-<LI>I/O base</LI>
-<LI>IRQ</LI>
-<LI>1=differential, 0=single ended</LI>
-<LI>ai 0=unipolar, 1=bipolar</LI>
-<LI>ao0 0=unipolar, 1=bipolar</LI>
-<LI>ao1 0=unipolar, 1=bipolar</LI>
-<LI>dma1</LI>
-<LI>dma2</LI>
-</UL>
-</P>
-<P>(ai=analog input, ao=analog output.) From this, I decide that
-the appropriate options list is</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-0x200,4,,1,1,1
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>I left the differential/single-ended number blank, since the
-driver already knowns (from the board name), that it is
-differential. I also left the DMA numbers blank, since I
-don't want the driver to use DMA. (Don't want it to interfere
-with my sound card -- life is full of difficult choices.)
-Keep in mind that things commented in the source, but not in
-the documentation are about as likely to change as the weather,
-so I put good comments next to the following line when I put
-it in rc.local.</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-/usr/sbin/comedi_config /dev/comedi1 dt2821-f-8di 0x200,4,,1,1,1
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>So now I think that I have my boards configured correctly.
-Since data acquisition boards are not typically well-engineered,
-comedi sometimes can't figure out if the board is actually there.
-If it can't, it assumes you are right. Both of these boards
-are well-made, so comedi will give me an error message if it
-can't find them. The comedi kernel module, since it is a part
-of the kernel, prints messages to the kernel logs, which you
-can access through the command 'dmesg' or /var/log/messages.
-Here is a configuration failure (from dmesg):</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-comedi0: ni_E: 0x0200 can't find board
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>When it does work, I get:</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-comedi0: ni_E: 0x0260 at-mio-16e-10 ( irq = 3 )
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>Note that it also correctly identified my board.</P>
-
-
-
-<H2><A NAME="ss2.4">2.4 Getting information from comedi</A>
-</H2>
-
-
-
-<P>So now that we have comedi talking to the hardware, we want to
-talk to comedi. Here's some pretty low-level information --
-it's sometimes useful for debugging:</P>
-
-
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-cat /proc/comedi
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>Right now, on my computer, this command gives:</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-comedi version 0.6.4
-format string
- 0: atmio-E at-mio-16e-10 7
- 1: dt282x dt2821-f-8di 4
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>This is a feature that is not well-developed yet. Basically, it
-currently tells you driver name, device name, and number of
-subdevices.</P>
-<P>In the <CODE>demo/</CODE> directory, there is a command called
-<CODE>info</CODE>, which provides information about each subdevice on the
-board. The output of it is rather long, since I have 7
-subdevices (4 or fewer is common for other boards.)
-Here's part of the output of the NI board (which
-is on <CODE>/dev/comedi0</CODE>.) ('demo/info /dev/comedi0')</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-overall info:
- version code: 0x000604
- driver name: atmio-E
- board name: at-mio-16e-10
- number of subdevices: 7
-subdevice 0:
- type: 1 (unknown)
- number of channels: 16
- max data value: 4095
-</PRE>
-
-...
-</CODE></BLOCKQUOTE>
-</P>
-<P>The overall info gives information about the device -- basically
-the same information as /proc/comedi.</P>
-<P>This board has 7 subdevices. Devices are separated into
-subdevices that each have a distinct purpose -- e.g., analog
-input, analog output, digital input/output. This board also
-has an EEPROM and calibration DACs that are also subdevices.</P>
-<P>Subdevice 0 is the analog input subdevice. You would have
-known this from the 'type: 1 (unknown)' line, if I've updated
-demo/info recently, because it would say 'type: 1 (analog input)'
-instead. The other lines should be self-explanitory. Comedi
-has more information about the device, but demo/info doesn't
-currently display this.</P>
-
-
-<HR>
-<A HREF="comedilib-3.html">Next</A>
-<A HREF="comedilib-1.html">Previous</A>
-<A HREF="comedilib.html#toc2">Contents</A>
-</BODY>
-</HTML>
+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
- <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.8.1">
- <TITLE>Comedi Documentation: Individual drivers</TITLE>
- <LINK HREF="comedilib-4.html" REL=next>
- <LINK HREF="comedilib-2.html" REL=previous>
- <LINK HREF="comedilib.html#toc3" REL=contents>
-</HEAD>
-<BODY>
-<A HREF="comedilib-4.html">Next</A>
-<A HREF="comedilib-2.html">Previous</A>
-<A HREF="comedilib.html#toc3">Contents</A>
-<HR>
-<H2><A NAME="s3">3.</A> <A HREF="comedilib.html#toc3">Individual drivers</A></H2>
-
-
-<P>This section contains information that is specific to each
-hardware driver. The most current information about a driver
-is included in the comedi source.</P>
-
-<H2><A NAME="ss3.1">3.1 National Instruments AT-MIO E series</A>
-</H2>
-
-
-
-
-<H2><A NAME="ss3.2">3.2 Data Translation</A>
-</H2>
-
-
-
-
-
-<HR>
-<A HREF="comedilib-4.html">Next</A>
-<A HREF="comedilib-2.html">Previous</A>
-<A HREF="comedilib.html#toc3">Contents</A>
-</BODY>
-</HTML>
+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
- <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.8.1">
- <TITLE>Comedi Documentation: Writing programs that use comedi and comedilib</TITLE>
- <LINK HREF="comedilib-5.html" REL=next>
- <LINK HREF="comedilib-3.html" REL=previous>
- <LINK HREF="comedilib.html#toc4" REL=contents>
-</HEAD>
-<BODY>
-<A HREF="comedilib-5.html">Next</A>
-<A HREF="comedilib-3.html">Previous</A>
-<A HREF="comedilib.html#toc4">Contents</A>
-<HR>
-<H2><A NAME="s4">4.</A> <A HREF="comedilib.html#toc4">Writing programs that use comedi and comedilib</A></H2>
-
-
-
-<H2><A NAME="ss4.1">4.1 Your first comedi program</A>
-</H2>
-
-
-<P>This example requires a card that has analog or
-digital input. Right to the source:</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-#include <stdio.h> /* for printf() */
-#include <comedilib.h>
-
-int subdev = 0; /* change this to your input subdevice */
-int chan = 0; /* change this to your channel */
-int range = 0; /* more on this later */
-int aref = AREF_GROUND; /* more on this later */
-
-int main(int argc,char *argv[])
-{
- comedi_t *it;
- lsampl_t data;
-
- it=comedi_open("/dev/comedi0");
-
- comedi_data_read(it,subdev,chan,range,aref,&data);
-
- printf("%d\n",data);
-
- return 0;
-}
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-
-<P>Should be understandable: open the device, get the data,
-print it out. This is basically the guts of <CODE>demo/inp.c</CODE>,
-without error checking or fancy options.
-Compile it using</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-cc tut1.c -lcomedi -o tut1
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>A few notes: The range variable tells comedi which gain
-to use when measuring an analog voltage. Since we don't
-know (yet) which numbers are valid, or what each means,
-we'll use 0, because it won't cause errors. Likewise with
-aref, which determines the analog reference used.</P>
-
-
-
-<H2><A NAME="ss4.2">4.2 Converting samples to voltages</A>
-</H2>
-
-
-<P>If you selected an analog input subdevice, you probably noticed
-that the output of <CODE>tut1</CODE> is a number between
-0 and 4095, or 0 and 65535, depending on the number of bits
-in the A/D converter. Comedi samples are <B>always</B> unsigned,
-with 0 representing the lowest voltage of the ADC, and 4095
-the highest. Comedi compensates for
-anything else the manual for your device says. However,
-you probably prefer to have this number translated to
-a voltage. Naturally, as a good programmer, your first
-question is: "How do I do this in a device-independent
-manner?"</P>
-<P>Most devices give you a choice of gain and unipolar/bipolar
-input, and Comedi allows you to select which of these to
-use. This parameter is called the "range parameter", since
-it specifies the "input range" for analog input (or "output range"
-for analog output.) The range parameter represents both the gain
-and the unipolar/bipolar aspects.</P>
-<P>Comedi keeps the number of available ranges and the largest
-sample value for each subdevice/channel combination. (Some
-devices allow different input/output ranges for different
-channels in a subdevice.)</P>
-<P>The largest sample value can be found using the function:</P>
-<P>comedi_get_maxdata()</P>
-<P>The number of available ranges can be found using the function:</P>
-<P>comedi_get_n_ranges()</P>
-<P>For each value of the range parameter for a particular
-subdevice/channel, you can get range information using the
-function:</P>
-<P>ptr=comedi_get_range(comedi_file,subdevice,channel,
-range)</P>
-<P>which returns a pointer to a comedi_range structure.
-The comedi_range structure looks like</P>
-
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-typedef struct{
- double min;
- double max;
- unsigned int unit;
-}comedi_range;
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>The structure element 'min' represents
-the voltage corresponding to comedi_data_read() returning 0,
-and 'max' represents comedi_data_read() returning 'maxdata',
-(i.e., 4095 for 12 bit A/C converters, 65535 for 16 bit,
-or, 1 for digital input -- more on this in a bit.) The
-'unit' entry tells you if min and
-max refer to voltage, current, etc.</P>
-<P>"Could it get easier?", you say. Well, yes. Use
-the function comedi_to_phys(), which converts data
-values to physical units. Call it using something like</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-volts=comedi_to_phys(it,data,range,maxdata);
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>and the opposite</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-data=comedi_from_phys(it,volts,range,maxdata);
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-
-
-
-<H2><A NAME="ss4.3">4.3 Another section</A>
-</H2>
-
-
-
-<P>In addition to providing low level routines for data
-access, the comedi library provides higher-level access,
-much like the standard C library provides fopen(), etc.
-as a high-level (and portable) alternative to the direct
-UNIX system calls open(), etc. Similarily to fopen(),
-we have comedi_open():</P>
-
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-file=comedi_open("/dev/comedi0");
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>where file is of type <CODE>(comedi_t *)</CODE>. This function
-calls <CODE>open()</CODE>, like we did explicitly in a previous
-section, but also fills the <CODE>comedi_t</CODE> structure with
-lots of goodies -- information that we will need to use
-soon. </P>
-<P>Specifically, we needed to know maxdata for a specific
-subdevice/channel. How about:</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-maxdata=comedi_get_maxdata(file,subdevice,channel);
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>Wow. How easy. And the range type?</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-range_type=comedi_get_rangetype(file,subdevice,channel);
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>Cool. Other information you need to know about a channel
-can be gotten in a similar way.</P>
-
-
-
-<H2><A NAME="ss4.4">4.4 Your second comedi program</A>
-</H2>
-
-
-
-<P>Actually, this is the first comedi program again, just
-that we've added what we've learned.</P>
-
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-#include <stdio.h> /* for printf() */
-#include <comedi.h> /* also included by comedilib.h */
-#include <comedilib.h> /* 'cuz we're using comedilib */
-
-int subdev = 0; /* change this to your input subdevice */
-int chan = 0; /* change this to your channel */
-int range = 0; /* more on this later */
-int aref = 0; /* more on this later */
-
-int main(int argc,char *argv[])
-{
- comedi_t *cf;
- int chan=0;
- lsampl_t data;
- int maxdata,rangetype;
- double volts;
-
- cf=comedi_open("/dev/comedi0");
-
- maxdata=comedi_get_maxdata(cf,subdev,chan);
-
- rangetype=comedi_get_rangetype(cf,subdev,chan);
-
- comedi_data_read(cf->fd,subdev,chan,range,aref,&data);
-
- volts=comedi_to_phys(data,rangetype,range,maxdata);
-
- printf("%d %g\n",data,volts);
-
- return 0;
-}
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-
-
-
-<HR>
-<A HREF="comedilib-5.html">Next</A>
-<A HREF="comedilib-3.html">Previous</A>
-<A HREF="comedilib.html#toc4">Contents</A>
-</BODY>
-</HTML>
+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
- <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.8.1">
- <TITLE>Comedi Documentation: Application-specific functions</TITLE>
- <LINK HREF="comedilib-6.html" REL=next>
- <LINK HREF="comedilib-4.html" REL=previous>
- <LINK HREF="comedilib.html#toc5" REL=contents>
-</HEAD>
-<BODY>
-<A HREF="comedilib-6.html">Next</A>
-<A HREF="comedilib-4.html">Previous</A>
-<A HREF="comedilib.html#toc5">Contents</A>
-<HR>
-<H2><A NAME="s5">5.</A> <A HREF="comedilib.html#toc5">Application-specific functions</A></H2>
-
-
-
-<H2><A NAME="ss5.1">5.1 Digital Input/Output</A>
-</H2>
-
-
-<P>Many boards supported by comedi have digital input and output
-channels. Some boards allow the direction of a channel to be
-specified in software.</P>
-<P>Comedi groups digital channels into subdevice, which is a group
-of digital channels that have the same characteristics. For
-example, digital output lines will be grouped into a digital
-output subdevice, bidirectional digital lines will be grouped
-into a digital I/O subdevice. Thus, there can be multiple
-digital subdevices on a particular board.</P>
-<P>Individual digital lines can be read and written using the
-functions</P>
-<P><CODE>comedi_dio_read(device,subdevice,channel,unsigned int *bit);</CODE>
-<CODE>comedi_dio_write(device,subdevice,channel,unsigned int bit);</CODE></P>
-<P>The direction of bidirectional lines can be configured using
-the function</P>
-<P><CODE>comedi_dio_config(device,subdevice,channel,unsigned int dir);</CODE></P>
-<P>The parameter <CODE>dir</CODE> should be either COMEDI_INPUT or COMEDI_OUTPUT.
-Many digital I/O subdevices group channels into blocks for
-configuring direction. Changing one channel in a block changes
-the entire block.</P>
-<P>Multiple channels can be read and written simultaneously using the
-function</P>
-<P><CODE>comedi_dio_bitfield(device,subdevice,unsigned int write_mask,unsigned int *bits);</CODE></P>
-<P>Each channel is assigned to a bit in the <CODE>write_mask</CODE> and <CODE>bits</CODE>
-bitfield. If a bit in <CODE>write_mask</CODE> is set, the corresponding bit
-in <CODE>*bits</CODE> will be written to the corresponding digital output line.
-Each digital line is then read and placed into <CODE>*bits</CODE>. The value
-of bits in <CODE>*bits</CODE> corresponding to digital output lines is
-undefined and device-specific. Channel 0 is the least significant
-bit in the bitfield; channel 31 is the most significant bit. Channels
-higher than 31 cannot be accessed using this method.</P>
-
-
-
-<H2><A NAME="ss5.2">5.2 Slowly-varying inputs</A>
-</H2>
-
-
-
-<P>Sometimes, your input channels change slowly enough that
-you are able to average many sucessive input values to get a
-more accurate measurement of the actual value. In general,
-the more samples you average, the better your estimate
-gets, roughly by a factor of sqrt(number_of_samples).
-Obviously, there are limitations to this:</P>
-
-<P>
-<UL>
-<LI>you are ultimately limited by "spurious free dynamic range"
-</LI>
-<LI>you need to have _some_ noise on the input channel,
-otherwise you will be averaging the same number N times.
-</LI>
-<LI>the more noise you have, the greater your SFDR, but it
-takes many more samples to compensate for the increased
-noise
-</LI>
-<LI>if you feel the need to average samples for 2 seconds,
-your signal will need to be _very_ slowly-varying, i.e.,
-not varying more than your target uncertainty for the
-entire 2 seconds.
-</LI>
-</UL>
-</P>
-<P>As you might have guessed, the comedi library has functions
-to help you in your quest to accurately measure slowly varying
-inputs. I use these functions to measure thermocouple voltages
--- actually, the library functions came from a section of code
-that was previously part of the thermocouple reading program.</P>
-<P>The comedi self-calibration utility also uses these functions.
-On some hardware, it is possible to tell it to measure an
-internal stable voltage reference, which is typically going
-to be very slowly varying -- on the kilosecond time scale
-or more. So it is reasonable to measure millions of samples,
-to get a very accurate measurement of the A/D converter output
-value that corresponds to the voltage reference. Sometimes,
-however, this is overkill, since there is no need to
-perform a part-per-million calibration to a standard that
-is only accurate to part-per-thousand.</P>
-
-
-
-<H2><A NAME="command_section"></A> <A NAME="ss5.3">5.3 Commands</A>
-</H2>
-
-
-
-<P>Many data acquisition devices have the capability to directly
-control acquisition using either an on-board timer or an external
-triggering input. Comedi commands are used to control this kind
-of acquisition. The
-<A HREF="comedilib-6.html#comedi_cmd">comedi_cmd</A> structure is
-used to control acquisition and query the capabilities of a device
-(see also
-<A HREF="comedilib-6.html#comedi_command">comedi_command()</A>,
-<A HREF="comedilib-6.html#comedi_command_test">comedi_command_test()</A>, and
-<A HREF="comedilib-6.html#comedi_get_cmd_src_mask">comedi_get_cmd_src_mask()</A>).</P>
-<P>Commands specify a particular data acquisition sequence, which
-is comprised of a number of scans. Each scan is comprised of
-a number of conversions, which usually corresponds to a single
-A/D or D/A conversion. The start and end of the sequence, and
-the start and end of each scan, and each conversion is called an
-event.</P>
-<P>Each of these 5 types of events are caused by a triggering
-source, specified through the <CODE>*_src</CODE> members of the
-<A HREF="comedilib-6.html#comedi_cmd">comedi_cmd</A> structure. The source types are:</P>
-<P>
-<UL>
-<LI>TRIG_NONE: don't ever cause an event</LI>
-<LI>TRIG_NOW: cause event to occur immediately</LI>
-<LI>TRIG_FOLLOW: see notes below</LI>
-<LI>TRIG_TIME: cause event to occur at a particular time</LI>
-<LI>TRIG_TIMER: cause event to occur repeatedly at a specific rate</LI>
-<LI>TRIG_COUNT: cause event when count reaches specific value</LI>
-<LI>TRIG_EXT: external signal causes event</LI>
-<LI>TRIG_INT: internal signal causes event</LI>
-<LI>TRIG_OTHER: driver-specific meaning</LI>
-</UL>
-</P>
-<P>Not all triggers are applicable to all events. Supported triggers
-for specific events depend significantly on your particular
-device. The
-<A HREF="comedilib-6.html#comedi_get_cmd_src_mask">comedi_get_cmd_src_mask()</A>
-function is useful for determining what triggers a subdevice supports.</P>
-<P>For every trigger, there is a corresponding
-argument (the <CODE>*_arg</CODE> members of the
-<A HREF="comedilib-6.html#comedi_cmd">comedi_cmd</A>
-structure) whose meaning depends on the type of trigger. The meanings
-of the arguments are as follows:</P>
-<P>TRIG_NONE is typically used only as a <CODE>stop_src</CODE>. The argument for TRIG_NONE
-is reserved and should be set to 0.</P>
-<P>TRIG_NOW is most often used as a <CODE>start_src</CODE>. The argument for TRIG_NOW is
-the number of nanoseconds between when the command is issued and when
-the event should occur. In the case of using TRIG now as a <CODE>start_src</CODE>,
-it indicates a delay between issuing the command and the start of
-acquisition. Most drivers only support a delay of 0.</P>
-<P>TRIG_FOLLOW is a special type of trigger for events that trigger on
-the completion of some other, logically connected event. The argument
-is reserved and should be set to 0. When used
-as a <CODE>scan_begin_src</CODE>, it indicates that a trigger should occur as a
-logical continuation of convert events. This is done in order to
-properly describe boards that do not have separate timers for
-convert and scan_begin events. When used as a <CODE>start_src</CODE> for analog
-output subdevices, it indicates that conversion of output samples
-should begin when samples are written to the buffer.</P>
-<P>TRIG_TIME is reserved for future use.</P>
-<P>TRIG_TIMER is most often used as a <CODE>convert_src</CODE>, a <CODE>scan_begin_src</CODE>, or
-both. It indicates that triggers should occur at a specific rate.
-The argument specifies the interval between triggers in nanoseconds.</P>
-<P>TRIG_COUNT is used for <CODE>scan_end_src</CODE> and <CODE>stop_src</CODE>. It indicates that
-a trigger should occur when the specified number of corresponding
-lower-level triggers (convert and scan_begin, respectively) occur.
-The argument is the count of lower-level triggers.</P>
-<P>TRIG_EXT can be useful as any of the trigger sources. It indicates
-that an external digital line should be used to trigger the event.
-The exact meaning of digital line is device-dependent. Some devices
-have one dedicated line, others may allow generic digital input
-lines to be used. The argument indicates the particular external
-line to use as the trigger.</P>
-<P>TRIG_INT is typically used as a <CODE>start_src</CODE>. This trigger occurs when
-the application performs an INSN_INTTRIG instruction. Using TRIG_INT
-is a method by which the application can accurately record the time of
-the start of acquisition, since the parsing and setup time of a
-particular command may be significant. The argument associated with
-TRIG_INT is reserved and should be set to 0.</P>
-<P>TRIG_OTHER can be useful as any of the trigger sources. The exact
-meaning of TRIG_OTHER is driver-specific, and implements a feature
-that otherwise does not fit into the command interface. Configuration
-of TRIG_OTHER features are done by INSN_CONFIG insns. The argument
-is reserved and should be set to 0.</P>
-<P>Ths <CODE>subdev</CODE> member of the
-<A HREF="comedilib-6.html#comedi_cmd">comedi_cmd</A>
-structure is the index of the subdevice the command is intended for. The
-<A HREF="comedilib-6.html#comedi_find_subdevice_by_type">comedi_find_subdevice_by_type()</A>
-function can be useful in discovering the index of your desired subdevice.</P>
-<P>The <CODE>chanlist</CODE> member of the
-<A HREF="comedilib-6.html#comedi_cmd">comedi_cmd</A>
-structure should point to an array whose number of elements is specificed by <CODE>chanlist_len</CODE>
-(this will generally be the same as the scan_end_arg).
-The chanlist specifies the sequence of channels and gains (and analog references)
-that should be stepped through for each scan. The elements of the chanlist array
-should be initialized by packing the channel, range and reference information
-together with the
-<A HREF="comedilib-6.html#CR_PACK">CR_PACK()</A> macro.</P>
-<P>The <CODE>data</CODE> and <CODE>data_len</CODE> members can be safely ignored when issueing commands
-from a user-space program. They only have meaning when a command is sent from a kernel
-module using the kcomedilib interface, in which case they specify the buffer where
-the driver should write/read its data to/from.</P>
-<P>The final member of the
-<A HREF="comedilib-6.html#comedi_cmd">comedi_cmd</A> structure is <CODE>flags</CODE>.
-The following flags are valid, and can be bitwise-or'd together.</P>
-<P>
-<UL>
-<LI>TRIG_BOGUS: do the motions??</LI>
-<LI>TRIG_DITHER: enable dithering??</LI>
-<LI>TRIG_DEGLITCH: enable deglitching??</LI>
-<LI>TRIG_RT: ask driver to use a hard real-time interrupt handler. This will
-reduce latency in handling interrupts from your data aquisition hardware. It can
-be useful if you are sampling at high frequency, or if your hardware has a small onboard
-fifo. You must have a real-time kernel (RTAI or RTLinux) and must compile
-comedi with real-time support or this flag will do nothing.</LI>
-<LI>TRIG_CONFIG: perform configuration, not triggering. This is a legacy of the
-deprecated comedi_trig_struct, and has no function at present.</LI>
-<LI>TRIG_WAKE_EOS: some drivers will change their behaviour when this flag is set,
-trying to transfer data at the end of every scan (instead of, for example, passing
-data in chunks whenever the board's onboard fifo is half full). This flag
-may degrade a driver's performance at high frequencies.</LI>
-<LI>TRIG_WRITE: write to bidirectional devices. Could be useful in principle, if someone
-wrote a driver that supported commands for a digital i/o device that could do either
-input or output.</LI>
-</UL>
-
-There are also a few flags that indicate how timing arguments should be rounded
-if the hardware cannot achieve the exact timing requested.
-<UL>
-<LI>TRIG_ROUND_NEAREST: round to nearest supported timing period, the default.</LI>
-<LI>TRIG_ROUND_DOWN: round period down.</LI>
-<LI>TRIG_ROUND_UP: round period up.</LI>
-<LI>TRIG_ROUND_UP_NEXT: this one doesn't do anything, and I don't know what it was intended
-to do??</LI>
-</UL>
-</P>
-
-
-<P>The typical sequence for executing a command is to first send
-the command through
-<A HREF="comedilib-6.html#comedi_command_test">comedi_command_test()</A>
-once or twice. The test will check that the command is valid for the particular
-device, and often makes some adjustments to the command arguments, which
-can then be read back by the user to see the actual values used. The
-command is executed with
-<A HREF="comedilib-6.html#comedi_command">comedi_command()</A>. For input/output commands, data
-is read from or written to the device file /dev/comedi[0..3] you are using.</P>
-
-<HR>
-<A HREF="comedilib-6.html">Next</A>
-<A HREF="comedilib-4.html">Previous</A>
-<A HREF="comedilib.html#toc5">Contents</A>
-</BODY>
-</HTML>
+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
- <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.8.1">
- <TITLE>Comedi Documentation: Libcomedi Reference</TITLE>
- <LINK HREF="comedilib-5.html" REL=previous>
- <LINK HREF="comedilib.html#toc6" REL=contents>
-</HEAD>
-<BODY>
-Next
-<A HREF="comedilib-5.html">Previous</A>
-<A HREF="comedilib.html#toc6">Contents</A>
-<HR>
-<H2><A NAME="s6">6.</A> <A HREF="comedilib.html#toc6">Libcomedi Reference</A></H2>
-
-
-
-<H2><A NAME="ss6.1">6.1 Constants and Macros</A>
-</H2>
-
-
-
-<H3><A NAME="CR_PACK"></A> CR_PACK()</H3>
-
-
-<P><CODE>CR_PACK(channel, range, aref)</CODE></P>
-<P><CODE>CR_PACK</CODE> is used to initialize the elements of the <CODE>chanlist array</CODE> in the
-<A HREF="#comedi_cmd">comedi_cmd</A> structure, and the <CODE>chanspec</CODE> member
-of the
-<A HREF="#comedi_insn">comedi_insn</A> structure.</P>
-<P>The <CODE>channel</CODE> argument is the channel you wish to use, with the channel numbering
-starting at zero.</P>
-<P>The <CODE>range</CODE> is an index, starting at zero, whose meaning
-is device dependent. The
-<A HREF="#comedi_get_n_ranges">comedi_get_n_ranges()</A> and
-<A HREF="#comedi_get_range">comedi_get_range()</A> functions
-are useful in discovering information about the available ranges.</P>
-<P>The <CODE>aref</CODE> argument indicates what reference you want the device to use. It
-can be any of the following:
-<UL>
-<LI>AREF_GROUND is for inputs/outputs referenced to ground</LI>
-<LI>AREF_COMMON is for a `common' reference (the low inputs of all the channels are tied
-together, but are isolated from ground)</LI>
-<LI>AREF_DIFF is for differential inputs/outputs</LI>
-<LI>AREF_OTHER is for any reference that does not fit into the above categories</LI>
-</UL>
-
-Particular drivers may or may not use the AREF flags. If they are not supported, they
-are silently ignored.</P>
-
-<P>Source: <CODE>/include/comedi.h</CODE></P>
-
-
-<H3>RANGE_LENGTH() <I>(deprecated)</I></H3>
-
-<P>
-<A NAME="RANGE_LENGTH"></A> </P>
-<P><CODE>RANGE_LENGTH(rangetype)</CODE></P>
-
-<P>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.</P>
-
-<P>The RANGE_LENGTH() macro returns the length of the array that is
-specified by the rangetype token.</P>
-
-<P>The RANGE_LENGTH() macro is deprecated, and should not be used in
-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.</P>
-
-
-
-<H2><A NAME="ss6.2">6.2 Data Types and Structures</A>
-</H2>
-
-
-<H3><A NAME="comedi_t"></A> comedi_t</H3>
-
-<P>The data type <CODE>comedi_t</CODE> is used to represent an open Comedi
-device. A valid <CODE>comedi_t</CODE> pointer is returned by a successful
-call to <CODE>comedi_open()</CODE>, and should be used for subsequent
-access to the device.
-It is a transparent type, and pointers to type <CODE>comedi_t</CODE>
-should not be dereferenced by the application.</P>
-
-
-
-<H3><A NAME="sampl_t"></A> sampl_t</H3>
-
-<P>The data type <CODE>sampl_t</CODE> is one of the generic types used to represent
-data values in libcomedi. It is used in a few places where a shorter
-data type is useful, but is limited to 16 bits on the i386 architecture.</P>
-
-
-
-<H3><A NAME="lsampl_t"></A> lsampl_t</H3>
-
-<P>The data type <CODE>lsampl_t</CODE> is one of the generic types used to represent
-data values in libcomedi. It is currently defined to be <CODE>unsigned int</CODE>.</P>
-
-
-
-
-
-<H3><A NAME="comedi_trig_struct"></A> comedi_trig_struct <I>(deprecated)</I></H3>
-
-
-<P>The <CODE>comedi_trig</CODE> structure</P>
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-struct comedi_trig_struct{
- unsigned int subdev; /* subdevice */
- unsigned int mode; /* mode */
- unsigned int flags;
- unsigned int n_chan; /* number of channels */
- unsigned int *chanlist; /* channel/range list */
- sampl_t *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];
-}
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>The <CODE>comedi_trig</CODE> structure is a control structure used by the
-COMEDI_TRIG ioctl, an older method of communicating
-instructions to the driver and hardware. Use of comedi_trig is
-deprecated, and should not be used in new applications.</P>
-
-<P>This structure is defined as part of the Comedi kernel interface.</P>
-
-
-<H3><A NAME="comedi_sv_t"></A> comedi_sv_t</H3>
-
-
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-struct comedi_sv_struct{
- comedi_t *dev;
- unsigned int subdevice;
- unsigned int chan;
-
- /* range policy */
- int range;
- int aref;
-
- /* number of measurements to average (for ai) */
- int n;
-
- lsampl_t maxdata;
-}
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-<P>The <CODE>comedi_sv_t</CODE> structure is used by the <CODE>comedi_sv_*()</CODE>
-functions to provide a simple method of accurately measuring
-slowly varying inputs. See the relevant section for more
-details.</P>
-
-
-
-<H3><A NAME="comedi_cmd"></A> comedi_cmd</H3>
-
-
-<P>
-<BLOCKQUOTE><CODE>
-<PRE>
-typedef struct comedi_cmd_struct comedi_cmd;
-
-struct comedi_cmd_struct{
- unsigned int subdev;
- unsigned int flags;
-
- unsigned int start_src;
- unsigned int start_arg;
-
- unsigned int scan_begin_src;
- unsigned int scan_begin_arg;
-
- unsigned int convert_src;
- unsigned int convert_arg;
-
- unsigned int scan_end_src;
- unsigned int scan_end_arg;
-
- unsigned int stop_src;
- unsigned int stop_arg;
-
- unsigned int *chanlist;
- unsigned int chanlist_len;
-
- sampl_t *data;
- unsigned int data_len;
-};
-</PRE>
-</CODE></BLOCKQUOTE>
-</P>
-
-<P>More information on using commands can be found in the
-<A HREF="comedilib-5.html#command_section">command</A> section.</P>
-
-<P>This structure is defined as part of the Comedi kernel interface.</P>
-
-
-<H3><A NAME="comedi_insn"></A> comedi_insn</H3>
-
-
-<P>undocumented</P>
-
-<P>Related functions are described in section XXX.</P>
-
-<P>This structure is defined as part of the Comedi kernel interface.</P>
-
-
-
-<H3><A NAME="comedi_range"></A> comedi_range</H3>
-
-
-<P>undocumented</P>
-
-
-
-<H2><A NAME="ss6.3">6.3 Functions</A>
-</H2>
-
-
-
-<H3><A NAME="comedi_close"></A> comedi_close()</H3>
-
-
-<P><CODE>void comedi_close(comedi_t *it);</CODE></P>
-
-<P>Closes a device previously opened by comedi_open().</P>
-
-<P>The return type of this function will change to <CODE>int</CODE>, in
-order to match <CODE>fclose</CODE>.</P>
-
-<P>Source: <CODE>/lib/comedi.c</CODE></P>
-
-
-<H3><A NAME="comedi_command"></A> comedi_command()</H3>
-
-
-<P><CODE>int comedi_command(comedi_t *it, comedi_cmd *cmd);</CODE></P>
-<P>Issues the command pointed at by <CODE>cmd</CODE> to the open device <CODE>it</CODE>. It
-is usually necessary to pass the command through
-<A HREF="#comedi_command_test">comedi_command_test()</A> to
-fix up the command before it can be successfully executed with
-<CODE>comedi_command()</CODE>.
-See
-<A HREF="comedilib-5.html#command_section">commands</A> for more information.</P>
-
-<P>Source: <CODE>/lib/comedi.c</CODE></P>
-
-
-<H3><A NAME="comedi_command_test"></A> comedi_command_test()</H3>
-
-
-<P><CODE>int comedi_command_test(comedi_t *it, comedi_cmd *cmd);</CODE></P>
-
-<P>Tests and fixes up the command pointed at by <CODE>cmd</CODE> according
-to the limitations of the driver configured on the open device <CODE>it</CODE>.
-The return value has the following meaning:
-<UL>
-<LI>0: the command passed the test and can be successfully executed
-by
-<A HREF="#comedi_command">comedi_command()</A>. The one exception
-to this rule is that the test will allow a NULL chanlist for the command.</LI>
-<LI>1: invalid trigger. One or more of the trigger sources (the *_src members
-of the
-<A HREF="#comedi_cmd">comedi_cmd</A> structure) is not
-supported by the driver.</LI>
-<LI>2: incompatible triggers. Two or more of the triggers selected are
-incompatible with each other. For example, a driver might allow either
-the scan_begin_src or the convert_src to be TRIG_TIMER, but not both.</LI>
-<LI>3: argument invalid. One or more argument is invalid, for example
-a timing argument might be in excess of the card's maximum speed. The
-command test will correct the arguments by modifying the command pointed
-at by <CODE>cmd</CODE>.</LI>
-<LI>4: argument fix up. The command underwent minor adjustment and should
-now be valid. For example, a timing argument might not be exactly achievable
-by the card so the timing argument will be adjusted to the actual timing
-the card will use.</LI>
-<LI>negative: some other error has occured.</LI>
-</UL>
-
-See
-<A HREF="comedilib-5.html#command_section">commands</A> for more information.</P>
-
-<P>Source: <CODE>/lib/comedi.c</CODE></P>
-
-
-<H3><A NAME="comedi_data_read"></A> comedi_data_read()</H3>
-
-
-<P><CODE>int comedi_data_read(comedi_t *it,unsigned int subd,unsigned int chan,
-unsigned int range,unsigned int aref,lsampl_t *data);</CODE></P>
-
-<P>Reads a single sample on the channel that
-is specified by the comedi device <CODE>it</CODE>, the
-subdevice <CODE>subd</CODE>, and the channel <CODE>chan</CODE>.
-For the A/D conversion (if appropriate),
-the device is configured to use range specification
-<CODE>range</CODE> and (if appropriate) analog reference type
-<CODE>aref</CODE>. Analog reference types that are not supported
-by the device are silently ignored.</P>
-
-<P><CODE>comedi_data_read()</CODE> reads one data value from
-the specified channel and places the
-data value that is read in the location pointed to by
-<CODE>data</CODE>.</P>
-
-<P>On sucess, <CODE>comedi_data_read()</CODE> returns 0. If there is an
-error, -1 is returned.</P>
-
-<P>Valid analog reference numbers are:</P>
-<P>
-<UL>
-<LI>AREF_GROUND Reference to analog ground</LI>
-<LI>AREF_COMMON Reference to analog common</LI>
-<LI>AREF_DIFF Differential reference</LI>
-<LI>AREF_OTHER Board-specific meaning</LI>
-</UL>
-</P>
-<P>Valid data values returned by these function is an unsigned integer
-less than or equal to <CODE>maxdata</CODE>, which is channel-dependent.
-Conversion of these data value to physical units can be performed
-by <CODE>
-<A HREF="#comedi_to_phys">comedi_to_phys()</A></CODE>.</P>
-<P>Source: <CODE>/lib/data.c</CODE></P>
-
-
-<H3>comedi_data_write()</H3>
-
-
-<P><CODE>int comedi_data_write(comedi_t *it,unsigned int subd,unsigned int chan,
-unsigned int range,unsigned int aref,lsampl_t data);</CODE></P>
-
-<P>Writes a single sample on the channel that
-is specified by the comedi device <CODE>it</CODE>, the
-subdevice <CODE>subd</CODE>, and the channel <CODE>chan</CODE>.
-For the D/A conversion (if appropriate), the device is
-configured to use range specification
-<CODE>range</CODE> and (if appropriate) analog reference type
-<CODE>aref</CODE>. Analog reference types that are not supported
-by the device are silently ignored.</P>
-<P><CODE>comedi_data_write()</CODE> writes the data value
-specified by the argument <CODE>data</CODE> to
-the specified channel.</P>
-<P>On sucess, <CODE>comedi_data_write()</CODE> returns 0. If there is an error, -1 is
-returned.</P>
-<P>Valid analog reference numbers are:</P>
-<P>
-<UL>
-<LI>AREF_GROUND Reference to analog ground</LI>
-<LI>AREF_COMMON Reference to analog common</LI>
-<LI>AREF_DIFF Differential reference</LI>
-<LI>AREF_OTHER Board-specific meaning</LI>
-</UL>
-</P>
-<P>Valid data values used by these functions is an unsigned integer
-less than or equal to <CODE>maxdata</CODE>, which is channel-dependent.
-Conversion of physical units to these data value can be performed
-by <CODE>
-<A HREF="#comedi_from_phys">comedi_from_phys()</A></CODE>.</P>
-<P>Source: <CODE>/lib/data.c</CODE></P>
-
-
-
-<H3>comedi_dio_bitfield();</H3>
-
-<P><CODE>int comedi_dio_bitfield(comedi_t *it,unsigned int subd,unsigned
-int write_mask,unsigned int *bits);</CODE></P>
-
-<P>The function <CODE>comedi_dio_bitfield()</CODE> allows multiple channels to
-be read simultaneously from a digital input or digital I/O device.
-The parameter <CODE>write_mask</CODE> and the value pointed to by <CODE>bits</CODE>
-are interpreted as bit fields, with the least significant bit
-representing channel 0. For each bit in <CODE>write_mask</CODE> that is
-set, the cooresponding bit in <CODE>*bits</CODE> is written to the digital
-output channel. Each digital input channel is read, and the result
-placed in the approprate bits in <CODE>*bits</CODE>.</P>
-
-<P>The current implementation reads and writes bits using separate
-system calls, which is not ideal. When the kernel driver supports
-simultaneous reading/writing, this will be fixed in the library.</P>
-
-<P>It should be noted that it is not possible to access channels
-greater than 31 using this function.</P>
-
-<P>Source: <CODE>/lib/dio.c</CODE></P>
-
-
-
-<H3>comedi_dio_config()</H3>
-
-<P><CODE>int comedi_dio_config(comedi_t *it,unsigned int subd,unsigned
-int chan,unsigned int dir);</CODE></P>
-
-<P>The function <CODE>comedi_dio_config</CODE> configures individual channels
-in a digital I/O subdevice to be either input or output, depending
-on the value of parameter <CODE>dir</CODE>. Depending on the capabilities
-of the hardware device, multiple channels may be affected by
-a single call to <CODE>comedi_dio_config</CODE>.</P>
-
-<P>Valid directions are:
-<UL>
-<LI> COMEDI_INPUT</LI>
-<LI> COMEDI_OUTPUT</LI>
-</UL>
-</P>
-<P>Source: <CODE>/lib/dio.c</CODE></P>
-
-
-
-<H3>comedi_dio_read()</H3>
-
-<P><CODE>int comedi_dio_read(comedi_t *it,unsigned int subd,unsigned int
-chan,unsigned int *bit);</CODE></P>
-
-<P>The function reads the status of channel <CODE>chan</CODE> belonging to the digital
-input subdevice <CODE>subd</CODE> of device <CODE>it</CODE>. The result, 0 or 1, is stored
-in bit. Returns -1 on failure.</P>
-
-<P>This function is equivalent to <CODE>comedi_data_read(it,subd,chan,0,0,bit)</CODE>.</P>
-
-<P>Source: <CODE>/lib/dio.c</CODE></P>
-
-
-<H3>comedi_dio_write()</H3>
-
-<P><CODE>int comedi_dio_write(comedi_t *it,unsigned int subd,unsigned
-int chan,unsigned int bit);</CODE></P>
-
-<P>The function writes the value of <CODE>bit</CODE>, 0 or 1, to channel <CODE>chan</CODE>,
-belonging to the digital output device <CODE>subd</CODE> of device <CODE>it</CODE>. Returns
--1 on failure.</P>
-
-<P>Source: <CODE>/lib/dio.c</CODE></P>
-
-
-<H3>comedi_fileno()</H3>
-
-
-<P><CODE>int comedi_fileno(comedi_t *it);</CODE></P>
-
-<P>The function <CODE>comedi_fileno</CODE>
-returns the integer descriptor for the handle <CODE>it</CODE>. It
-is equivalent to the standard function <CODE>fileno</CODE>. If
-<CODE>it</CODE> is an invalid <CODE>comedi_t</CODE> pointer, the function
-returns -1 and sets the appropriate libcomedi error value.</P>
-<P>Source: <CODE>/lib/comedi.c</CODE></P>
-
-
-
-<H3>comedi_find_range()</H3>
-
-
-<P><CODE>int comedi_find_range(comedi_t *it, unsigned int subdevice, unsigned
-int chan, unsigned int unit, double min, double max);</CODE></P>
-
-<P>The function <CODE>comedi_find_range</CODE> tries to
-locate the optimal (smallest) range for the channel <CODE>chan</CODE>
-belonging to a <CODE>subdevice</CODE> of the comedi device <CODE>it</CODE>,
-that includes both <CODE>min</CODE> and <CODE>max</CODE> in <CODE>units</CODE>.
-If it finds a matching range, it returns its index. If no
-matching range is available, it returns -1.</P>
-
-<P>Valid units are:</P>
-<P>
-<UL>
-<LI>UNIT_volt</LI>
-<LI>UNIT_mA</LI>
-<LI>UNIT_none</LI>
-</UL>
-</P>
-<P>Source: <CODE>/lib/range.c</CODE></P>
-
-
-
-<H3><A NAME="comedi_errno"></A> comedi_errno()</H3>
-
-<P><CODE>int comedi_errno(void);</CODE></P>
-
-<P>The function <CODE>comedi_errno()</CODE>
-returns an integer describing the most recent comedilib error. This
-integer may be used as the <CODE>errnum</CODE> parameter for
-<CODE>
-<A HREF="#comedi_strerror">comedi_strerror()</A></CODE>.</P>
-<P>When a libcomedi function fails, it usually returns -1 or
-NULL, depending on the return type. An internal library
-variable stores an error number, which can be retrieved with
-<CODE>comedi_errno()</CODE>. This error number can be
-converted to a human-readable form by the functions
-<CODE>
-<A HREF="#comedi_perror">comedi_perror()</A></CODE>
-and <CODE>
-<A HREF="#comedi_strerror">comedi_strerror()</A></CODE>.</P>
-<P>These functions are intended to mimic the behavior of the
-standard C library functions <CODE>perror()</CODE>,
-<CODE>strerror</CODE>, and <CODE>errno()</CODE>. In particular,
-libcomedi functions sometimes return an error that is generated
-by the C library; the Comedi error message in this case
-is the same as the C library.</P>
-<P>Source: <CODE>/lib/error.c</CODE></P>
-
-
-
-<H3><A NAME="comedi_find_subdevice_by_type"></A> comedi_find_subdevice_by_type()</H3>
-
-
-<P><CODE>int comedi_find_subdevice_by_type(comedi_t *it,int type,unsigned int
-start_subdevice);</CODE></P>
-
-<P>The function <CODE>comedi_find_subdevice_by_type</CODE> tries to
-locate a subdevice belonging to comedi device <CODE>it</CODE>,
-having type <CODE>type</CODE>, starting with the subdevice
-<CODE>start_subdevice</CODE>. If it finds the requested subdevice,
-it returns its index. If it does not locate the requested
-subdevice, it returns -1 and sets the comedi error number to
-"subdevice not found". If there is an error, the function
-returns -1 and sets the appropriate error.</P>
-
-<P>For subdevice types, see the manual page for the function
-<CODE>
-<A HREF="#comedi_get_subdevice_type">comedi_get_subdevice_type()</A></CODE>.</P>
-<P>Source: <CODE>/lib/get.c</CODE></P>
-
-
-
-<H3><A NAME="comedi_from_phys"></A> comedi_from_phys()</H3>
-
-
-<P><CODE>lsampl_t comedi_from_phys(double data, comedi_range *rng,
-lsampl_t maxdata);</CODE></P>
-<P>Converts data given in physical units (<CODE>data</CODE>) into sample values
-(lsampl_t, between 0 and maxdata). The parameter <CODE>rng</CODE>
-represents the conversion information to use, and the parameter
-<CODE>maxdata</CODE> represents the maximum possible data value for the
-channel that the data will be written to.</P>
-
-<P>Source: <CODE>/lib/range.c</CODE></P>
-
-
-
-<H3>comedi_get_board_name()</H3>
-
-
-<P><CODE>char *comedi_get_board_name(comedi_t *it);</CODE></P>
-<P>The function <CODE>comedi_get_board_name</CODE> returns a pointer
-to a string containing the name of the device. This pointer is
-valid until the comedi descriptor <CODE>it</CODE> is closed. This
-function returns <CODE>NULL</CODE> if there is an error.</P>
-<P>Source: <CODE>/lib/get.c</CODE></P>
-
-
-<H3><A NAME="comedi_get_cmd_src_mask"></A> comedi_get_cmd_src_mask()</H3>
-
-
-<P><CODE>int comedi_get_cmd_src_mask(comedi_t *dev, unsigned int subdevice,
-comedi_cmd *cmd);</CODE></P>
-<P>undocumented</P>
-<P>Source: <CODE>/lib/cmd.c</CODE></P>
-
-
-<H3>comedi_get_driver_name()</H3>
-
-
-<P><CODE>char *comedi_get_driver_name(comedi_t *it);</CODE></P>
-<P>The function <CODE>comedi_get_driver_name</CODE> returns a pointer
-to a string containing the name of the driver being used by comedi
-for the comedi device represented by <CODE>it</CODE>. This pointer is
-valid until the comedi descriptor <CODE>it</CODE> is closed. This
-function returns <CODE>NULL</CODE> if there is an error.</P>
-<P>Source: <CODE>/lib/get.c</CODE></P>
-
-
-
-<H3>comedi_get_maxdata()</H3>
-
-
-<P><CODE>lsampl_t comedi_get_maxdata(comedi_t *it,unsigned int
-subdevice,unsigned int chan);</CODE></P>
-
-<P>The function <CODE>comedi_get_maxdata()</CODE> returns the maximum
-valid data value for channel <CODE>chan</CODE> of subdevice
-<CODE>subdevice</CODE> belonging to the comedi device <CODE>it</CODE>
-This function returns 0 on error.</P>
-<P>Source: <CODE>/lib/get.c</CODE></P>
-
-
-
-<H3>comedi_get_n_channels()</H3>
-
-
-<P><CODE>int comedi_get_n_channels(comedi_t *it,unsigned int subdevice);</CODE></P>
-<P>The function <CODE>comedi_get_n_channels()</CODE> returns the number
-of channels of the subdevice belonging to the comedi device <CODE>it</CODE>
-and having index <CODE>subdevice</CODE>. This function returns -1 on error.</P>
-<P>Source: <CODE>/lib/get.c</CODE></P>
-
-
-
-<H3><A NAME="comedi_get_n_ranges"></A> comedi_get_n_ranges()</H3>
-
-
-<P><CODE>int comedi_get_n_ranges(comedi_t *it,unsigned int subdevice, unsigned int
-chan);</CODE></P>
-<P>The function <CODE>comedi_get_n_ranges()</CODE> returns the number
-of ranges of the channel <CODE>chan</CODE> belonging to the <CODE>subdevice</CODE>
-of the comedi device <CODE>it</CODE>. This function returns -1 on error.</P>
-<P>Source: <CODE>/lib/range.c</CODE></P>
-
-
-
-<H3>comedi_get_n_subdevices()</H3>
-
-
-<P><CODE>int comedi_get_n_subdevices(comedi_t *it);</CODE></P>
-<P>The function <CODE>comedi_get_n_subdevices</CODE> returns the
-number of subdevices associated with the comedi descriptor
-<CODE>it</CODE>, or -1 if there is an error.</P>
-<P>Source: <CODE>/lib/get.c</CODE></P>
-
-
-
-<H3><A NAME="comedi_get_range"></A> comedi_get_range()</H3>
-
-
-<P><CODE>comedi_range * comedi_get_range(comedi_t *it,unsigned int subdevice,unsigned int chan,unsigned int
-range);</CODE></P>
-<P>The function <CODE>comedi_get_range</CODE> returns a pointer to a
-comedi_range structure that contains information that can be used to
-convert sample values to or from physical units. The pointer is valid
-until the comedi device <CODE>it</CODE> is closed. If there is an
-error, NULL is returned.</P>
-<P>Source: <CODE>/lib/get.c</CODE></P>
-
-
-<H3>comedi_get_rangetype() <I>deprecated</I></H3>
-
-
-<P><CODE>int comedi_get_rangetype(comedi_t *it,unsigned int subdevice,unsigned int
-chan);</CODE></P>
-<P>The function <CODE>comedi_get_rangetype()</CODE> returns an integer
-that represents the number of range specifications available for a
-particular channel <CODE>chan</CODE> of the subdevice <CODE>subdevice</CODE>, as well as a conversion table to convert sample
-values to/from physical units.</P>
-<P>The macro
-<CODE>RANGE_LENGTH(rangetype)</CODE>
-can be used to determine the number of range specifications for a given
-range type.</P>
-
-<P>This function is deprecated and should not be used in new code.</P>
-<P>Source: <CODE>/lib/get.c</CODE></P>
-
-
-<H3><A NAME="comedi_get_subdevice_type"></A> comedi_get_subdevice_type()</H3>
-
-
-<P><CODE>int comedi_get_subdevice_type(comedi_t *it,unsigned int subdevice);</CODE></P>
-<P>The function <CODE>comedi_get_subdevice_type()</CODE> returns an
-integer describing the type of subdevice that belongs to the comedi
-device <CODE>it</CODE> and has the index <CODE>subdevice</CODE>. The
-function returns -1 is there is an error.</P>
-<P>Valid subdevice types are:</P>
-<P>
-<UL>
-<LI><CODE>COMEDI_SUBD_UNUSED</CODE>
-Subdevice has no functionality, i.e., a place-holder.</LI>
-<LI><CODE>COMEDI_SUBD_AI</CODE> Analog input</LI>
-<LI><CODE>COMEDI_SUBD_AO</CODE> Analog output</LI>
-<LI><CODE>COMEDI_SUBD_DI</CODE> Digital input</LI>
-<LI><CODE>COMEDI_SUBD_DO</CODE> Digital output</LI>
-<LI><CODE>COMEDI_SUBD_DIO</CODE>
-Digital input/output. Channels are configurable as to whether they
-are inputs or outputs.</LI>
-<LI><CODE>COMEDI_SUBD_COUNTER</CODE> Counter</LI>
-<LI><CODE>COMEDI_SUBD_TIMER</CODE> Timer</LI>
-<LI><CODE>COMEDI_SUBD_MEMORY</CODE>
-Memory, e.g., EEPROM or dual-ported RAM</LI>
-<LI><CODE>COMEDI_SUBD_CALIB</CODE>
-Calibration DACs</LI>
-<LI><CODE>COMEDI_SUBD_PROC</CODE>
-Processor or DSP</LI>
-</UL>
-</P>
-<P>Source: <CODE>/lib/get.c</CODE></P>
-
-
-<H3>comedi_get_timer() <I>(deprecated)</I></H3>
-
-
-<P><CODE>int comedi_get_timer(comedi_t *it,unsigned int subdev, double
-freq,unsigned int *trigvar, double *actual_freq);</CODE></P>
-
-<P>The function <CODE>comedi_get_timer</CODE> converts the frequency <CODE>freq</CODE>
-to a number suitable to send to the driver in a <CODE>comedi_trig</CODE>
-structure. This function remains for compatibility with very
-old versions of Comedi, that converted sampling rates to timer
-values in the libary. This conversion is now done in the kernel,
-and every device has the timer type <CODE>nanosec_timer</CODE>, indicating
-that timer values are simply a time specified in nanoseconds.</P>
-
-<P>This function is deprecated and should not be used in new applications.</P>
-
-<P>Source: <CODE>/lib/timer.c</CODE></P>
-
-
-<H3>comedi_get_version_code()</H3>
-
-
-<P><CODE>int comedi_get_version_code(comedi_t *it);</CODE></P>
-
-<P>The function <CODE>comedi_get_version_code()</CODE> returns the
-version code of the currently running comedi module. The version
-code is of the form 0x01072b, which is the version code for
-version 1.7.43.</P>
-
-<P>This function is of limited usefulness. A typical mis-application
-of this function is to use it to determine if a certain feature is
-supported. If the application needs
-to know of the existence of a particular feature, an existence
-test function should be written and put in the libcomedi source.</P>
-<P>Source: <CODE>/lib/get.c</CODE></P>
-
-
-<H3>comedi_loglevel()</H3>
-
-
-<P><CODE>int comedi_loglevel(int loglevel);</CODE></P>
-
-<P>This function affects the output of debugging and error messages
-from libcomedi. By increasing the loglevel, additional debugging
-information will be printed. This function returns the previous
-loglevel. Error messages and debugging are printed to the
-stream <CODE>stderr</CODE>. The loglevel can also be affected by the
-environment variable COMEDI_LOGLEVEL.</P>
-
-<P>In order to conserve resources, some debugging information is
-disabled when libcomedi is compiled.</P>
-
-<P>The meaning of the loglevels is as follows:</P>
-<P>
-<UL>
-<LI><CODE>COMEDILIB_LOGLEVEL=0</CODE>
-
-Comedilib prints nothing.
-</LI>
-<LI><CODE>COMEDILIB_LOGLEVEL=1</CODE> (default)
-
-Comedilib only prints error messages when there is a
-self-consistency error (i.e., internal bug).
-</LI>
-<LI><CODE>COMEDILIB_LOGLEVEL=2</CODE>
-
-Comedilib prints an error message when an invalid
-parameter is passed to comedilib.
-</LI>
-<LI><CODE>COMEDILIB_LOGLEVEL=3</CODE>
-
-Comedilib prints an error message whenever an error is generated
-in the comedilib library or is generated in the C library when
-called by comedilib.
-</LI>
-<LI><CODE>COMEDILIB_LOGLEVEL=4</CODE>
-
-Comedilib prints a lot of debugging messages.
-</LI>
-</UL>
-</P>
-<P>Bugs: Libcomedi doesn't currently have much debugging information.</P>
-<P>Source: <CODE>/lib/error.c</CODE></P>
-
-
-<H3>comedi_open()</H3>
-
-
-<P><CODE>comedi_t *comedi_open(char *filename);</CODE></P>
-<P>Opens a comedi device specified by the filename <CODE>filename</CODE>.
-Returns NULL on error. On sucess, it returns a handle that is
-given as a parameter to other libcomedi functions.</P>
-
-<P>You are not supposed to have access to the internals of the
-<CODE>comedi_t</CODE> structure.</P>
-<P>Bugs: Not strictly identical to <CODE>fopen</CODE></P>
-<P>Source: <CODE>/lib/comedi.c</CODE></P>
-
-
-
-<H3><A NAME="comedi_perror"></A> comedi_perror()</H3>
-
-
-<P><CODE>void comedi_perror(const char *s);</CODE></P>
-<P>When a comedilib function fails, it usually returns -1 or
-NULL, depending on the return type. An internal library
-variable stores an error number, which can be retrieved with
-<CODE>
-<A HREF="#comedi_errno">comedi_errno()</A></CODE>.
-This error number can be
-converted to a human-readable form by the functions
-<CODE>comedi_perror()</CODE>
-and <CODE>
-<A HREF="#comedi_strerror">comedi_strerror()</A></CODE>.</P>
-<P>These functions are intended to mimic the behavior of the
-standard C library functions <CODE>perror()</CODE>,
-<CODE>strerror</CODE>, and <CODE>errno()</CODE>. In particular,
-comedilib functions sometimes return an error that is generated
-inside the C library; the comedi error message in this case
-is the same as the C library.</P>
-<P>The function <CODE>comedi_perror()</CODE> prints an error
-message to stderr. The error message consists of the
-argument string, a colon, a space, a description of the error
-condition, and a new line.</P>
-<P>Bugs: Does not support internationalization.</P>
-<P>Source: <CODE>/lib/error.c</CODE></P>
-
-
-
-<H3><A NAME="comedi_strerror"></A> comedi_strerror()</H3>
-
-
-<P><CODE>*comedi_strerror(int errnum);</CODE></P>
-<P>When a comedilib function fails, it usually returns -1 or
-NULL, depending on the return type. An internal library
-variable stores an error number, which can be retrieved with
-<CODE>
-<A HREF="#comedi_errno">comedi_errno()</A></CODE>. This error number can be
-converted to a human-readable form by the functions
-<CODE>
-<A HREF="#comedi_perror">comedi_perror()</A></CODE>
-and <CODE>comedi_strerror()</CODE>.</P>
-<P>These functions are intended to mimic the behavior of the
-standard C library functions <CODE>perror()</CODE>,
-<CODE>strerror</CODE>, and <CODE>errno()</CODE>. In particular,
-comedilib functions sometimes return an error that is generated
-inside the C library; the comedi error message in this case
-is the same as the C library.</P>
-<P>The function <CODE>comedi_strerror()</CODE> returns a pointer to a
-character string
-describing the comedilib error <CODE>errnum</CODE>. The persistence
-of the returned pointer is undefined, and should not be trusted
-after the next libcomedi call. An unrecognized error number will
-return a pointer to the string "undefined error", or similar.</P>
-<P>Bugs: Does not support internationalization.</P>
-<P>Source: <CODE>/lib/error.c</CODE></P>
-
-
-
-<H3>comedi_sv_init()</H3>
-
-
-<P><CODE>int comedi_sv_init(comedi_sv_t *sv,comedi_t *dev,unsigned int subd,
-unsigned int chan);</CODE></P>
-
-<P><CODE>comedi_sv_init</CODE> initializes the slow varying comedi structure
-<CODE>sv</CODE> of the device <CODE>dev</CODE>, the subdevice <CODE>subd</CODE> (analog input) and
-the channel <CODE>chan</CODE>.
-The slow varying comedi structure <CODE>sv</CODE> of type <CODE>
-<A HREF="#comedi_sv_t">comedi_sv_t</A></CODE>
-specifies the signal measurement. The default number of averaged
-samples is 100. Returns zero on success, -1 on error.</P>
-<P>Bugs: comedi_sv_* was very poorly designed.</P>
-<P>Source: <CODE>/lib/sv.c</CODE></P>
-
-
-
-<H3>comedi_sv_update()</H3>
-
-
-<P><CODE>int comedi_sv_update(comedi_sv_t *sv);</CODE></P>
-<P>The function <CODE>comedi_sv_update</CODE> updates the slow varying comedi structure
-<CODE>sv</CODE>.
-Returns zero on success, -1 on error.</P>
-<P>Source: <CODE>/lib/sv.c</CODE></P>
-
-
-
-<H3>int comedi_sv_measure()</H3>
-
-
-<P><CODE>int comedi_sv_measure(comedi_sv_t *it,double *data);</CODE></P>
-<P><CODE>comedi_sv_measure</CODE> measures the slow variing signal. The measurement
-is specified by the slow varying comedi structure <CODE>sv</CODE>, the result is
-stored in <CODE>data</CODE>.
-On success returns the number of samples, -1 on error.</P>
-<P>Source: <CODE>/lib/sv.c</CODE></P>
-
-
-
-<H3><A NAME="comedi_to_phys"></A> comedi_to_phys()</H3>
-
-
-<P><CODE>double comedi_to_phys(lsampl_t data, comedi_range *rng,
-lsampl_t maxdata);</CODE></P>
-<P>Converts data given in sample values (lsampl_t, between 0 and
-maxdata) into physical units (double). The parameter <CODE>rng</CODE>
-represents the conversion information to use, and the parameter
-<CODE>maxdata</CODE> represents the maximum possible data value for the
-channel that the data was read.</P>
-<P>Source: <CODE>/lib/range.c</CODE></P>
-
-
-
-<H3>comedi_trigger() <I>(deprecated)</I></H3>
-
-
-<P><CODE>int comedi_trigger(comedi_t *it,comedi_trig *trig);</CODE></P>
-<P>The function <CODE>comedi_trigger</CODE> instructs comedi to
-perform the command specified by the
-<A HREF="#comedi_trig_struct">trigger structure</A> <CODE>trig</CODE>. Results depend on
-the particular command being issued. If there is an
-error, -1 is returned.</P>
-<P>Lifetime: removal at 1.0.</P>
-<P>Source: <CODE>/lib/comedi.c</CODE></P>
-
-
-
-<H3><A NAME="comedi_get_subdevice_flags"></A> comedi_get_subdevice_flags()</H3>
-
-
-<P><CODE>int comedi_get_subdevice_flags(comedi_t *dev, unsigned int subdevice);</CODE></P>
-
-<P>This function returns a bitfield describing the capabilities of the
-specified subdevice. If there is an error, -1 is returned.</P>
-
-<P>The bits are:</P>
-<P>
-<UL>
-<LI>SDF_BUSY subdevice is running a command</LI>
-<LI>SDF_BUSY_OWNER subdevice is running a command started by
-the file descriptor used by <CODE>dev</CODE>.</LI>
-<LI>SDF_LOCKED subdevice is locked</LI>
-<LI>SDF_LOCKED_OWNER subdevice is locked by the file descriptor used
-by <CODE>dev</CODE>.</LI>
-<LI>SDF_MAXDATA maximum data values are channel dependent</LI>
-<LI>SDF_FLAGS channel flags are channel dependent</LI>
-<LI>SDF_RANGETYPE range types are channel dependent</LI>
-<LI>SDF_MODE0 deprecated</LI>
-<LI>SDF_MODE1 deprecated</LI>
-<LI>SDF_MODE2 deprecated</LI>
-<LI>SDF_MODE3 deprecated</LI>
-<LI>SDF_MODE4 deprecated</LI>
-<LI>SDF_CMD subdevice supports commands</LI>
-<LI>SDF_READABLE subdevice can be read from</LI>
-<LI>SDF_WRITEABLE subdevice can be written to</LI>
-<LI>SDF_RT deprecated</LI>
-<LI>SDF_GROUND subdevice is capable of ground analog reference</LI>
-<LI>SDF_COMMON subdevice is capable of common analog reference</LI>
-<LI>SDF_DIFF subdevice is capable of differential analog reference</LI>
-<LI>SDF_OTHER subdevice is capable of other analog reference</LI>
-<LI>SDF_DITHER subdevice recognizes dither flag</LI>
-<LI>SDF_DEGLITCH subdevice recognizes deglitch flag</LI>
-<LI>SDF_MMAP deprecated</LI>
-<LI>SDF_RUNNING subdevice is acquiring data (i.e., command has not
-completed)</LI>
-<LI>SDF_LSAMPL subdevice uses samples of type lsampl_t (otherwise
-sampl_t)</LI>
-<LI>SDF_PACKED subdevice uses bitfield samples (otherwise it uses
-one sample per channel)</LI>
-</UL>
-</P>
-
-
-
-<P>The bit definitions are part of the Comedi kernel interface.</P>
-
-
-
-<H3><A NAME="comedi_range_is_chan_specific"></A> comedi_range_is_chan_specific()</H3>
-
-
-<P><CODE>int comedi_range_is_chan_specific(comedi_t *dev,unsigned int subdevice);</CODE></P>
-
-<P>If each channel of the specified subdevice has a different range
-specification, this function returns 1. Otherwise, this function
-returns 0. On error, this function returns -1.</P>
-
-
-
-<H3><A NAME="undocumented"></A> Undocumented functions</H3>
-
-
-
-<P>
-<UL>
-<LI>comedi_maxdata_is_chan_specific()</LI>
-<LI>comedi_get_buffer_size()</LI>
-<LI>comedi_get_max_buffer_size()</LI>
-<LI>comedi_set_buffer_size()</LI>
-<LI>comedi_set_max_buffer_size()</LI>
-<LI>comedi_do_insnlist()</LI>
-<LI>comedi_do_insn()</LI>
-<LI>comedi_lock()</LI>
-<LI>comedi_unlock()</LI>
-<LI>comedi_get_cmd_src_mask()</LI>
-<LI>comedi_get_cmd_generic_timed()</LI>
-<LI>comedi_cancel()</LI>
-<LI>comedi_poll()</LI>
-<LI>comedi_get_buffer_contents()</LI>
-<LI>comedi_mark_buffer_read()</LI>
-<LI>comedi_get_buffer_offset()</LI>
-<LI>comedi_set_global_oor_behavior()</LI>
-</UL>
-</P>
-
-
-<HR>
-Next
-<A HREF="comedilib-5.html">Previous</A>
-<A HREF="comedilib.html#toc6">Contents</A>
-</BODY>
-</HTML>
+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
- <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.8.1">
- <TITLE>Comedi Documentation</TITLE>
- <LINK HREF="comedilib-1.html" REL=next>
-
-
-</HEAD>
-<BODY>
-<A HREF="comedilib-1.html">Next</A>
-Previous
-Contents
-<HR>
-<H1>Comedi Documentation</H1>
-
-<H2>David Schleef <CODE>ds@stm.lbl.gov</CODE>,
-Frank Hess <CODE>fmhess@uiuc.edu</CODE></H2>
-<P>
-<H2><A NAME="toc1">1.</A> <A HREF="comedilib-1.html">Introduction</A></H2>
-
-<P>
-<H2><A NAME="toc2">2.</A> <A HREF="comedilib-2.html">Installation and configuration</A></H2>
-
-<P>
-<H2><A NAME="toc3">3.</A> <A HREF="comedilib-3.html">Individual drivers</A></H2>
-
-<P>
-<H2><A NAME="toc4">4.</A> <A HREF="comedilib-4.html">Writing programs that use comedi and comedilib</A></H2>
-
-<P>
-<H2><A NAME="toc5">5.</A> <A HREF="comedilib-5.html">Application-specific functions</A></H2>
-
-<P>
-<H2><A NAME="toc6">6.</A> <A HREF="comedilib-6.html">Libcomedi Reference</A></H2>
-
-<HR>
-<A HREF="comedilib-1.html">Next</A>
-Previous
-Contents
-</BODY>
-</HTML>
+++ /dev/null
- Comedi Documentation
- David Schleef ds@stm.lbl.gov, Frank Hess fmhess@uiuc.edu
-
-
- 1\b1.\b. I\bIn\bnt\btr\bro\bod\bdu\buc\bct\bti\bio\bon\bn
-
- This is preliminary documentation for Comedi and Comedilib.
-
-
- 2\b2.\b. I\bIn\bns\bst\bta\bal\bll\bla\bat\bti\bio\bon\bn a\ban\bnd\bd c\bco\bon\bnf\bfi\big\bgu\bur\bra\bat\bti\bio\bon\bn
-
-
- This section covers compiling, installing, and configuring comedi and
- comedlib.
-
-
-
- 2\b2.\b.1\b1.\b. C\bCo\bom\bmp\bpi\bil\bli\bin\bng\bg a\ban\bnd\bd I\bIn\bns\bst\bta\bal\bll\bli\bin\bng\bg
-
-
- This section has not been written.
-
-
-
- 2\b2.\b.2\b2.\b. I\bIn\bns\bsm\bmo\bod\bd'\b'd\bdi\bin\bng\bg t\bth\bhe\be k\bke\ber\brn\bne\bel\bl m\bmo\bod\bdu\bul\ble\be
-
-
- This section has not been written.
-
-
-
- 2\b2.\b.3\b3.\b. C\bCo\bon\bnf\bfi\big\bgu\bur\bri\bin\bng\bg c\bco\bom\bme\bed\bdi\bi f\bfo\bor\br y\byo\bou\bur\br h\bha\bar\brd\bdw\bwa\bar\bre\be
-
-
-
- I assume that your hardware device is in your computer, and that you
- know the relevant details about it, i.e., what kind of card it is, the
- I/O base, the IRQ, jumper settings related to input ranges, etc.
-
- To tell the comedi kernel module that you have a particular device,
- and some information about it, you will be running the comedi_config
- command. Perhaps you should read the man page now.
-
- In this tutorial, I will go through the process of configuring comedi
- for two devices, a National Instruments AT-MIO-16E-10 and a Data
- Translation DT2821-F-8DI.
-
- The NI board is plug-and-play, and the man page tells me that I need
- to configure the PnP part of the board with isapnptools. The
- isapnptools package is a little cryptic, but the concepts are simple.
- Once I learned how to use it, I settled on a /etc/isapnp.conf file
- that contained the lines:
-
-
-
- # ANSI string -->National Instruments, AT-MIO-16E-10<--
- (CONFIGURE NIC2400/10725401 (LD 0
- (IO 0 (BASE 0x0260))
- (INT 0 (IRQ 3 (MODE +E)))
- # (DMA 0 (CHANNEL 5))
- # (DMA 1 (CHANNEL 6))
- (ACT Y)
- ))
-
-
- It also contains a few lines about overall configuration and about my
- sound card. I found out after a bit of trial-and-error that the NI
- board does not always work with interrupts other than IRQ 3. YMMV.
- Currently, the driver doesn't use DMA, but it may in the future, so I
- commented out the DMA lines. It is a curious fact that the device
- ignores the IRQ and DMA information given here, however, I keep the
- information here to remind myself that the numbers aren't arbitrary.
-
- When I run comedi_config (as root, of course), I provide the same
- information. Since I want to have the board configured every time I
- boot, I put the line
-
-
-
- /usr/sbin/comedi_config /dev/comedi0 atmio-E 0x260,3
-
-
-
- into /etc/rc.d/rc.local. You can, of course, run this command at a
- command prompt. The man page tells me that the option list is
- supposed to be "(I/O base),(IRQ)", so I used the same numbers as I put
- in /etc/isapnp.conf, i.e., 0x260,3.
-
- For the Data Translation board, I need to have a list of the jumper
- settings. Fortunately, I wrote them all down in the manual -- I hope
- they are still correct. However, I had to open the case to figure out
- which board in the series I had. It is a DT2821-f-8di. The man page
- of comedi_config tells me that I need to know the I/O base, IRQ, DMA
- 1, DMA 2. However, since I wrote the driver, I know that it also
- recognizes the differential/single-ended and unipolar/bipolar jumpers.
- As always, the source is the final authority, and looking in
- module/dt282x.c tells me that the options list is interpreted as:
-
-
- +\bo I/O base
-
- +\bo IRQ
-
- +\bo 1=differential, 0=single ended
-
- +\bo ai 0=unipolar, 1=bipolar
-
- +\bo ao0 0=unipolar, 1=bipolar
-
- +\bo ao1 0=unipolar, 1=bipolar
-
- +\bo dma1
-
- +\bo dma2
-
- (ai=analog input, ao=analog output.) From this, I decide that the
- appropriate options list is
-
-
-
- 0x200,4,,1,1,1
-
-
-
- I left the differential/single-ended number blank, since the driver
- already knowns (from the board name), that it is differential. I
- also left the DMA numbers blank, since I don't want the driver to use
- DMA. (Don't want it to interfere with my sound card -- life is full
- of difficult choices.) Keep in mind that things commented in the
- source, but not in the documentation are about as likely to change as
- the weather, so I put good comments next to the following line when I
- put it in rc.local.
-
-
-
- /usr/sbin/comedi_config /dev/comedi1 dt2821-f-8di 0x200,4,,1,1,1
-
-
-
- So now I think that I have my boards configured correctly. Since data
- acquisition boards are not typically well-engineered, comedi sometimes
- can't figure out if the board is actually there. If it can't, it
- assumes you are right. Both of these boards are well-made, so comedi
- will give me an error message if it can't find them. The comedi
- kernel module, since it is a part of the kernel, prints messages to
- the kernel logs, which you can access through the command 'dmesg' or
- /var/log/messages. Here is a configuration failure (from dmesg):
-
-
-
- comedi0: ni_E: 0x0200 can't find board
-
-
-
- When it does work, I get:
-
-
-
- comedi0: ni_E: 0x0260 at-mio-16e-10 ( irq = 3 )
-
-
-
- Note that it also correctly identified my board.
-
-
-
- 2\b2.\b.4\b4.\b. G\bGe\bet\btt\bti\bin\bng\bg i\bin\bnf\bfo\bor\brm\bma\bat\bti\bio\bon\bn f\bfr\bro\bom\bm c\bco\bom\bme\bed\bdi\bi
-
-
-
- So now that we have comedi talking to the hardware, we want to talk to
- comedi. Here's some pretty low-level information -- it's sometimes
- useful for debugging:
-
-
-
- cat /proc/comedi
-
-
-
- Right now, on my computer, this command gives:
-
-
-
- comedi version 0.6.4
- format string
- 0: atmio-E at-mio-16e-10 7
- 1: dt282x dt2821-f-8di 4
-
-
-
- This is a feature that is not well-developed yet. Basically, it
- currently tells you driver name, device name, and number of
- subdevices.
-
- In the demo/ directory, there is a command called info, which provides
- information about each subdevice on the board. The output of it is
- rather long, since I have 7 subdevices (4 or fewer is common for
- other boards.) Here's part of the output of the NI board (which is on
- /dev/comedi0.) ('demo/info /dev/comedi0')
-
-
-
- overall info:
- version code: 0x000604
- driver name: atmio-E
- board name: at-mio-16e-10
- number of subdevices: 7
- subdevice 0:
- type: 1 (unknown)
- number of channels: 16
- max data value: 4095
-
-
- ...
-
-
- The overall info gives information about the device -- basically the
- same information as /proc/comedi.
-
- This board has 7 subdevices. Devices are separated into subdevices
- that each have a distinct purpose -- e.g., analog input, analog
- output, digital input/output. This board also has an EEPROM and
- calibration DACs that are also subdevices.
-
- Subdevice 0 is the analog input subdevice. You would have known this
- from the 'type: 1 (unknown)' line, if I've updated demo/info recently,
- because it would say 'type: 1 (analog input)' instead. The other
- lines should be self-explanitory. Comedi has more information about
- the device, but demo/info doesn't currently display this.
-
-
-
- 3\b3.\b. I\bIn\bnd\bdi\biv\bvi\bid\bdu\bua\bal\bl d\bdr\bri\biv\bve\ber\brs\bs
-
-
- This section contains information that is specific to each hardware
- driver. The most current information about a driver is included in
- the comedi source.
-
-
- 3\b3.\b.1\b1.\b. N\bNa\bat\bti\bio\bon\bna\bal\bl I\bIn\bns\bst\btr\bru\bum\bme\ben\bnt\bts\bs A\bAT\bT-\b-M\bMI\bIO\bO E\bE s\bse\ber\bri\bie\bes\bs
-
-
-
- 3\b3.\b.2\b2.\b. D\bDa\bat\bta\ba T\bTr\bra\ban\bns\bsl\bla\bat\bti\bio\bon\bn
-
-
-
- 4\b4.\b. W\bWr\bri\bit\bti\bin\bng\bg p\bpr\bro\bog\bgr\bra\bam\bms\bs t\bth\bha\bat\bt u\bus\bse\be c\bco\bom\bme\bed\bdi\bi a\ban\bnd\bd c\bco\bom\bme\bed\bdi\bil\bli\bib\bb
-
-
-
- 4\b4.\b.1\b1.\b. Y\bYo\bou\bur\br f\bfi\bir\brs\bst\bt c\bco\bom\bme\bed\bdi\bi p\bpr\bro\bog\bgr\bra\bam\bm
-
-
- This example requires a card that has analog or digital input. Right
- to the source:
-
-
-
- #include <stdio.h> /* for printf() */
- #include <comedilib.h>
-
- int subdev = 0; /* change this to your input subdevice */
- int chan = 0; /* change this to your channel */
- int range = 0; /* more on this later */
- int aref = AREF_GROUND; /* more on this later */
-
- int main(int argc,char *argv[])
- {
- comedi_t *it;
- lsampl_t data;
-
- it=comedi_open("/dev/comedi0");
-
- comedi_data_read(it,subdev,chan,range,aref,&data);
-
- printf("%d\n",data);
-
- return 0;
- }
-
-
-
- Should be understandable: open the device, get the data, print it out.
- This is basically the guts of demo/inp.c, without error checking or
- fancy options. Compile it using
-
-
-
- cc tut1.c -lcomedi -o tut1
-
-
-
- A few notes: The range variable tells comedi which gain to use when
- measuring an analog voltage. Since we don't know (yet) which numbers
- are valid, or what each means, we'll use 0, because it won't cause
- errors. Likewise with aref, which determines the analog reference
- used.
-
-
-
- 4\b4.\b.2\b2.\b. C\bCo\bon\bnv\bve\ber\brt\bti\bin\bng\bg s\bsa\bam\bmp\bpl\ble\bes\bs t\bto\bo v\bvo\bol\blt\bta\bag\bge\bes\bs
-
-
- If you selected an analog input subdevice, you probably noticed that
- the output of tut1 is a number between 0 and 4095, or 0 and 65535,
- depending on the number of bits in the A/D converter. Comedi samples
- are a\bal\blw\bwa\bay\bys\bs unsigned, with 0 representing the lowest voltage of the
- ADC, and 4095 the highest. Comedi compensates for anything else the
- manual for your device says. However, you probably prefer to have
- this number translated to a voltage. Naturally, as a good programmer,
- your first question is: "How do I do this in a device-independent
- manner?"
-
- Most devices give you a choice of gain and unipolar/bipolar input, and
- Comedi allows you to select which of these to use. This parameter is
- called the "range parameter", since it specifies the "input range" for
- analog input (or "output range" for analog output.) The range
- parameter represents both the gain and the unipolar/bipolar aspects.
-
- Comedi keeps the number of available ranges and the largest sample
- value for each subdevice/channel combination. (Some devices allow
- different input/output ranges for different channels in a subdevice.)
-
- The largest sample value can be found using the function:
-
- comedi_get_maxdata()
-
- The number of available ranges can be found using the function:
-
- comedi_get_n_ranges()
-
- For each value of the range parameter for a particular
- subdevice/channel, you can get range information using the function:
-
- ptr=comedi_get_range(comedi_file,subdevice,channel, range)
-
- which returns a pointer to a comedi_range structure. The comedi_range
- structure looks like
-
-
-
- typedef struct{
- double min;
- double max;
- unsigned int unit;
- }comedi_range;
-
-
-
- The structure element 'min' represents the voltage corresponding to
- comedi_data_read() returning 0, and 'max' represents
- comedi_data_read() returning 'maxdata', (i.e., 4095 for 12 bit A/C
- converters, 65535 for 16 bit, or, 1 for digital input -- more on this
- in a bit.) The max refer to voltage, current, etc.
-
- "Could it get easier?", you say. Well, yes. Use the function
- comedi_to_phys(), which converts data values to physical units. Call
- it using something like
-
-
-
- volts=comedi_to_phys(it,data,range,maxdata);
-
-
- and the opposite
-
-
-
- data=comedi_from_phys(it,volts,range,maxdata);
-
-
-
- 4\b4.\b.3\b3.\b. A\bAn\bno\bot\bth\bhe\ber\br s\bse\bec\bct\bti\bio\bon\bn
-
-
-
- In addition to providing low level routines for data access, the
- comedi library provides higher-level access, much like the standard C
- library provides fopen(), etc. as a high-level (and portable)
- alternative to the direct UNIX system calls open(), etc. Similarily
- to fopen(), we have comedi_open():
-
-
-
- file=comedi_open("/dev/comedi0");
-
-
-
- where file is of type (comedi_t *). This function calls open(), like
- we did explicitly in a previous section, but also fills the comedi_t
- structure with lots of goodies -- information that we will need to use
- soon.
-
- Specifically, we needed to know maxdata for a specific
- subdevice/channel. How about:
-
-
-
- maxdata=comedi_get_maxdata(file,subdevice,channel);
-
-
-
- Wow. How easy. And the range type?
-
-
-
- range_type=comedi_get_rangetype(file,subdevice,channel);
-
-
-
- Cool. Other information you need to know about a channel can be
- gotten in a similar way.
-
-
-
- 4\b4.\b.4\b4.\b. Y\bYo\bou\bur\br s\bse\bec\bco\bon\bnd\bd c\bco\bom\bme\bed\bdi\bi p\bpr\bro\bog\bgr\bra\bam\bm
-
-
-
- Actually, this is the first comedi program again, just that we've
- added what we've learned.
- #include <stdio.h> /* for printf() */
- #include <comedi.h> /* also included by comedilib.h */
- #include <comedilib.h> /* 'cuz we're using comedilib */
-
- int subdev = 0; /* change this to your input subdevice */
- int chan = 0; /* change this to your channel */
- int range = 0; /* more on this later */
- int aref = 0; /* more on this later */
-
- int main(int argc,char *argv[])
- {
- comedi_t *cf;
- int chan=0;
- lsampl_t data;
- int maxdata,rangetype;
- double volts;
-
- cf=comedi_open("/dev/comedi0");
-
- maxdata=comedi_get_maxdata(cf,subdev,chan);
-
- rangetype=comedi_get_rangetype(cf,subdev,chan);
-
- comedi_data_read(cf->fd,subdev,chan,range,aref,&data);
-
- volts=comedi_to_phys(data,rangetype,range,maxdata);
-
- printf("%d %g\n",data,volts);
-
- return 0;
- }
-
-
-
- 5\b5.\b. A\bAp\bpp\bpl\bli\bic\bca\bat\bti\bio\bon\bn-\b-s\bsp\bpe\bec\bci\bif\bfi\bic\bc f\bfu\bun\bnc\bct\bti\bio\bon\bns\bs
-
-
-
- 5\b5.\b.1\b1.\b. D\bDi\big\bgi\bit\bta\bal\bl I\bIn\bnp\bpu\but\bt/\b/O\bOu\but\btp\bpu\but\bt
-
-
- Many boards supported by comedi have digital input and output
- channels. Some boards allow the direction of a channel to be
- specified in software.
-
- Comedi groups digital channels into subdevice, which is a group of
- digital channels that have the same characteristics. For example,
- digital output lines will be grouped into a digital output subdevice,
- bidirectional digital lines will be grouped into a digital I/O
- subdevice. Thus, there can be multiple digital subdevices on a
- particular board.
-
- Individual digital lines can be read and written using the functions
-
- comedi_dio_read(device,subdevice,channel,unsigned int *bit);
- comedi_dio_write(device,subdevice,channel,unsigned int bit);
-
- The direction of bidirectional lines can be configured using the
- function
-
- comedi_dio_config(device,subdevice,channel,unsigned int dir);
-
- The parameter dir should be either COMEDI_INPUT or COMEDI_OUTPUT.
- Many digital I/O subdevices group channels into blocks for configuring
- direction. Changing one channel in a block changes the entire block.
-
- Multiple channels can be read and written simultaneously using the
- function
-
- comedi_dio_bitfield(device,subdevice,unsigned int write_mask,unsigned
- int *bits);
-
- Each channel is assigned to a bit in the write_mask and bits bitfield.
- If a bit in write_mask is set, the corresponding bit in *bits will be
- written to the corresponding digital output line. Each digital line
- is then read and placed into *bits. The value of bits in *bits
- corresponding to digital output lines is undefined and device-
- specific. Channel 0 is the least significant bit in the bitfield;
- channel 31 is the most significant bit. Channels higher than 31
- cannot be accessed using this method.
-
-
-
- 5\b5.\b.2\b2.\b. S\bSl\blo\bow\bwl\bly\by-\b-v\bva\bar\bry\byi\bin\bng\bg i\bin\bnp\bpu\but\bts\bs
-
-
-
- Sometimes, your input channels change slowly enough that you are able
- to average many sucessive input values to get a more accurate
- measurement of the actual value. In general, the more samples you
- average, the better your estimate gets, roughly by a factor of
- sqrt(number_of_samples). Obviously, there are limitations to this:
-
-
-
- +\bo you are ultimately limited by "spurious free dynamic range"
-
- +\bo you need to have _some_ noise on the input channel, otherwise you
- will be averaging the same number N times.
-
- +\bo the more noise you have, the greater your SFDR, but it takes many
- more samples to compensate for the increased noise
-
- +\bo if you feel the need to average samples for 2 seconds, your signal
- will need to be _very_ slowly-varying, i.e., not varying more than
- your target uncertainty for the entire 2 seconds.
-
- As you might have guessed, the comedi library has functions to help
- you in your quest to accurately measure slowly varying inputs. I use
- these functions to measure thermocouple voltages -- actually, the
- library functions came from a section of code that was previously part
- of the thermocouple reading program.
-
- The comedi self-calibration utility also uses these functions. On
- some hardware, it is possible to tell it to measure an internal stable
- voltage reference, which is typically going to be very slowly varying
- -- on the kilosecond time scale or more. So it is reasonable to
- measure millions of samples, to get a very accurate measurement of the
- A/D converter output value that corresponds to the voltage reference.
- Sometimes, however, this is overkill, since there is no need to
- perform a part-per-million calibration to a standard that is only
- accurate to part-per-thousand.
-
-
-
- 5\b5.\b.3\b3.\b. C\bCo\bom\bmm\bma\ban\bnd\bds\bs
-
-
-
- Many data acquisition devices have the capability to directly control
- acquisition using either an on-board timer or an external triggering
- input. Comedi commands are used to control this kind of acquisition.
- The ``comedi_cmd'' structure is used to control acquisition and query
- the capabilities of a device (see also ``comedi_command()'',
- ``comedi_command_test()'', and ``comedi_get_cmd_src_mask()'').
-
- Commands specify a particular data acquisition sequence, which is
- comprised of a number of scans. Each scan is comprised of a number of
- conversions, which usually corresponds to a single A/D or D/A
- conversion. The start and end of the sequence, and the start and end
- of each scan, and each conversion is called an event.
-
- Each of these 5 types of events are caused by a triggering source,
- specified through the *_src members of the ``comedi_cmd'' structure.
- The source types are:
-
-
- +\bo TRIG_NONE: don't ever cause an event
-
- +\bo TRIG_NOW: cause event to occur immediately
-
- +\bo TRIG_FOLLOW: see notes below
-
- +\bo TRIG_TIME: cause event to occur at a particular time
-
- +\bo TRIG_TIMER: cause event to occur repeatedly at a specific rate
-
- +\bo TRIG_COUNT: cause event when count reaches specific value
-
- +\bo TRIG_EXT: external signal causes event
-
- +\bo TRIG_INT: internal signal causes event
-
- +\bo TRIG_OTHER: driver-specific meaning
-
- Not all triggers are applicable to all events. Supported triggers for
- specific events depend significantly on your particular device. The
- ``comedi_get_cmd_src_mask()'' function is useful for determining what
- triggers a subdevice supports.
-
- For every trigger, there is a corresponding argument (the *_arg
- members of the ``comedi_cmd'' structure) whose meaning depends on the
- type of trigger. The meanings of the arguments are as follows:
-
- TRIG_NONE is typically used only as a stop_src. The argument for
- TRIG_NONE is reserved and should be set to 0.
-
- TRIG_NOW is most often used as a start_src. The argument for TRIG_NOW
- is the number of nanoseconds between when the command is issued and
- when the event should occur. In the case of using TRIG now as a
- start_src, it indicates a delay between issuing the command and the
- start of acquisition. Most drivers only support a delay of 0.
-
- TRIG_FOLLOW is a special type of trigger for events that trigger on
- the completion of some other, logically connected event. The argument
- is reserved and should be set to 0. When used as a scan_begin_src, it
- indicates that a trigger should occur as a logical continuation of
- convert events. This is done in order to properly describe boards
- that do not have separate timers for convert and scan_begin events.
- When used as a start_src for analog output subdevices, it indicates
- that conversion of output samples should begin when samples are
- written to the buffer.
-
- TRIG_TIME is reserved for future use.
-
- TRIG_TIMER is most often used as a convert_src, a scan_begin_src, or
- both. It indicates that triggers should occur at a specific rate.
- The argument specifies the interval between triggers in nanoseconds.
-
- TRIG_COUNT is used for scan_end_src and stop_src. It indicates that a
- trigger should occur when the specified number of corresponding lower-
- level triggers (convert and scan_begin, respectively) occur. The
- argument is the count of lower-level triggers.
-
- TRIG_EXT can be useful as any of the trigger sources. It indicates
- that an external digital line should be used to trigger the event.
- The exact meaning of digital line is device-dependent. Some devices
- have one dedicated line, others may allow generic digital input lines
- to be used. The argument indicates the particular external line to
- use as the trigger.
-
- TRIG_INT is typically used as a start_src. This trigger occurs when
- the application performs an INSN_INTTRIG instruction. Using TRIG_INT
- is a method by which the application can accurately record the time of
- the start of acquisition, since the parsing and setup time of a
- particular command may be significant. The argument associated with
- TRIG_INT is reserved and should be set to 0.
-
- TRIG_OTHER can be useful as any of the trigger sources. The exact
- meaning of TRIG_OTHER is driver-specific, and implements a feature
- that otherwise does not fit into the command interface. Configuration
- of TRIG_OTHER features are done by INSN_CONFIG insns. The argument is
- reserved and should be set to 0.
-
- Ths subdev member of the ``comedi_cmd'' structure is the index of the
- subdevice the command is intended for. The
- ``comedi_find_subdevice_by_type()'' function can be useful in
- discovering the index of your desired subdevice.
-
- The chanlist member of the ``comedi_cmd'' structure should point to an
- array whose number of elements is specificed by chanlist_len (this
- will generally be the same as the scan_end_arg). The chanlist
- specifies the sequence of channels and gains (and analog references)
- that should be stepped through for each scan. The elements of the
- chanlist array should be initialized by packing the channel, range and
- reference information together with the ``CR_PACK()'' macro.
-
- The data and data_len members can be safely ignored when issueing
- commands from a user-space program. They only have meaning when a
- command is sent from a kernel module using the kcomedilib interface,
- in which case they specify the buffer where the driver should
- write/read its data to/from.
-
- The final member of the ``comedi_cmd'' structure is flags. The
- following flags are valid, and can be bitwise-or'd together.
-
-
- +\bo TRIG_BOGUS: do the motions??
-
- +\bo TRIG_DITHER: enable dithering??
-
- +\bo TRIG_DEGLITCH: enable deglitching??
-
- +\bo TRIG_RT: ask driver to use a hard real-time interrupt
- handler. This will reduce latency in handling interrupts from your
- data aquisition hardware. It can be useful if you are sampling at
- high frequency, or if your hardware has a small onboard fifo. You
- must have a real-time kernel (RTAI or RTLinux) and must compile
- comedi with real-time support or this flag will do nothing.
-
- +\bo TRIG_CONFIG: perform configuration, not triggering. This is a
- legacy of the deprecated comedi_trig_struct, and has no function at
- present.
-
- +\bo TRIG_WAKE_EOS: some drivers will change their behaviour when this
- flag is set, trying to transfer data at the end of every scan
- (instead of, for example, passing data in chunks whenever the
- board's onboard fifo is half full). This flag may degrade a
- driver's performance at high frequencies.
-
- +\bo TRIG_WRITE: write to bidirectional devices. Could be useful in
- principle, if someone wrote a driver that supported commands for a
- digital i/o device that could do either input or output.
-
- There are also a few flags that indicate how timing arguments
- should be rounded if the hardware cannot achieve the exact timing
- requested.
-
- +\bo TRIG_ROUND_NEAREST: round to nearest supported timing period, the
- default.
-
- +\bo TRIG_ROUND_DOWN: round period down.
-
- +\bo TRIG_ROUND_UP: round period up.
-
- +\bo TRIG_ROUND_UP_NEXT: this one doesn't do anything, and I don't know
- what it was intended to do??
-
-
-
- The typical sequence for executing a command is to first send the
- command through ``comedi_command_test()'' once or twice. The test
- will check that the command is valid for the particular device, and
- often makes some adjustments to the command arguments, which can then
- be read back by the user to see the actual values used. The command
- is executed with ``comedi_command()''. For input/output commands,
- data is read from or written to the device file /dev/comedi[0..3] you
- are using.
-
-
- 6\b6.\b. L\bLi\bib\bbc\bco\bom\bme\bed\bdi\bi R\bRe\bef\bfe\ber\bre\ben\bnc\bce\be
-
-
-
- 6\b6.\b.1\b1.\b. C\bCo\bon\bns\bst\bta\ban\bnt\bts\bs a\ban\bnd\bd M\bMa\bac\bcr\bro\bos\bs
-
-
-
- 6\b6.\b.1\b1.\b.1\b1.\b. C\bCR\bR_\b_P\bPA\bAC\bCK\bK(\b()\b)
-
-
- CR_PACK(channel, range, aref)
-
- CR_PACK is used to initialize the elements of the chanlist array in
- the ``comedi_cmd'' structure, and the chanspec member of the
- ``comedi_insn'' structure.
-
- The channel argument is the channel you wish to use, with the channel
- numbering starting at zero.
-
- The range is an index, starting at zero, whose meaning is device
- dependent. The ``comedi_get_n_ranges()'' and ``comedi_get_range()''
- functions are useful in discovering information about the available
- ranges.
-
- The aref argument indicates what reference you want the device to use.
- It can be any of the following:
-
- +\bo AREF_GROUND is for inputs/outputs referenced to ground
-
- +\bo AREF_COMMON is for a `common' reference (the low inputs of all
- the channels are tied together, but are isolated from ground)
-
- +\bo AREF_DIFF is for differential inputs/outputs
-
- +\bo AREF_OTHER is for any reference that does not fit into the
- above categories
-
- Particular drivers may or may not use the AREF flags. If they are
- not supported, they are silently ignored.
-
-
- Source: /include/comedi.h
-
-
-
- 6\b6.\b.1\b1.\b.2\b2.\b. R\bRA\bAN\bNG\bGE\bE_\b_L\bLE\bEN\bNG\bGT\bTH\bH(\b()\b) (\b(d\bde\bep\bpr\bre\bec\bca\bat\bte\bed\bd)\b)
-
-
- RANGE_LENGTH(rangetype)
-
-
- 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.
-
-
- The RANGE_LENGTH() macro returns the length of the array that is
- specified by the rangetype token.
-
-
- The RANGE_LENGTH() macro is deprecated, and should not be used in 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.
-
-
-
- 6\b6.\b.2\b2.\b. D\bDa\bat\bta\ba T\bTy\byp\bpe\bes\bs a\ban\bnd\bd S\bSt\btr\bru\buc\bct\btu\bur\bre\bes\bs
-
-
- 6\b6.\b.2\b2.\b.1\b1.\b. c\bco\bom\bme\bed\bdi\bi_\b_t\bt
-
- The data type comedi_t is used to represent an open Comedi device. A
- valid comedi_t pointer is returned by a successful call to
- comedi_open(), and should be used for subsequent access to the device.
- It is a transparent type, and pointers to type comedi_t should not be
- dereferenced by the application.
-
-
-
- 6\b6.\b.2\b2.\b.2\b2.\b. s\bsa\bam\bmp\bpl\bl_\b_t\bt
-
- The data type sampl_t is one of the generic types used to represent
- data values in libcomedi. It is used in a few places where a shorter
- data type is useful, but is limited to 16 bits on the i386
- architecture.
-
- 6\b6.\b.2\b2.\b.3\b3.\b. l\bls\bsa\bam\bmp\bpl\bl_\b_t\bt
-
- The data type lsampl_t is one of the generic types used to represent
- data values in libcomedi. It is currently defined to be unsigned int.
-
-
-
- 6\b6.\b.2\b2.\b.4\b4.\b. c\bco\bom\bme\bed\bdi\bi_\b_t\btr\bri\big\bg_\b_s\bst\btr\bru\buc\bct\bt (\b(d\bde\bep\bpr\bre\bec\bca\bat\bte\bed\bd)\b)
-
-
- The comedi_trig structure
-
-
-
- struct comedi_trig_struct{
- unsigned int subdev; /* subdevice */
- unsigned int mode; /* mode */
- unsigned int flags;
- unsigned int n_chan; /* number of channels */
- unsigned int *chanlist; /* channel/range list */
- sampl_t *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];
- }
-
-
-
- The comedi_trig structure is a control structure used by the
- COMEDI_TRIG ioctl, an older method of communicating instructions to
- the driver and hardware. Use of comedi_trig is deprecated, and should
- not be used in new applications.
-
-
- This structure is defined as part of the Comedi kernel interface.
-
-
-
- 6\b6.\b.2\b2.\b.5\b5.\b. c\bco\bom\bme\bed\bdi\bi_\b_s\bsv\bv_\b_t\bt
-
-
-
- struct comedi_sv_struct{
- comedi_t *dev;
- unsigned int subdevice;
- unsigned int chan;
-
- /* range policy */
- int range;
- int aref;
-
- /* number of measurements to average (for ai) */
- int n;
-
- lsampl_t maxdata;
- }
-
-
- The comedi_sv_t structure is used by the comedi_sv_*() functions to
- provide a simple method of accurately measuring slowly varying inputs.
- See the relevant section for more details.
-
-
-
- 6\b6.\b.2\b2.\b.6\b6.\b. c\bco\bom\bme\bed\bdi\bi_\b_c\bcm\bmd\bd
-
-
-
- typedef struct comedi_cmd_struct comedi_cmd;
-
- struct comedi_cmd_struct{
- unsigned int subdev;
- unsigned int flags;
-
- unsigned int start_src;
- unsigned int start_arg;
-
- unsigned int scan_begin_src;
- unsigned int scan_begin_arg;
-
- unsigned int convert_src;
- unsigned int convert_arg;
-
- unsigned int scan_end_src;
- unsigned int scan_end_arg;
-
- unsigned int stop_src;
- unsigned int stop_arg;
-
- unsigned int *chanlist;
- unsigned int chanlist_len;
-
- sampl_t *data;
- unsigned int data_len;
- };
-
-
-
- More information on using commands can be found in the ``command''
- section.
-
-
- This structure is defined as part of the Comedi kernel interface.
-
-
-
- 6\b6.\b.2\b2.\b.7\b7.\b. c\bco\bom\bme\bed\bdi\bi_\b_i\bin\bns\bsn\bn
-
-
- undocumented
-
-
- Related functions are described in section XXX.
-
-
- This structure is defined as part of the Comedi kernel interface.
-
-
-
- 6\b6.\b.2\b2.\b.8\b8.\b. c\bco\bom\bme\bed\bdi\bi_\b_r\bra\ban\bng\bge\be
-
-
- undocumented
-
-
-
- 6\b6.\b.3\b3.\b. F\bFu\bun\bnc\bct\bti\bio\bon\bns\bs
-
-
-
- 6\b6.\b.3\b3.\b.1\b1.\b. c\bco\bom\bme\bed\bdi\bi_\b_c\bcl\blo\bos\bse\be(\b()\b)
-
-
- void comedi_close(comedi_t *it);
-
-
- Closes a device previously opened by comedi_open().
-
-
- The return type of this function will change to int, in order to match
- fclose.
-
-
- Source: /lib/comedi.c
-
-
-
- 6\b6.\b.3\b3.\b.2\b2.\b. c\bco\bom\bme\bed\bdi\bi_\b_c\bco\bom\bmm\bma\ban\bnd\bd(\b()\b)
-
-
- int comedi_command(comedi_t *it, comedi_cmd *cmd);
-
- Issues the command pointed at by cmd to the open device it. It is
- usually necessary to pass the command through
- ``comedi_command_test()'' to fix up the command before it can be
- successfully executed with comedi_command(). See ``commands'' for
- more information.
-
-
- Source: /lib/comedi.c
-
-
-
- 6\b6.\b.3\b3.\b.3\b3.\b. c\bco\bom\bme\bed\bdi\bi_\b_c\bco\bom\bmm\bma\ban\bnd\bd_\b_t\bte\bes\bst\bt(\b()\b)
-
-
- int comedi_command_test(comedi_t *it, comedi_cmd *cmd);
-
-
- Tests and fixes up the command pointed at by cmd according to the
- limitations of the driver configured on the open device it. The
- return value has the following meaning:
-
- +\bo 0: the command passed the test and can be successfully
- executed by ``comedi_command()''. The one exception to this rule
- is that the test will allow a NULL chanlist for the command.
-
- +\bo 1: invalid trigger. One or more of the trigger sources (the *_src
- members of the ``comedi_cmd'' structure) is not supported by the
- driver.
-
- +\bo 2: incompatible triggers. Two or more of the triggers selected are
- incompatible with each other. For example, a driver might allow
- either the scan_begin_src or the convert_src to be TRIG_TIMER, but
- not both.
-
- +\bo 3: argument invalid. One or more argument is invalid, for example
- a timing argument might be in excess of the card's maximum speed.
- The command test will correct the arguments by modifying the
- command pointed at by cmd.
-
- +\bo 4: argument fix up. The command underwent minor adjustment and
- should now be valid. For example, a timing argument might not be
- exactly achievable by the card so the timing argument will be
- adjusted to the actual timing the card will use.
-
- +\bo negative: some other error has occured.
-
- See ``commands'' for more information.
-
-
- Source: /lib/comedi.c
-
-
-
- 6\b6.\b.3\b3.\b.4\b4.\b. c\bco\bom\bme\bed\bdi\bi_\b_d\bda\bat\bta\ba_\b_r\bre\bea\bad\bd(\b()\b)
-
-
- int comedi_data_read(comedi_t *it,unsigned int subd,unsigned int chan,
- unsigned int range,unsigned int aref,lsampl_t *data);
-
-
- Reads a single sample on the channel that is specified by the comedi
- device it, the subdevice subd, and the channel chan. For the A/D
- conversion (if appropriate), the device is configured to use range
- specification range and (if appropriate) analog reference type aref.
- Analog reference types that are not supported by the device are
- silently ignored.
-
-
- comedi_data_read() reads one data value from the specified channel and
- places the data value that is read in the location pointed to by data.
-
-
- On sucess, comedi_data_read() returns 0. If there is an error, -1 is
- returned.
-
-
- Valid analog reference numbers are:
-
-
- +\bo AREF_GROUND Reference to analog ground
-
- +\bo AREF_COMMON Reference to analog common
-
- +\bo AREF_DIFF Differential reference
-
- +\bo AREF_OTHER Board-specific meaning
-
- Valid data values returned by these function is an unsigned integer
- less than or equal to maxdata, which is channel-dependent. Conversion
- of these data value to physical units can be performed by
- ``comedi_to_phys()''.
-
- Source: /lib/data.c
-
-
-
- 6\b6.\b.3\b3.\b.5\b5.\b. c\bco\bom\bme\bed\bdi\bi_\b_d\bda\bat\bta\ba_\b_w\bwr\bri\bit\bte\be(\b()\b)
-
-
- int comedi_data_write(comedi_t *it,unsigned int subd,unsigned int
- chan, unsigned int range,unsigned int aref,lsampl_t data);
-
-
- Writes a single sample on the channel that is specified by the comedi
- device it, the subdevice subd, and the channel chan. For the D/A
- conversion (if appropriate), the device is configured to use range
- specification range and (if appropriate) analog reference type aref.
- Analog reference types that are not supported by the device are
- silently ignored.
-
- comedi_data_write() writes the data value specified by the argument
- data to the specified channel.
-
- On sucess, comedi_data_write() returns 0. If there is an error, -1 is
- returned.
-
- Valid analog reference numbers are:
-
-
- +\bo AREF_GROUND Reference to analog ground
-
- +\bo AREF_COMMON Reference to analog common
-
- +\bo AREF_DIFF Differential reference
-
- +\bo AREF_OTHER Board-specific meaning
-
- Valid data values used by these functions is an unsigned integer less
- than or equal to maxdata, which is channel-dependent. Conversion of
- physical units to these data value can be performed by
- ``comedi_from_phys()''.
-
- Source: /lib/data.c
-
-
-
- 6\b6.\b.3\b3.\b.6\b6.\b. c\bco\bom\bme\bed\bdi\bi_\b_d\bdi\bio\bo_\b_b\bbi\bit\btf\bfi\bie\bel\bld\bd(\b()\b);\b;
-
- int comedi_dio_bitfield(comedi_t *it,unsigned int subd,unsigned int
- write_mask,unsigned int *bits);
-
-
- The function comedi_dio_bitfield() allows multiple channels to be read
- simultaneously from a digital input or digital I/O device. The
- parameter write_mask and the value pointed to by bits are interpreted
- as bit fields, with the least significant bit representing channel 0.
- For each bit in write_mask that is set, the cooresponding bit in *bits
- is written to the digital output channel. Each digital input channel
- is read, and the result placed in the approprate bits in *bits.
-
-
- The current implementation reads and writes bits using separate system
- calls, which is not ideal. When the kernel driver supports
- simultaneous reading/writing, this will be fixed in the library.
-
-
- It should be noted that it is not possible to access channels greater
- than 31 using this function.
-
-
-
- Source: /lib/dio.c
-
-
-
- 6\b6.\b.3\b3.\b.7\b7.\b. c\bco\bom\bme\bed\bdi\bi_\b_d\bdi\bio\bo_\b_c\bco\bon\bnf\bfi\big\bg(\b()\b)
-
- int comedi_dio_config(comedi_t *it,unsigned int subd,unsigned int
- chan,unsigned int dir);
-
-
- The function comedi_dio_config configures individual channels in a
- digital I/O subdevice to be either input or output, depending on the
- value of parameter dir. Depending on the capabilities of the hardware
- device, multiple channels may be affected by a single call to
- comedi_dio_config.
-
-
- Valid directions are:
-
- +\bo COMEDI_INPUT
-
- +\bo COMEDI_OUTPUT
-
- Source: /lib/dio.c
-
-
-
- 6\b6.\b.3\b3.\b.8\b8.\b. c\bco\bom\bme\bed\bdi\bi_\b_d\bdi\bio\bo_\b_r\bre\bea\bad\bd(\b()\b)
-
- int comedi_dio_read(comedi_t *it,unsigned int subd,unsigned int
- chan,unsigned int *bit);
-
-
- The function reads the status of channel chan belonging to the digital
- input subdevice subd of device it. The result, 0 or 1, is stored in
- bit. Returns -1 on failure.
-
-
- This function is equivalent to comedi_data_read(it,subd,chan,0,0,bit).
-
-
- Source: /lib/dio.c
-
-
-
- 6\b6.\b.3\b3.\b.9\b9.\b. c\bco\bom\bme\bed\bdi\bi_\b_d\bdi\bio\bo_\b_w\bwr\bri\bit\bte\be(\b()\b)
-
- int comedi_dio_write(comedi_t *it,unsigned int subd,unsigned int
- chan,unsigned int bit);
-
-
- The function writes the value of bit, 0 or 1, to channel chan,
- belonging to the digital output device subd of device it. Returns -1
- on failure.
-
-
- Source: /lib/dio.c
-
-
-
- 6\b6.\b.3\b3.\b.1\b10\b0.\b. c\bco\bom\bme\bed\bdi\bi_\b_f\bfi\bil\ble\ben\bno\bo(\b()\b)
-
-
-
- int comedi_fileno(comedi_t *it);
-
-
- The function comedi_fileno returns the integer descriptor for the
- handle it. It is equivalent to the standard function fileno. If it
- is an invalid comedi_t pointer, the function returns -1 and sets the
- appropriate libcomedi error value.
-
- Source: /lib/comedi.c
-
-
-
- 6\b6.\b.3\b3.\b.1\b11\b1.\b. c\bco\bom\bme\bed\bdi\bi_\b_f\bfi\bin\bnd\bd_\b_r\bra\ban\bng\bge\be(\b()\b)
-
-
- int comedi_find_range(comedi_t *it, unsigned int subdevice, unsigned
- int chan, unsigned int unit, double min, double max);
-
-
- The function comedi_find_range tries to locate the optimal (smallest)
- range for the channel chan belonging to a subdevice of the comedi
- device it, that includes both min and max in units. If it finds a
- matching range, it returns its index. If no matching range is
- available, it returns -1.
-
-
- Valid units are:
-
-
- +\bo UNIT_volt
-
- +\bo UNIT_mA
-
- +\bo UNIT_none
-
- Source: /lib/range.c
-
-
-
- 6\b6.\b.3\b3.\b.1\b12\b2.\b. c\bco\bom\bme\bed\bdi\bi_\b_e\ber\brr\brn\bno\bo(\b()\b)
-
- int comedi_errno(void);
-
-
- The function comedi_errno() returns an integer describing the most
- recent comedilib error. This integer may be used as the errnum
- parameter for ``comedi_strerror()''.
-
- When a libcomedi function fails, it usually returns -1 or NULL,
- depending on the return type. An internal library variable stores an
- error number, which can be retrieved with comedi_errno(). This error
- number can be converted to a human-readable form by the functions
- ``comedi_perror()'' and ``comedi_strerror()''.
-
- These functions are intended to mimic the behavior of the standard C
- library functions perror(), strerror, and errno(). In particular,
- libcomedi functions sometimes return an error that is generated by the
- C library; the Comedi error message in this case is the same as the C
- library.
-
- Source: /lib/error.c
-
-
-
- 6\b6.\b.3\b3.\b.1\b13\b3.\b. c\bco\bom\bme\bed\bdi\bi_\b_f\bfi\bin\bnd\bd_\b_s\bsu\bub\bbd\bde\bev\bvi\bic\bce\be_\b_b\bby\by_\b_t\bty\byp\bpe\be(\b()\b)
-
-
- int comedi_find_subdevice_by_type(comedi_t *it,int type,unsigned int
- start_subdevice);
-
-
- The function comedi_find_subdevice_by_type tries to locate a subdevice
- belonging to comedi device it, having type type, starting with the
- subdevice start_subdevice. If it finds the requested subdevice, it
- returns its index. If it does not locate the requested subdevice, it
- returns -1 and sets the comedi error number to "subdevice not found".
- If there is an error, the function returns -1 and sets the appropriate
- error.
-
-
- For subdevice types, see the manual page for the function
- ``comedi_get_subdevice_type()''.
-
- Source: /lib/get.c
-
-
-
- 6\b6.\b.3\b3.\b.1\b14\b4.\b. c\bco\bom\bme\bed\bdi\bi_\b_f\bfr\bro\bom\bm_\b_p\bph\bhy\bys\bs(\b()\b)
-
-
- lsampl_t comedi_from_phys(double data, comedi_range *rng, lsampl_t
- maxdata);
-
- Converts data given in physical units (data) into sample values
- (lsampl_t, between 0 and maxdata). The parameter rng represents the
- conversion information to use, and the parameter maxdata represents
- the maximum possible data value for the channel that the data will be
- written to.
-
-
- Source: /lib/range.c
-
-
-
- 6\b6.\b.3\b3.\b.1\b15\b5.\b. c\bco\bom\bme\bed\bdi\bi_\b_g\bge\bet\bt_\b_b\bbo\boa\bar\brd\bd_\b_n\bna\bam\bme\be(\b()\b)
-
-
- char *comedi_get_board_name(comedi_t *it);
-
- The function comedi_get_board_name returns a pointer to a string
- containing the name of the device. This pointer is valid until the
- comedi descriptor it is closed. This function returns NULL if there
- is an error.
-
- Source: /lib/get.c
-
-
-
- 6\b6.\b.3\b3.\b.1\b16\b6.\b. c\bco\bom\bme\bed\bdi\bi_\b_g\bge\bet\bt_\b_c\bcm\bmd\bd_\b_s\bsr\brc\bc_\b_m\bma\bas\bsk\bk(\b()\b)
-
-
- int comedi_get_cmd_src_mask(comedi_t *dev, unsigned int subdevice,
- comedi_cmd *cmd);
-
- undocumented
-
- Source: /lib/cmd.c
-
- 6\b6.\b.3\b3.\b.1\b17\b7.\b. c\bco\bom\bme\bed\bdi\bi_\b_g\bge\bet\bt_\b_d\bdr\bri\biv\bve\ber\br_\b_n\bna\bam\bme\be(\b()\b)
-
-
- char *comedi_get_driver_name(comedi_t *it);
-
- The function comedi_get_driver_name returns a pointer to a string
- containing the name of the driver being used by comedi for the comedi
- device represented by it. This pointer is valid until the comedi
- descriptor it is closed. This function returns NULL if there is an
- error.
-
- Source: /lib/get.c
-
-
-
- 6\b6.\b.3\b3.\b.1\b18\b8.\b. c\bco\bom\bme\bed\bdi\bi_\b_g\bge\bet\bt_\b_m\bma\bax\bxd\bda\bat\bta\ba(\b()\b)
-
-
- lsampl_t comedi_get_maxdata(comedi_t *it,unsigned int
- subdevice,unsigned int chan);
-
-
- The function comedi_get_maxdata() returns the maximum valid data value
- for channel chan of subdevice subdevice belonging to the comedi device
- it This function returns 0 on error.
-
- Source: /lib/get.c
-
-
-
- 6\b6.\b.3\b3.\b.1\b19\b9.\b. c\bco\bom\bme\bed\bdi\bi_\b_g\bge\bet\bt_\b_n\bn_\b_c\bch\bha\ban\bnn\bne\bel\bls\bs(\b()\b)
-
-
- int comedi_get_n_channels(comedi_t *it,unsigned int subdevice);
-
- The function comedi_get_n_channels() returns the number of channels of
- the subdevice belonging to the comedi device it and having index
- subdevice. This function returns -1 on error.
-
- Source: /lib/get.c
-
-
-
- 6\b6.\b.3\b3.\b.2\b20\b0.\b. c\bco\bom\bme\bed\bdi\bi_\b_g\bge\bet\bt_\b_n\bn_\b_r\bra\ban\bng\bge\bes\bs(\b()\b)
-
-
- int comedi_get_n_ranges(comedi_t *it,unsigned int subdevice, unsigned
- int chan);
-
- The function comedi_get_n_ranges() returns the number of ranges of the
- channel chan belonging to the subdevice of the comedi device it. This
- function returns -1 on error.
-
- Source: /lib/range.c
-
-
-
- 6\b6.\b.3\b3.\b.2\b21\b1.\b. c\bco\bom\bme\bed\bdi\bi_\b_g\bge\bet\bt_\b_n\bn_\b_s\bsu\bub\bbd\bde\bev\bvi\bic\bce\bes\bs(\b()\b)
-
-
- int comedi_get_n_subdevices(comedi_t *it);
-
- The function comedi_get_n_subdevices returns the number of subdevices
- associated with the comedi descriptor it, or -1 if there is an error.
-
- Source: /lib/get.c
-
-
-
- 6\b6.\b.3\b3.\b.2\b22\b2.\b. c\bco\bom\bme\bed\bdi\bi_\b_g\bge\bet\bt_\b_r\bra\ban\bng\bge\be(\b()\b)
-
-
- comedi_range * comedi_get_range(comedi_t *it,unsigned int
- subdevice,unsigned int chan,unsigned int range);
-
- The function comedi_get_range returns a pointer to a comedi_range
- structure that contains information that can be used to convert sample
- values to or from physical units. The pointer is valid until the
- comedi device it is closed. If there is an error, NULL is returned.
-
- Source: /lib/get.c
-
-
-
- 6\b6.\b.3\b3.\b.2\b23\b3.\b. c\bco\bom\bme\bed\bdi\bi_\b_g\bge\bet\bt_\b_r\bra\ban\bng\bge\bet\bty\byp\bpe\be(\b()\b) d\bde\bep\bpr\bre\bec\bca\bat\bte\bed\bd
-
-
- int comedi_get_rangetype(comedi_t *it,unsigned int subdevice,unsigned
- int chan);
-
- The function comedi_get_rangetype() returns an integer that represents
- the number of range specifications available for a particular channel
- chan of the subdevice subdevice, as well as a conversion table to
- convert sample values to/from physical units.
-
- The macro RANGE_LENGTH(rangetype) can be used to determine the number
- of range specifications for a given range type.
-
-
- This function is deprecated and should not be used in new code.
-
- Source: /lib/get.c
-
-
-
- 6\b6.\b.3\b3.\b.2\b24\b4.\b. c\bco\bom\bme\bed\bdi\bi_\b_g\bge\bet\bt_\b_s\bsu\bub\bbd\bde\bev\bvi\bic\bce\be_\b_t\bty\byp\bpe\be(\b()\b)
-
-
- int comedi_get_subdevice_type(comedi_t *it,unsigned int subdevice);
-
- The function comedi_get_subdevice_type() returns an integer describing
- the type of subdevice that belongs to the comedi device it and has the
- index subdevice. The function returns -1 is there is an error.
-
- Valid subdevice types are:
-
-
- +\bo COMEDI_SUBD_UNUSED Subdevice has no functionality, i.e., a place-
- holder.
-
- +\bo COMEDI_SUBD_AI Analog input
-
- +\bo COMEDI_SUBD_AO Analog output
-
- +\bo COMEDI_SUBD_DI Digital input
-
-
- +\bo COMEDI_SUBD_DO Digital output
-
- +\bo COMEDI_SUBD_DIO Digital input/output. Channels are configurable as
- to whether they are inputs or outputs.
-
- +\bo COMEDI_SUBD_COUNTER Counter
-
- +\bo COMEDI_SUBD_TIMER Timer
-
- +\bo COMEDI_SUBD_MEMORY Memory, e.g., EEPROM or dual-ported RAM
-
- +\bo COMEDI_SUBD_CALIB Calibration DACs
-
- +\bo COMEDI_SUBD_PROC Processor or DSP
-
- Source: /lib/get.c
-
-
-
- 6\b6.\b.3\b3.\b.2\b25\b5.\b. c\bco\bom\bme\bed\bdi\bi_\b_g\bge\bet\bt_\b_t\bti\bim\bme\ber\br(\b()\b) (\b(d\bde\bep\bpr\bre\bec\bca\bat\bte\bed\bd)\b)
-
-
- int comedi_get_timer(comedi_t *it,unsigned int subdev, double
- freq,unsigned int *trigvar, double *actual_freq);
-
-
- The function comedi_get_timer converts the frequency freq to a number
- suitable to send to the driver in a comedi_trig structure. This
- function remains for compatibility with very old versions of Comedi,
- that converted sampling rates to timer values in the libary. This
- conversion is now done in the kernel, and every device has the timer
- type nanosec_timer, indicating that timer values are simply a time
- specified in nanoseconds.
-
-
- This function is deprecated and should not be used in new
- applications.
-
-
- Source: /lib/timer.c
-
-
-
- 6\b6.\b.3\b3.\b.2\b26\b6.\b. c\bco\bom\bme\bed\bdi\bi_\b_g\bge\bet\bt_\b_v\bve\ber\brs\bsi\bio\bon\bn_\b_c\bco\bod\bde\be(\b()\b)
-
-
- int comedi_get_version_code(comedi_t *it);
-
-
- The function comedi_get_version_code() returns the version code of the
- currently running comedi module. The version code is of the form
- 0x01072b, which is the version code for version 1.7.43.
-
-
- This function is of limited usefulness. A typical mis-application of
- this function is to use it to determine if a certain feature is
- supported. If the application needs to know of the existence of a
- particular feature, an existence test function should be written and
- put in the libcomedi source.
-
- Source: /lib/get.c
-
-
-
- 6\b6.\b.3\b3.\b.2\b27\b7.\b. c\bco\bom\bme\bed\bdi\bi_\b_l\blo\bog\bgl\ble\bev\bve\bel\bl(\b()\b)
-
-
- int comedi_loglevel(int loglevel);
-
-
- This function affects the output of debugging and error messages from
- libcomedi. By increasing the loglevel, additional debugging
- information will be printed. This function returns the previous
- loglevel. Error messages and debugging are printed to the stream
- stderr. The loglevel can also be affected by the environment variable
- COMEDI_LOGLEVEL.
-
-
- In order to conserve resources, some debugging information is disabled
- when libcomedi is compiled.
-
-
- The meaning of the loglevels is as follows:
-
-
- +\bo COMEDILIB_LOGLEVEL=0
-
- Comedilib prints nothing.
-
- +\bo COMEDILIB_LOGLEVEL=1 (default)
-
- Comedilib only prints error messages when there is a self-
- consistency error (i.e., internal bug).
-
- +\bo COMEDILIB_LOGLEVEL=2
-
- Comedilib prints an error message when an invalid parameter is
- passed to comedilib.
-
- +\bo COMEDILIB_LOGLEVEL=3
-
- Comedilib prints an error message whenever an error is generated in
- the comedilib library or is generated in the C library when called
- by comedilib.
-
- +\bo COMEDILIB_LOGLEVEL=4
-
- Comedilib prints a lot of debugging messages.
-
- Bugs: Libcomedi doesn't currently have much debugging information.
-
- Source: /lib/error.c
-
-
-
- 6\b6.\b.3\b3.\b.2\b28\b8.\b. c\bco\bom\bme\bed\bdi\bi_\b_o\bop\bpe\ben\bn(\b()\b)
-
-
- comedi_t *comedi_open(char *filename);
-
- Opens a comedi device specified by the filename filename. Returns
- NULL on error. On sucess, it returns a handle that is given as a
- parameter to other libcomedi functions.
-
-
- You are not supposed to have access to the internals of the comedi_t
- structure.
-
- Bugs: Not strictly identical to fopen
-
- Source: /lib/comedi.c
-
-
-
- 6\b6.\b.3\b3.\b.2\b29\b9.\b. c\bco\bom\bme\bed\bdi\bi_\b_p\bpe\ber\brr\bro\bor\br(\b()\b)
-
-
- void comedi_perror(const char *s);
-
- When a comedilib function fails, it usually returns -1 or NULL,
- depending on the return type. An internal library variable stores an
- error number, which can be retrieved with ``comedi_errno()''. This
- error number can be converted to a human-readable form by the
- functions comedi_perror() and ``comedi_strerror()''.
-
- These functions are intended to mimic the behavior of the standard C
- library functions perror(), strerror, and errno(). In particular,
- comedilib functions sometimes return an error that is generated inside
- the C library; the comedi error message in this case is the same as
- the C library.
-
- The function comedi_perror() prints an error message to stderr. The
- error message consists of the argument string, a colon, a space, a
- description of the error condition, and a new line.
-
- Bugs: Does not support internationalization.
-
- Source: /lib/error.c
-
-
-
- 6\b6.\b.3\b3.\b.3\b30\b0.\b. c\bco\bom\bme\bed\bdi\bi_\b_s\bst\btr\bre\ber\brr\bro\bor\br(\b()\b)
-
-
- *comedi_strerror(int errnum);
-
- When a comedilib function fails, it usually returns -1 or NULL,
- depending on the return type. An internal library variable stores an
- error number, which can be retrieved with ``comedi_errno()''. This
- error number can be converted to a human-readable form by the
- functions ``comedi_perror()'' and comedi_strerror().
-
- These functions are intended to mimic the behavior of the standard C
- library functions perror(), strerror, and errno(). In particular,
- comedilib functions sometimes return an error that is generated inside
- the C library; the comedi error message in this case is the same as
- the C library.
-
- The function comedi_strerror() returns a pointer to a character string
- describing the comedilib error errnum. The persistence of the
- returned pointer is undefined, and should not be trusted after the
- next libcomedi call. An unrecognized error number will return a
- pointer to the string "undefined error", or similar.
-
- Bugs: Does not support internationalization.
-
- Source: /lib/error.c
-
-
-
- 6\b6.\b.3\b3.\b.3\b31\b1.\b. c\bco\bom\bme\bed\bdi\bi_\b_s\bsv\bv_\b_i\bin\bni\bit\bt(\b()\b)
-
-
- int comedi_sv_init(comedi_sv_t *sv,comedi_t *dev,unsigned int subd,
- unsigned int chan);
-
-
- comedi_sv_init initializes the slow varying comedi structure sv of the
- device dev, the subdevice subd (analog input) and the channel chan.
- The slow varying comedi structure sv of type ``comedi_sv_t'' specifies
- the signal measurement. The default number of averaged samples is
- 100. Returns zero on success, -1 on error.
-
- Bugs: comedi_sv_* was very poorly designed.
-
- Source: /lib/sv.c
-
-
-
- 6\b6.\b.3\b3.\b.3\b32\b2.\b. c\bco\bom\bme\bed\bdi\bi_\b_s\bsv\bv_\b_u\bup\bpd\bda\bat\bte\be(\b()\b)
-
-
- int comedi_sv_update(comedi_sv_t *sv);
-
- The function comedi_sv_update updates the slow varying comedi
- structure sv. Returns zero on success, -1 on error.
-
- Source: /lib/sv.c
-
-
-
- 6\b6.\b.3\b3.\b.3\b33\b3.\b. i\bin\bnt\bt c\bco\bom\bme\bed\bdi\bi_\b_s\bsv\bv_\b_m\bme\bea\bas\bsu\bur\bre\be(\b()\b)
-
-
- int comedi_sv_measure(comedi_sv_t *it,double *data);
-
- comedi_sv_measure measures the slow variing signal. The measurement is
- specified by the slow varying comedi structure sv, the result is
- stored in data. On success returns the number of samples, -1 on
- error.
-
- Source: /lib/sv.c
-
-
-
- 6\b6.\b.3\b3.\b.3\b34\b4.\b. c\bco\bom\bme\bed\bdi\bi_\b_t\bto\bo_\b_p\bph\bhy\bys\bs(\b()\b)
-
-
- double comedi_to_phys(lsampl_t data, comedi_range *rng, lsampl_t
- maxdata);
-
- Converts data given in sample values (lsampl_t, between 0 and maxdata)
- into physical units (double). The parameter rng represents the
- conversion information to use, and the parameter maxdata represents
- the maximum possible data value for the channel that the data was
- read.
-
- Source: /lib/range.c
-
-
-
- 6\b6.\b.3\b3.\b.3\b35\b5.\b. c\bco\bom\bme\bed\bdi\bi_\b_t\btr\bri\big\bgg\bge\ber\br(\b()\b) (\b(d\bde\bep\bpr\bre\bec\bca\bat\bte\bed\bd)\b)
-
-
- int comedi_trigger(comedi_t *it,comedi_trig *trig);
-
- The function comedi_trigger instructs comedi to perform the command
- specified by the ``trigger structure'' trig. Results depend on the
- particular command being issued. If there is an error, -1 is
- returned.
-
- Lifetime: removal at 1.0.
-
- Source: /lib/comedi.c
-
-
-
- 6\b6.\b.3\b3.\b.3\b36\b6.\b. c\bco\bom\bme\bed\bdi\bi_\b_g\bge\bet\bt_\b_s\bsu\bub\bbd\bde\bev\bvi\bic\bce\be_\b_f\bfl\bla\bag\bgs\bs(\b()\b)
-
-
- int comedi_get_subdevice_flags(comedi_t *dev, unsigned int subdevice);
-
-
- This function returns a bitfield describing the capabilities of the
- specified subdevice. If there is an error, -1 is returned.
-
-
- The bits are:
-
-
- +\bo SDF_BUSY subdevice is running a command
-
- +\bo SDF_BUSY_OWNER subdevice is running a command started by the file
- descriptor used by dev.
-
- +\bo SDF_LOCKED subdevice is locked
-
- +\bo SDF_LOCKED_OWNER subdevice is locked by the file descriptor
- used by dev.
-
- +\bo SDF_MAXDATA maximum data values are channel dependent
-
- +\bo SDF_FLAGS channel flags are channel dependent
-
- +\bo SDF_RANGETYPE range types are channel dependent
-
- +\bo SDF_MODE0 deprecated
-
- +\bo SDF_MODE1 deprecated
-
- +\bo SDF_MODE2 deprecated
-
- +\bo SDF_MODE3 deprecated
-
- +\bo SDF_MODE4 deprecated
-
- +\bo SDF_CMD subdevice supports commands
-
- +\bo SDF_READABLE subdevice can be read from
-
- +\bo SDF_WRITEABLE subdevice can be written to
-
- +\bo SDF_RT deprecated
-
- +\bo SDF_GROUND subdevice is capable of ground analog reference
-
- +\bo SDF_COMMON subdevice is capable of common analog reference
-
- +\bo SDF_DIFF subdevice is capable of differential analog
- reference
-
- +\bo SDF_OTHER subdevice is capable of other analog
- reference
-
- +\bo SDF_DITHER subdevice recognizes dither flag
-
- +\bo SDF_DEGLITCH subdevice recognizes deglitch flag
-
- +\bo SDF_MMAP deprecated
-
- +\bo SDF_RUNNING subdevice is acquiring data (i.e., command has not
- completed)
-
- +\bo SDF_LSAMPL subdevice uses samples of type lsampl_t (otherwise
- sampl_t)
-
- +\bo SDF_PACKED subdevice uses bitfield samples (otherwise it uses
- one sample per channel)
-
-
-
- The bit definitions are part of the Comedi kernel interface.
-
-
-
- 6\b6.\b.3\b3.\b.3\b37\b7.\b. c\bco\bom\bme\bed\bdi\bi_\b_r\bra\ban\bng\bge\be_\b_i\bis\bs_\b_c\bch\bha\ban\bn_\b_s\bsp\bpe\bec\bci\bif\bfi\bic\bc(\b()\b)
-
-
- int comedi_range_is_chan_specific(comedi_t *dev,unsigned int
- subdevice);
-
-
- If each channel of the specified subdevice has a different range
- specification, this function returns 1. Otherwise, this function
- returns 0. On error, this function returns -1.
-
-
-
- 6\b6.\b.3\b3.\b.3\b38\b8.\b. U\bUn\bnd\bdo\boc\bcu\bum\bme\ben\bnt\bte\bed\bd f\bfu\bun\bnc\bct\bti\bio\bon\bns\bs
-
-
-
- +\bo comedi_maxdata_is_chan_specific()
-
- +\bo comedi_get_buffer_size()
-
- +\bo comedi_get_max_buffer_size()
-
- +\bo comedi_set_buffer_size()
-
- +\bo comedi_set_max_buffer_size()
-
- +\bo comedi_do_insnlist()
-
- +\bo comedi_do_insn()
-
- +\bo comedi_lock()
-
- +\bo comedi_unlock()
-
- +\bo comedi_get_cmd_src_mask()
-
- +\bo comedi_get_cmd_generic_timed()
-
- +\bo comedi_cancel()
-
- +\bo comedi_poll()
-
- +\bo comedi_get_buffer_contents()
-
- +\bo comedi_mark_buffer_read()
-
- +\bo comedi_get_buffer_offset()
-
- +\bo comedi_set_global_oor_behavior()
-
-
-