145 lines
5.7 KiB
Text
145 lines
5.7 KiB
Text
Error reporting
|
|
Function: comedi_errno -- number of last Comedilib error
|
|
Retval: int
|
|
Param: void
|
|
Description:
|
|
When a Comedilib function fails, it usually returns <literal>-1</literal> or
|
|
<constant>NULL</constant>, depending on the return type. An internal library
|
|
variable stores an error number, which can be retrieved by calling
|
|
<function>comedi_errno</function> This error number can be converted to a
|
|
human-readable form by the functions
|
|
<function><link linkend="func-ref-comedi-perror">comedi_perror</link></function>
|
|
and
|
|
<function><link linkend="func-ref-comedi-strerror">comedi_strerror</link></function>.
|
|
|
|
These functions are intended to mimic the behavior of the
|
|
standard C library functions <function>perror</function>,
|
|
<function>strerror</function>, and <varname>errno</varname>.
|
|
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 <function>comedi_errno</function> returns an integer describing
|
|
the most recent Comedilib error. This integer may be used
|
|
as the <parameter class="function">errnum</parameter> parameter for
|
|
<function>comedi_strerror</function>.
|
|
|
|
Function: comedi_loglevel -- change Comedilib logging properties
|
|
Retval: int
|
|
Param: int loglevel
|
|
Description:
|
|
This function affects the output of debugging and error messages
|
|
from Comedilib. By increasing the log level <parameter
|
|
class="function">loglevel</parameter>, additional debugging
|
|
information will be printed. Error and debugging messages are
|
|
printed to the standard error output stream <varname>stderr</varname>.
|
|
|
|
The default loglevel can be set by using the environment variable
|
|
<envar>COMEDI_LOGLEVEL</envar>. The default log level is 1.
|
|
|
|
In order to conserve resources, some debugging information is
|
|
disabled by default when Comedilib is compiled.
|
|
|
|
The meaning of the log levels is as follows:
|
|
<informaltable colsep="1" rowsep="1">
|
|
<tgroup cols="2" align="left">
|
|
<colspec colwidth="*"/>
|
|
<colspec colwidth="5*"/>
|
|
<thead>
|
|
<row>
|
|
<entry>Loglevel</entry>
|
|
<entry>Behavior</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>0</entry>
|
|
<entry>Comedilib prints nothing.</entry>
|
|
</row>
|
|
<row>
|
|
<entry>1</entry>
|
|
<entry>
|
|
(default) Comedilib prints error messages when
|
|
there is a self-consistency error (i.e., an internal bug.)
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>2</entry>
|
|
<entry>
|
|
Comedilib prints an error message when an invalid
|
|
parameter is passed.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>3</entry>
|
|
<entry>
|
|
Comedilib prints an error message whenever an
|
|
error is generated in the Comedilib library or in the C library,
|
|
when called by Comedilib.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>4</entry>
|
|
<entry>Comedilib prints a lot of junk.</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
Returns:
|
|
This function returns the previous log level.
|
|
|
|
Function: comedi_perror -- print a Comedilib error message
|
|
Retval: void
|
|
Param: const char * s
|
|
Description:
|
|
When a Comedilib function fails, it usually returns <literal>-1</literal> or
|
|
<constant>NULL</constant>, depending on the return type. An internal library
|
|
variable stores an error number, which can be retrieved with
|
|
<function><link linkend="func-ref-comedi-errno">comedi_errno</link></function>.
|
|
This error number can be converted to a
|
|
human-readable form by the functions
|
|
<function>comedi_perror</function> or
|
|
<function><link linkend="func-ref-comedi-strerror">comedi_strerror</link></function>.
|
|
|
|
These functions are intended to mimic the behavior of the
|
|
standard C library functions <function>perror</function>,
|
|
<function>strerror</function>, and <varname>errno</varname>.
|
|
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 <function>comedi_perror</function> prints an error message to
|
|
the standard error output stream <varname>stderr</varname>.
|
|
The error message consists of the argument string
|
|
<parameter class="function">s</parameter>, a colon, a
|
|
space, a description of the error condition, and a new line.
|
|
|
|
Function: comedi_strerror -- return string describing Comedilib error code
|
|
Retval: const char *
|
|
Param: int errnum
|
|
Description:
|
|
When a Comedilib function fails, it usually returns <literal>-1</literal> or
|
|
<constant>NULL</constant>, depending on the return type. An internal library
|
|
variable stores an error number, which can be retrieved with
|
|
<function><link linkend="func-ref-comedi-errno">comedi_errno</link></function>.
|
|
This error number can be converted to a
|
|
human-readable form by the functions
|
|
<function><link linkend="func-ref-comedi-perror">comedi_perror</link></function>
|
|
or <function>comedi_strerror</function>.
|
|
|
|
These functions are intended to mimic the behavior of the
|
|
standard C library functions <function>perror</function>,
|
|
<function>strerror</function>, and <varname>errno</varname>.
|
|
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 <function>comedi_strerror</function> returns a pointer to a
|
|
character string
|
|
describing the Comedilib error <parameter class="function">errnum</parameter>.
|
|
The returned string may be
|
|
modified by a subsequent call to a <function>strerr</function> or
|
|
<function>perror</function> function
|
|
(either the <systemitem class="library">libc</systemitem> or Comedilib versions).
|
|
An unrecognized error number will
|
|
return a pointer to the string <quote>undefined error</quote>, or similar.
|