comedilib/doc/funcref

688 lines
29 KiB
Text
Raw Permalink Normal View History

Core Functions
2002-01-21 11:15:31 +00:00
Function: comedi_close -- close a Comedi device
Retval: int
Param: comedi * device
Description:
Close a device previously opened by
<function><link linkend="func-ref-comedi-open">comedi_open</link></function>.
2002-01-21 15:17:12 +00:00
Returns:
If successful, <function>comedi_close</function> returns <literal>0</literal>.
On failure, <literal>-1</literal> is returned.
2002-01-21 11:15:31 +00:00
Function: comedi_data_read -- read single sample from channel
2002-01-21 11:15:31 +00:00
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Param: unsigned int channel
Param: unsigned int range
Param: unsigned int aref
Param: lsampl_t * data
2002-01-21 11:15:31 +00:00
Description:
Reads a single sample on the channel specified by the Comedi
device <parameter class="function">device</parameter>, the subdevice
<parameter class="function">subdevice</parameter>, and the channel
<parameter class="function">channel</parameter>.
For the A/D conversion (if appropriate),
the device is configured to use range specification
<parameter class="function">range</parameter> and (if appropriate) analog
reference type <parameter class="function">aref</parameter>.
Analog reference types that are not supported
by the device are silently ignored.
2002-01-21 15:17:12 +00:00
The function <function>comedi_data_read</function> reads one data value from
the specified channel and stores the value in
<code>*<parameter class="function">data</parameter></code>.
2002-01-21 15:17:12 +00:00
WARNING: <function>comedi_data_read</function> does not do any pausing to
allow multiplexed analog inputs to settle before
starting an analog to digital conversion. If you are
switching between different channels and need to allow
your analog input to settle for an accurate reading,
use
<function><link linkend="func-ref-comedi-data-read-delayed">comedi_data_read_delayed</link></function>,
or set the
input channel at an earlier time with
<function><link linkend="func-ref-comedi-data-read-hint">comedi_data_read_hint</link></function>.
2002-01-21 15:17:12 +00:00
Data values returned by this function are unsigned integers
less than or equal to the maximum sample value of the channel,
which can be determined using the function
<function><link linkend="func-ref-comedi-get-maxdata">comedi_get_maxdata</link></function>.
Conversion of data values to physical units can be performed
by the functions <function><link linkend="func-ref-comedi-to-phys">comedi_to_phys</link></function> (linear conversion) or <function><link linkend="func-ref-comedi-to-physical">comedi_to_physical</link></function> (non-linear polynomial conversion).
Returns:
On success, <function>comedi_data_read</function> returns <literal>1</literal> (the number of samples
read). If there is an error, <literal>-1</literal> is returned.
2002-01-21 15:17:12 +00:00
Function: comedi_data_read_n -- read multiple samples from channel
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Param: unsigned int channel
Param: unsigned int range
Param: unsigned int aref
Param: lsampl_t * data
Param: unsigned int n
Description:
Similar to
<function><link linkend="func-ref-comedi-data-read">comedi_data_read</link></function>
except it reads <parameter class="function">n</parameter> samples into the
array <parameter class="function">data</parameter>.
The precise timing of the samples is not hardware controlled.
Function: comedi_data_read_delayed -- read single sample from channel after delaying for specified settling time
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Param: unsigned int channel
Param: unsigned int range
Param: unsigned int aref
Param: lsampl_t * data
Param: unsigned int nanosec
Description:
Similar to
<function><link linkend="func-ref-comedi-data-read">comedi_data_read</link></function>
except it will wait for the
specified number of nanoseconds between setting the input
channel and taking a sample. For analog inputs, most
boards have a single
analog to digital converter which is multiplexed to be
able to read multiple channels. If the input is not allowed
to settle after the multiplexer switches channels, the
reading will be inaccurate. This function is useful
for allowing a multiplexed analog input to settle
when switching channels.
2002-01-21 15:17:12 +00:00
Although the settling time is specified in nanoseconds, the
actual settling time will be rounded up to the nearest
microsecond.
2002-01-21 11:15:31 +00:00
Function: comedi_data_read_hint -- tell driver which channel/range/aref you are going to read from next
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Param: unsigned int channel
Param: unsigned int range
Param: unsigned int aref
2002-01-21 11:15:31 +00:00
Description:
Used to prepare an analog input for a subsequent call to
<function><link linkend="func-ref-comedi-data-read">comedi_data_read</link></function>.
It is not necessary to use this
function, but it can be useful for eliminating inaccuracies
caused by insufficient settling times when switching the
channel
or gain on an analog input. This function sets an analog input
to the channel, range, and aref specified but does not
perform an actual analog to digital conversion.
2002-01-21 15:17:12 +00:00
Alternatively, one can simply use
<function><link linkend="func-ref-comedi-data-read-delayed">comedi_data_read_delayed</link></function>,
which sets up the
input, pauses to allow settling, then performs a conversion.
2002-01-21 11:15:31 +00:00
Function: comedi_data_write -- write single sample to channel
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Param: unsigned int channel
Param: unsigned int range
Param: unsigned int aref
Param: lsampl_t data
2002-01-21 11:15:31 +00:00
Description:
Writes a single sample on the channel that is specified by the
Comedi device <parameter class="function">device</parameter>, the subdevice
<parameter class="function">subdevice</parameter>, and the channel
<parameter class="function">channel</parameter>. If appropriate, the device is
configured to use range
specification <parameter class="function">range</parameter> and analog
reference type <parameter class="function">aref</parameter>. Analog
reference types that are not supported by the device are
silently ignored.
2002-01-21 15:17:12 +00:00
The function <function>comedi_data_write</function> writes the data value specified
by the parameter <parameter class="function">data</parameter> to the specified channel.
Returns:
On success, <function>comedi_data_write</function> returns <literal>1</literal> (the number of samples
written). If there is an error, <literal>-1</literal> is returned.
2002-01-21 11:15:31 +00:00
Function: comedi_do_insn -- perform instruction
2002-01-21 11:15:31 +00:00
Retval: int
Param: comedi_t * device
Param: comedi_insn * instruction
2002-01-21 11:15:31 +00:00
Description:
The function <function>comedi_do_insn</function> performs a single instruction.
Returns:
If successful, returns a non-negative number. For the case
of <constant>INSN_READ</constant> or <constant>INSN_WRITE</constant> instructions,
<function>comedi_do_insn</function> returns the number of samples
read or written, which may be less than the number requested.
If there is an error, <literal>-1</literal> is returned.
2002-01-21 15:17:12 +00:00
Function: comedi_do_insnlist -- perform multiple instructions
Retval: int
Param: comedi_t * device
Param: comedi_insnlist * list
Description:
The function <function>comedi_do_insnlist</function> performs multiple Comedi
instructions as part of one system call. This function
can be used to avoid the overhead of multiple
system calls.
Returns:
The function <function>comedi_do_insnlist</function> returns the number of
successfully completed instructions. Error information for
the unsuccessful instruction is not available. If there is
an error before the first instruction can be executed, <literal>-1</literal>
is returned.
2002-01-21 11:15:31 +00:00
Function: comedi_fileno -- get file descriptor for open Comedilib device
2002-01-21 11:15:31 +00:00
Retval: int
Param: comedi_t * device
Description:
The function <function>comedi_fileno</function> returns the file descriptor for
the device <parameter class="function">device</parameter>. This descriptor can then be used as the
file descriptor parameter of <function>read</function>, <function>write</function>, etc.
2002-01-21 15:17:12 +00:00
This function is intended to mimic the standard C library
function <function>fileno</function>.
The returned file descriptor should not be closed, and will
become invalid when
<function><link linkend="func-ref-comedi-close">comedi_close</link></function>
is called on <parameter class="function">device</parameter>.
Returns:
A file descriptor, or <literal>-1</literal> on error.
2002-01-21 11:15:31 +00:00
Function: comedi_find_range -- search for range
2002-01-21 11:15:31 +00:00
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Param: unsigned int channel
Param: unsigned int unit
Param: double min
Param: double max
2002-01-21 11:15:31 +00:00
Description:
The function <function>comedi_find_range</function> tries to
locate the optimal (smallest) range for the channel
<parameter class="function">channel</parameter>
belonging to subdevice <parameter class="function">subdevice</parameter>
of the comedi device <parameter class="function">device</parameter>,
that includes both <parameter class="function">min</parameter>
and <parameter class="function">max</parameter> in
units of <parameter class="function">unit</parameter>.
Returns:
If a matching range is found, the index of the matching range is
returned. If no matching range is available, the function returns
<literal>-1</literal>.
2002-01-21 11:15:31 +00:00
Function: comedi_find_subdevice_by_type -- search for subdevice type
2002-01-21 11:15:31 +00:00
Retval: int
Param: comedi_t * device
Param: int type
Param: unsigned int start_subdevice
2002-01-21 11:15:31 +00:00
Description:
The function <function>comedi_find_subdevice_by_type</function> tries to
locate a subdevice belonging to comedi device
<parameter class="function">device</parameter>,
having type <parameter class="function">type</parameter>, starting with
the subdevice <parameter class="function">start_subdevice</parameter>. The
<type><link linkend="ref-enum-comedi-subdevice-type">comedi_subdevice_type</link></type> enum
specifies the possible subdevice types.
Returns:
If it finds a subdevice with the requested
type, it returns its index. If there is an error, the function
returns <literal>-1</literal> and sets the appropriate error.
2002-01-21 15:17:12 +00:00
Function: comedi_from_phys -- convert physical units to sample
Retval: lsampl_t
Param: double data
Param: comedi_range * range
Param: lsampl_t maxdata
Description:
Converts parameter <parameter class="function">data</parameter> given in
physical units (<type>double</type>) into sample values
(<type>lsampl_t</type>, between <literal>0</literal> and maxdata).
The parameter <parameter class="function">range</parameter>
represents the conversion information to use, and the parameter
<parameter class="function">maxdata</parameter> represents the maximum possible data value for the
channel that the data will be written to. The mapping between
physical units and raw data is linear and
assumes that the converter has ideal characteristics.
Conversion is not affected by out-of-range behavior. Out-of-range
data parameters are silently truncated to the range <literal>0</literal>
to <parameter class="function">maxdata</parameter>.
Function: comedi_from_physical -- convert physical units to sample using calibration data
Retval: lsampl_t
Param: double data
Param: const comedi_polynomial_t * conversion_polynomial
Description:
Converts <parameter class="function">data</parameter> given in physical units into Comedi's
integer sample values
(<type>lsampl_t</type>, between <literal>0</literal> and maxdata &mdash;
see <function><link linkend="func-ref-comedi-get-maxdata">comedi_get_maxdata</link></function>).
The <parameter class="function">conversion_polynomial</parameter>
parameter is obtained from either
<function><link linkend="func-ref-comedi-get-hardcal-converter">comedi_get_hardcal_converter</link></function> or
<function><link linkend="func-ref-comedi-get-softcal-converter">comedi_get_softcal_converter</link></function>. The allows non linear and board specific
correction.
The result will be rounded
using the C library's current rounding direction.
No range checking of the input
<parameter class="function">data</parameter> is performed. It is up to you to ensure
your data is within the limits of the output range you are using.
Returns:
Comedi sample value corresponding to input physical value.
Function: comedi_get_board_name -- Comedi device name
Retval: const char *
Param: comedi_t * device
Description:
The function <function>comedi_get_board_name</function> returns a pointer
to a string containing the name of the comedi device represented by
<parameter class="function">device</parameter>. This pointer is
valid until the device is closed. This
function returns <constant>NULL</constant> if there is an error.
2002-01-21 11:15:31 +00:00
Function: comedi_get_driver_name -- Comedi driver name
Retval: char *
Param: comedi_t * device
Description:
The function <function>comedi_get_driver_name</function> returns a pointer
2002-01-21 15:17:12 +00:00
to a string containing the name of the driver being used by comedi
for the comedi device represented by <parameter class="function">device</parameter>. This pointer is
valid until the device is closed. This function returns <constant>NULL</constant>
2002-01-21 15:17:12 +00:00
if there is an error.
2002-01-21 11:15:31 +00:00
Function: comedi_get_maxdata -- maximum sample of channel
Retval: lsampl_t
2002-01-21 11:15:31 +00:00
Param: comedi_t * device
Param: unsigned int subdevice
Param: unsigned int channel
2002-01-21 11:15:31 +00:00
Description:
The function <function>comedi_get_maxdata</function> returns the maximum
valid data value for channel <parameter class="function">channel</parameter>
of subdevice <parameter clas="function">subdevice</parameter> belonging to
the comedi device <parameter class="function">device</parameter>.
Returns:
The maximum valid sample value, or <literal>0</literal> on error.
2002-01-21 11:15:31 +00:00
Function: comedi_get_n_channels -- number of subdevice channels
2002-01-21 11:15:31 +00:00
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Description:
The function <function>comedi_get_n_channels</function> returns the number
of channels of the subdevice <parameter class="function">subdevice</parameter>
belonging to the comedi device <parameter class="function">device</parameter>.
This function returns <literal>-1</literal> on error and
the Comedilib error value is set.
2002-01-21 11:15:31 +00:00
Function: comedi_get_n_ranges -- number of ranges of channel
2002-01-21 11:15:31 +00:00
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Param: unsigned int channel
2002-01-21 11:15:31 +00:00
Description:
The function <function>comedi_get_n_ranges</function> returns the number
of ranges of the channel <parameter class="function">channel</parameter>
belonging to the subdevice <parameter class="function">subdevice</parameter>
of the comedi device <parameter class="function">device</parameter>.
This function returns <literal>-1</literal> on error.
2002-01-21 11:15:31 +00:00
Function: comedi_get_n_subdevices -- number of subdevices
2002-05-01 19:24:27 +00:00
Retval: int
Param: comedi_t * device
Description:
The function <function>comedi_get_n_subdevices</function> returns the number
of subdevices belonging to the Comedi
device referenced by the parameter <parameter class="function">device</parameter>,
or <literal>-1</literal> on error.
2002-05-01 19:24:27 +00:00
Function: comedi_get_range -- range information of channel
Retval: comedi_range *
2002-05-01 19:24:27 +00:00
Param: comedi_t * device
Param: unsigned int subdevice
Param: unsigned int channel
Param: unsigned int range
Description:
The function <function>comedi_get_range</function> returns a pointer to a
<type><link linkend="ref-type-comedi-range">comedi_range</link></type>
structure that contains information on
the range specified by the <parameter class="function">subdevice</parameter>,
<parameter class="function">channel</parameter>,
and <parameter class="function">range</parameter> parameters.
The pointer is valid until the Comedi device
<parameter class="function">device</parameter> is closed.
If there is an error, <constant>NULL</constant> is returned.
2002-01-21 11:15:31 +00:00
Function: comedi_get_subdevice_flags -- properties of subdevice
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Description:
The function <function>comedi_get_subdevice_flags</function>
returns a bitfield describing the capabilities of
the specified subdevice <parameter class="function">subdevice</parameter>
of the Comedi device <parameter class="function">device</parameter>.
If there is an error, <literal>-1</literal> is returned,
2002-01-21 15:17:12 +00:00
and the Comedilib error value is set.
<informaltable colsep="1" rowsep="1" orient="port" pgwide="1">
<tgroup cols="3" align="left" >
<thead>
<row>
<entry>Subdevice Flag</entry>
<entry>Value (hex)</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><constant>SDF_BUSY</constant></entry>
<entry><literal>0x00000001</literal></entry>
<entry>The subdevice is busy performing an asynchronous command.
A subdevice being <quote>busy</quote>
is slightly different from the <quote>running</quote> state flagged by
<constant>SDF_RUNNING</constant>. A <quote>running</quote> subdevice
is always <quote>busy</quote>, but a <quote>busy</quote> subdevice is
not necessarily <quote>running</quote>. For example, suppose an
analog input command has been completed by the hardware, but there are still samples in
Comedi's buffer waiting to be read out. In this case, the subdevice is not
<quote>running</quote>, but is still <quote>busy</quote> until all the
samples are read out or <function><link linkend="func-ref-comedi-cancel">comedi_cancel</link></function> is called.</entry>
</row>
<row>
<entry><constant>SDF_BUSY_OWNER</constant></entry>
<entry><literal>0x00000002</literal></entry>
<entry>The subdevice is <quote>busy</quote>, and the command it is running was started by the current process.</entry>
</row>
<row>
<entry><constant>SDF_LOCKED</constant></entry>
<entry><literal>0x00000004</literal></entry>
<entry>The subdevice has been locked by <function><link linkend="func-ref-comedi-lock">comedi_lock</link></function>.</entry>
</row>
<row>
<entry><constant>SDF_LOCK_OWNER</constant></entry>
<entry><literal>0x00000008</literal></entry>
<entry>The subdevice is locked, and was locked by the current process.</entry>
</row>
<row>
<entry><constant>SDF_MAXDATA</constant></entry>
<entry><literal>0x00000010</literal></entry>
<entry>The maximum data value for the subdevice depends on the channel.</entry>
</row>
<row>
<entry><constant>SDF_FLAGS</constant></entry>
<entry><literal>0x00000020</literal></entry>
<entry>The subdevice flags depend on the channel (unfinished/broken support in library).</entry>
</row>
<row>
<entry><constant>SDF_RANGETYPE</constant></entry>
<entry><literal>0x00000040</literal></entry>
<entry>The range type depends on the channel.</entry>
</row>
<row>
<entry><constant>SDF_CMD</constant></entry>
<entry><literal>0x00001000</literal></entry>
<entry>The subdevice supports asynchronous commands.</entry>
</row>
<row>
<entry><constant>SDF_SOFT_CALIBRATED</constant></entry>
<entry><literal>0x00002000</literal></entry>
<entry>The subdevice relies on the host to do calibration in software.
Software calibration coefficients are determined by the <command>comedi_soft_calibrate</command>
utility. See the description of the
<function><link linkend="func-ref-comedi-get-softcal-converter">comedi_get_softcal_converter</link></function> function
for more information.
</entry>
</row>
<row>
<entry><constant>SDF_READABLE</constant></entry>
<entry><literal>0x00010000</literal></entry>
<entry>The subdevice can be read (e.g. analog input).</entry>
</row>
<row>
<entry><constant>SDF_WRITABLE</constant></entry>
<entry><literal>0x00020000</literal></entry>
<entry>The subdevice can be written to (e.g. analog output).</entry>
</row>
<row>
<entry><constant>SDF_INTERNAL</constant></entry>
<entry><literal>0x00040000</literal></entry>
<entry>The subdevice does not have externally visible lines.</entry>
</row>
<row>
<entry><constant>SDF_GROUND</constant></entry>
<entry><literal>0x00100000</literal></entry>
<entry>The subdevice supports analog reference <constant>AREF_GROUND</constant>.</entry>
</row>
<row>
<entry><constant>SDF_COMMON</constant></entry>
<entry><literal>0x00200000</literal></entry>
<entry>The subdevice supports analog reference <constant>AREF_COMMON</constant>.</entry>
</row>
<row>
<entry><constant>SDF_DIFF</constant></entry>
<entry><literal>0x00400000</literal></entry>
<entry>The subdevice supports analog reference <constant>AREF_DIFF</constant>.</entry>
</row>
<row>
<entry><constant>SDF_OTHER</constant></entry>
<entry><literal>0x00800000</literal></entry>
<entry>The subdevice supports analog reference <constant>AREF_OTHER</constant></entry>
</row>
<row>
<entry><constant>SDF_DITHER</constant></entry>
<entry><literal>0x01000000</literal></entry>
<entry>The subdevice supports dithering (via the <constant>CR_ALT_FILTER</constant> chanspec flag).</entry>
</row>
<row>
<entry><constant>SDF_DEGLITCH</constant></entry>
<entry><literal>0x02000000</literal></entry>
<entry>The subdevice supports deglitching (via the <constant>CR_ALT_FILTER</constant> chanspec flag).</entry>
</row>
<row>
<entry><constant>SDF_RUNNING</constant></entry>
<entry><literal>0x08000000</literal></entry>
<entry>An asynchronous command is running. You can use this flag to poll for the completion of an
output command.</entry>
</row>
<row>
<entry><constant>SDF_LSAMPL</constant></entry>
<entry><literal>0x10000000</literal></entry>
<entry>The subdevice uses the 32-bit <type>lsampl_t</type> type instead of
the 16-bit <type>sampl_t</type> for
asynchronous command data.</entry>
</row>
<row>
<entry><constant>SDF_PACKED</constant></entry>
<entry><literal>0x20000000</literal></entry>
<entry>The subdevice uses bitfield samples for asynchronous command data,
one bit per channel (otherwise it uses
one <type>sampl_t</type> or <type>lsampl_t</type> per channel).
Commonly used for digital subdevices.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
2002-01-21 11:15:31 +00:00
Function: comedi_get_subdevice_type -- type of subdevice
2002-01-21 11:15:31 +00:00
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Description:
The function <function>comedi_get_subdevice_type</function> returns an
integer describing the type of subdevice that belongs to the comedi
device <parameter class="function">device</parameter> and has the subdevice index
<parameter class="function">subdevice</parameter>. The
<type><link linkend="ref-enum-comedi-subdevice-type">comedi_subdevice_type</link></type> enum
specifies the possible values for the subdevice type.
Returns:
The function returns the subdevice type, or
<literal>-1</literal> if there is an error.
2002-01-21 11:15:31 +00:00
Function: comedi_get_version_code -- Comedi version code
2002-01-21 11:15:31 +00:00
Retval: int
Param: comedi_t * device
Description:
Returns the Comedi kernel module version code. A valid Comedi
device referenced by the parameter <parameter class="function">device</parameter>
is necessary to
communicate with the kernel module. On error, <literal>-1</literal> is returned.
The version code is encoded as a bitfield of three 8-bit
numbers. For example, <literal>0x00073d</literal> is the version code for
version 0.7.61.
2002-01-21 11:15:31 +00:00
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 Comedilib source.
2002-01-21 11:15:31 +00:00
Function: comedi_internal_trigger -- generate soft trigger
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Param: unsigned int trig_num
Description:
This function sends an <constant>INSN_INTTRIG</constant> instruction to a subdevice, which causes an internal triggering event.
This event can, for example, trigger a subdevice to start an asynchronous command.
The <parameter class="function">trig_num</parameter> parameter is reserved for future use, and should be set to 0.
It is likely it will be used in the future to support multiple independent internal triggers.
For example, an asynchronous command might be specified for a subdevice
with a <structfield>start_src</structfield> of <constant>TRIG_INT</constant>,
and a <structfield>start_arg</structfield> of <literal>5</literal>.
Then the start event would only be triggered if <function>comedi_internal_trigger</function>
were called on the subdevice with a <parameter class="function">trig_num</parameter>
equal to the same value of <literal>5</literal>.
Returns:
<literal>0</literal> on success, <literal>-1</literal> on error.
2002-01-21 11:15:31 +00:00
Function: comedi_lock -- subdevice reservation
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Description:
The function <function>comedi_lock</function> reserves a subdevice for use by the
2002-01-21 15:17:12 +00:00
current process. While the lock is held, no other process is
allowed to read, write, or configure that subdevice, although
other processes can read information about the subdevice. The
lock is released by
<function><link linkend="func-ref-comedi-unlock">comedi_unlock</link></function>,
or when
<function><link linkend="func-ref-comedi-close">comedi_close</link></function>
is called on <parameter class="function">device</parameter>.
Returns:
If successful, <literal>0</literal> is returned. If there is an error,
<literal>-1</literal> is returned.
2002-01-21 11:15:31 +00:00
Function: comedi_maxdata_is_chan_specific -- maximum sample depends on channel
2002-01-21 11:15:31 +00:00
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Description:
If each channel of the specified subdevice may have different maximum
sample values, this function returns <literal>1</literal>. Otherwise, this function
returns <literal>0</literal>. On error, this function returns <literal>-1</literal>.
2002-01-21 11:15:31 +00:00
Function: comedi_open -- open a Comedi device
Retval: comedi_t *
Param: const char * filename
Description:
Open a Comedi device specified by the file filename.
Returns:
If successful, <function>comedi_open</function> returns a pointer to
a valid <type>comedi_t</type>
structure. This structure is opaque; the pointer should not
be dereferenced by the application. <constant>NULL</constant> is returned on failure.
Function: comedi_range_is_chan_specific -- range information depends on channel
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
2002-01-21 11:15:31 +00:00
Description:
If each channel of the specified subdevice may have different range
information, this function returns <literal>1</literal>. Otherwise, this function
returns <literal>0</literal>. On error, this function returns <literal>-1</literal>.
2002-01-21 15:17:12 +00:00
Function: comedi_set_global_oor_behavior -- out-of-range behavior
Retval: enum comedi_oor_behavior
Param: enum comedi_oor_behavior behavior
Description:
This function changes the Comedilib out-of-range behavior.
This currently affects the behavior of
<function><link linkend="func-ref-comedi-to-phys">comedi_to_phys</link></function>
when converting endpoint sample values, that is, sample values
equal to <literal>0</literal> or <parameter
class="function">maxdata</parameter>. If the out-of-range behavior is set to
<constant>COMEDI_OOR_NAN</constant>, endpoint values are converted to
<constant>NAN</constant>. If the
out-of-range behavior is set to <constant>COMEDI_OOR_NUMBER</constant>, the endpoint
values are converted similarly to other values.
Returns:
The previous out-of-range behavior is returned.
Function: comedi_to_phys -- convert sample to physical units
Retval: double
Param: lsampl_t data
Param: comedi_range * range
Param: lsampl_t maxdata
Description:
Converts parameter <parameter class="function">data</parameter> given in sample values
(<type>lsampl_t</type>, between <literal>0</literal> and
<parameter class="function">maxdata</parameter>) into physical units
(<type>double</type>). The parameter <parameter
class="function">range</parameter>
represents the conversion information to use, and the parameter
<parameter class="function">maxdata</parameter> represents the maximum possible data value for the
channel that the data was read. The mapping between physical units
is linear and assumes ideal converter characteristics.
Conversion of endpoint sample values, that is, sample values
equal to <literal>0</literal> or <parameter class="function">maxdata</parameter>,
is affected by the Comedilib out-of-range
behavior (see function <function><link
linkend="func-ref-comedi-set-global-oor-behavior"
>comedi_set_global_oor_behavior</link></function>).
If the out-of-range behavior is set to
<constant>COMEDI_OOR_NAN</constant>,
endpoint values are converted to <constant>NAN</constant>. If the out-of-range
behavior is set to <constant>COMEDI_OOR_NUMBER</constant>, the endpoint values are
converted similarly to other values.
If there is an error, <constant>NAN</constant> is returned.
Function: comedi_to_physical -- convert sample to physical units using polynomials
Retval: double
Param: lsampl_t data
Param: const comedi_polynomial_t * conversion_polynomial
Description:
Converts <parameter class="function">data</parameter> given in Comedi's integer
sample values (<type>lsampl_t</type>, between <literal>0</literal> and
maxdata) into physical units (<type>double</type>). The
<parameter class="function">conversion_polynomial</parameter>
parameter is obtained from either
<function><link linkend="func-ref-comedi-get-hardcal-converter">comedi_get_hardcal_converter</link></function> or
<function><link linkend="func-ref-comedi-get-softcal-converter">comedi_get_softcal_converter</link></function>.
No range checking of the
input <parameter class="function">data</parameter> is performed. It is up to
you to check for <parameter class="function">data</parameter> values of
0 or maxdata if you want to detect possibly out-of-range readings.
Returns:
Physical value corresponding to the input sample value.
Function: comedi_unlock -- subdevice reservation
2002-01-21 11:15:31 +00:00
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Description:
The function <function>comedi_unlock</function> releases a subdevice locked
by
<function><link linkend="func-ref-comedi-lock">comedi_lock</link></function>.
Returns:
<literal>0</literal> on success, otherwise <literal>-1</literal>.
2003-07-08 22:39:23 +00:00