added get_subdevice_flags()
[comedilib.git] / doc / comedilib_reference-4.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML>
3 <HEAD>
4  <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
5  <TITLE>Comedi Documentation: Reference Comedilib-0.7.9: functions</TITLE>
6  <LINK HREF="comedilib_reference-3.html" REL=previous>
7  <LINK HREF="comedilib_reference.html#toc4" REL=contents>
8 </HEAD>
9 <BODY>
10 Next
11 <A HREF="comedilib_reference-3.html">Previous</A>
12 <A HREF="comedilib_reference.html#toc4">Contents</A>
13 <HR>
14 <H2><A NAME="s4">4. Reference Comedilib-0.7.9: functions</A></H2>
15
16 <P>
17 <P>
18 <H2><A NAME="ss4.1">4.1 comedi_close()</A>
19 </H2>
20
21 <P>
22 <P><CODE>void comedi_close(comedi_t *it);</CODE>
23 <P>Closes a device previously opened by comedi_open().
24 <P>Source: <CODE>/lib/comedi.c</CODE>
25 <P>
26 <H2><A NAME="ss4.2">4.2 comedi_data_read()</A>
27 </H2>
28
29 <P>
30 <P><CODE>int comedi_data_read(comedi_t *it,unsigned int subd,unsigned int chan,
31 unsigned int range,unsigned int aref,lsampl_t *data);</CODE>
32 <P>Reads a single sample on the channel that
33 is specified by the comedi device <CODE>it</CODE>, the
34 subdevice <CODE>subd</CODE>, and the channel <CODE>chan</CODE>.
35 For the operation,
36 the device is configured to use range specification
37 <CODE>range</CODE> and (if appropriate) analog reference type
38 <CODE>aref</CODE>.  Analog reference types that are not supported
39 by the device are silently ignored.
40 <P><CODE>comedi_data_read()</CODE> reads one data value from
41 the specified channel and places the 
42 data value that is read in the location pointed to by
43 <CODE>data</CODE>.
44 <P>On sucess, <CODE>comedi_data_read()</CODE> returns 0.  If there is an error, -1 is
45 returned.
46 <P>Valid analog reference numbers are:
47 <P>
48 <UL>
49 <LI>AREF_GROUND Reference to analog ground</LI>
50 <LI>AREF_COMMON Reference to analog common</LI>
51 <LI>AREF_DIFF           Differential reference</LI>
52 <LI>AREF_OTHER  Board-specific meaning</LI>
53 </UL>
54 <P>Valid data values used by these function is an unsigned integer
55 less than or equal to <CODE>maxdata</CODE>, which is channel-dependent.
56 Conversion of these data value to physical units can be performed
57 by <CODE>
58 <A HREF="#comedi_to_phys">comedi_to_phys()</A></CODE>.
59 <P>Source: <CODE>/lib/data.c</CODE>
60 <P>
61 <P>
62 <H2><A NAME="ss4.3">4.3 comedi_data_write()</A>
63 </H2>
64
65 <P>
66 <P><CODE>int comedi_data_write(comedi_t *it,unsigned int subd,unsigned int chan,
67 unsigned int range,unsigned int aref,lsampl_t data);</CODE>
68 <P>Writes a single sample on the channel that
69 is specified by the comedi device <CODE>it</CODE>, the
70 subdevice <CODE>subd</CODE>, and the channel <CODE>chan</CODE>.
71 For the operation,
72 the device is configured to use range specification
73 <CODE>range</CODE> and (if appropriate) analog reference type
74 <CODE>aref</CODE>.  Analog reference types that are not supported
75 by the device are silently ignored.
76 <P><CODE>comedi_data_write()</CODE> writes the data value
77 specified by the argument <CODE>data</CODE> to
78 the specified channel.
79 <P>On sucess, <CODE>comedi_data_write()</CODE> returns 0.  If there is an error, -1 is
80 returned.
81 <P>Valid analog reference numbers are:
82 <P>
83 <UL>
84 <LI>AREF_GROUND Reference to analog ground</LI>
85 <LI>AREF_COMMON Reference to analog common</LI>
86 <LI>AREF_DIFF           Differential reference</LI>
87 <LI>AREF_OTHER  Board-specific meaning</LI>
88 </UL>
89 <P>Valid data values used by these functions is an unsigned integer
90 less than or equal to <CODE>maxdata</CODE>, which is channel-dependent.
91 Conversion of physical units to these data value can be performed
92 by <CODE>
93 <A HREF="#comedi_from_phys">comedi_from_phys()</A></CODE>.
94 <P>Source: <CODE>/lib/data.c</CODE>
95 <P>
96 <P>
97 <P>
98 <H2><A NAME="ss4.4">4.4 comedi_dio_bitfield();</A>
99 </H2>
100
101 <P>int comedi_dio_bitfield(comedi_t *it,unsigned int subd,unsigned int write_mask,
102 unsigned int *bits);
103 <P>Source: <CODE>/lib/dio.c</CODE>
104 <P>
105 <P>
106 <H2><A NAME="ss4.5">4.5 comedi_dio_config()</A>
107 </H2>
108
109 <P><CODE>int comedi_dio_config(comedi_t *it,unsigned int subd,unsigned int chan,unsigned int dir);</CODE>
110 <P>The function <CODE>comedi_dio_config</CODE> configures the direction <CODE>dir</CODE> of
111 channel <CODE>chan</CODE> belonging to the configurable digital input/output subdevice
112 <CODE>subd</CODE> of the device <CODE>it</CODE>. Returns -1 on failure.
113 <P>
114 <P>Valid directions are:
115 <UL>
116 <LI> COMEDI_INPUT</LI>
117 <LI> COMEDI_OUTPUT</LI>
118 </UL>
119 <P>Source: <CODE>/lib/dio.c</CODE>
120 <P>
121 <P>
122 <H2><A NAME="ss4.6">4.6 comedi_dio_read()</A>
123 </H2>
124
125 <P><CODE>int comedi_dio_read(comedi_t *it,unsigned int subd,unsigned int chan,unsigned int *bit);</CODE>
126 <P>The function reads the status of channel <CODE>chan</CODE> belonging to the digital
127 input subdevice <CODE>subd</CODE> of device <CODE>it</CODE>. The result, 0 or 1, is stored
128 in bit. Returns -1 on failure.
129 <P>Source: <CODE>/lib/dio.c</CODE>
130 <P>
131 <P>
132 <H2><A NAME="ss4.7">4.7 comedi_dio_write()</A>
133 </H2>
134
135 <P><CODE>int comedi_dio_write(comedi_t *it,unsigned int subd,unsigned int chan,unsigned int bit);</CODE>
136 <P>The function writes the value of <CODE>bit</CODE>, 0 or 1, in channel <CODE>chan</CODE>,
137 belonging to the digital output device <CODE>subd</CODE> of device <CODE>it</CODE>. Returns
138 -1 on failure.
139 <P>Source: <CODE>/lib/dio.c</CODE>
140 <P>
141 <P>
142 <H2><A NAME="ss4.8">4.8 comedi_fileno()</A>
143 </H2>
144
145 <P>
146 <P><CODE>int comedi_fileno(comedi_t *it);</CODE>
147 <P>The function <CODE>comedi_fileno</CODE>
148 returns the integer descriptor for the handle <CODE>it</CODE>.  If
149 <CODE>it</CODE> is an invalid <CODE>comedi_t</CODE> pointer, the function
150 returns -1 and sets the appropriate comedilib error value.
151 <P>Source: <CODE>/lib/comedi.c</CODE>
152 <P>
153 <P>
154 <P>
155 <H2><A NAME="ss4.9">4.9 comedi_find_range()</A>
156 </H2>
157
158 <P>
159 <P><CODE>int comedi_find_range(comedi_t *it, unsigned int subdevice, unsigned
160 int chan, unsigned int unit, double min, double max);</CODE>
161 <P>The function <CODE>comedi_find_range</CODE> tries to
162 locate the optimal (smallest) range of a channel <CODE>chan</CODE> belonging to a 
163 <CODE>subdevice</CODE> of the comedi device <CODE>it</CODE>, which includes the data 
164 range between <CODE>min</CODE> and <CODE>max</CODE> in <CODE>units</CODE> with highest
165 precision. If it finds a matching range, 
166 it returns its index.  If no matching range is available, it returns -1.
167 <P>Valid units are:
168 <P>
169 <UL>
170 <LI>UNIT_volt           </LI>
171 <LI>UNIT_mA</LI>
172 <LI>UNIT_none</LI>
173 </UL>
174 <P>Source: <CODE>/lib/range.c</CODE>
175 <P>
176 <P>
177 <P>
178 <H2><A NAME="comedi_errno"></A> <A NAME="ss4.10">4.10 comedi_errno()</A>
179 </H2>
180
181 <P><CODE>int comedi_errno(void);</CODE>
182 <P>
183 <P>When a comedilib function fails, it usually returns -1 or
184 NULL, depending on the return type.  An internal library
185 variable stores an error number, which can be retrieved with
186 <CODE>comedi_errno()</CODE>.  This error number can be
187 converted to a human-readable form by the functions
188 <CODE>
189 <A HREF="#comedi_perror">comedi_perror()</A></CODE>
190 and <CODE>
191 <A HREF="#comedi_strerror">comedi_strerror()</A></CODE>.
192 <P>These functions are intended to mimic the behavior of the
193 standard C library functions <CODE>perror()</CODE>,
194 <CODE>strerror</CODE>, and <CODE>errno()</CODE>.  In particular,
195 comedilib functions sometimes return an error that is generated
196 inside the C library; the comedi error message in this case
197 is the same as the C library.
198 <P>The function <CODE>comedi_errno()</CODE>
199 returns an integer describing the most recent comedilib error.  This
200 integer may be used as the <CODE>errnum</CODE> parameter for
201 <CODE>
202 <A HREF="#comedi_strerror">comedi_strerror()</A></CODE>.
203 <P>Source: <CODE>/lib/error.c</CODE>
204 <P>
205 <P>
206 <P>
207 <H2><A NAME="ss4.11">4.11 comedi_find_subdevice_by_type()</A>
208 </H2>
209
210 <P>
211 <P><CODE>int comedi_find_subdevice_by_type(comedi_t *it,int type,unsigned int
212 start_subdevice);</CODE>
213 <P>The function <CODE>comedi_find_subdevice_by_type</CODE> tries to
214 locate a subdevice belonging to comedi device <CODE>it</CODE>,
215 having type <CODE>type</CODE>, starting with the subdevice
216 <CODE>start_subdevice</CODE>.  If it finds the requested subdevice,
217 it returns its index.  If it does not locate the requested
218 subdevice, it returns -1 and sets the comedi error number to
219 "subdevice not found".  If there is an error, the function
220 returns -1 and sets the appropriate error.
221 <P>For subdevice types, see the manual page for the function
222 <CODE>
223 <A HREF="#comedi_get_subdevice_type">comedi_get_subdevice_type()</A></CODE>.
224 <P>Source: <CODE>/lib/get.c</CODE>
225 <P>
226 <P>
227 <P>
228 <H2><A NAME="comedi_from_phys"></A> <A NAME="ss4.12">4.12 comedi_from_phys()</A>
229 </H2>
230
231 <P>
232 <P><CODE>lsampl_t comedi_from_phys(double data, comedi_range *rng, lsampl_t maxdata);</CODE>
233 <P>Converts data given in physical units (double) into sample values (lsampl_t, between 0 and maxdata). 
234 The parameter <CODE>rng</CODE> represents the conversion information to use, and the parameter <CODE>maxdata</CODE> represents
235 the maximum possible data value for the channel that the data will be written to.
236 <P>Source: <CODE>/lib/range.c</CODE>
237 <P>
238 <P>
239 <P>
240 <H2><A NAME="ss4.13">4.13 comedi_get_board_name()</A>
241 </H2>
242
243 <P>
244 <P><CODE>char *comedi_get_board_name(comedi_t *it);</CODE>
245 <P>The function <CODE>comedi_get_board_name</CODE> returns a pointer
246 to a string containing the name of the device.  This pointer is
247 valid until the comedi descriptor <CODE>it</CODE> is closed.  This
248 function returns NULL if there is an error.
249 <P>Source: <CODE>/lib/get.c</CODE>
250 <P>
251 <P>
252 <P>
253 <H2><A NAME="ss4.14">4.14 comedi_get_driver_name()</A>
254 </H2>
255
256 <P>
257 <P><CODE>char *comedi_get_driver_name(comedi_t *it);</CODE>
258 <P>The function <CODE>comedi_get_driver_name</CODE> returns a pointer
259 to a string containing the name of the driver being used by comedi
260 for the comedi device represented by <CODE>it</CODE>.  This pointer is
261 valid until the comedi descriptor <CODE>it</CODE> is closed.  This
262 function returns NULL if there is an error.
263 <P>Source: <CODE>/lib/get.c</CODE>
264 <P>
265 <P>
266 <P>
267 <H2><A NAME="ss4.15">4.15 comedi_get_maxdata()</A>
268 </H2>
269
270 <P>
271 <P><CODE>lsampl_t comedi_get_maxdata(comedi_t *it,unsigned int subdevice,unsigned int
272 chan);</CODE>
273 <P>The function <CODE>comedi_get_maxdata()</CODE> returns the maximum
274 valid data value for channel <CODE>chan</CODE> of subdevice
275 <CODE>subdevice</CODE> belonging to the comedi device <CODE>it</CODE>
276 This function returns 0 on error.
277 <P>Source: <CODE>/lib/get.c</CODE>
278 <P>
279 <P>
280 <P>
281 <H2><A NAME="ss4.16">4.16 comedi_get_n_channels()</A>
282 </H2>
283
284 <P>
285 <P><CODE>int comedi_get_n_channels(comedi_t *it,unsigned int subdevice);</CODE>
286 <P>The function <CODE>comedi_get_n_channels()</CODE> returns the number
287 of channels of the subdevice belonging to the comedi device <CODE>it</CODE>
288 and having index <CODE>subdevice</CODE>.  This function returns -1 on error.
289 <P>Source: <CODE>/lib/get.c</CODE>
290 <P>
291 <P>
292 <P>
293 <H2><A NAME="ss4.17">4.17 comedi_get_n_ranges()</A>
294 </H2>
295
296 <P>
297 <P><CODE>int comedi_get_n_ranges(comedi_t *it,unsigned int subdevice, unsigned int
298 chan);</CODE>
299 <P>The function <CODE>comedi_get_n_ranges()</CODE> returns the number
300 of ranges of the channel <CODE>chan</CODE> belonging to the <CODE>subdevice</CODE>
301 of the comedi device <CODE>it</CODE>.  This function returns -1 on error.
302 <P>Source: <CODE>/lib/range.c</CODE>
303 <P>
304 <P>
305 <P>
306 <H2><A NAME="ss4.18">4.18 comedi_get_n_subdevices()</A>
307 </H2>
308
309 <P>
310 <P><CODE>int comedi_get_n_subdevices(comedi_t *it);</CODE>
311 <P>The function <CODE>comedi_get_n_subdevices</CODE> returns the
312 number of subdevices associated with the comedi descriptor
313 <CODE>it</CODE>, or -1 if there is an error.
314 <P>Source: <CODE>/lib/get.c</CODE>
315 <P>
316 <P>
317 <P>
318 <H2><A NAME="ss4.19">4.19 comedi_get_range()</A>
319 </H2>
320
321 <P>
322 <P><CODE>comedi_range * comedi_get_range(comedi_t *it,unsigned int subdevice,unsigned int chan,unsigned int
323 range);</CODE>
324 <P>The function <CODE>comedi_get_range</CODE> returns a pointer to a
325 comedi_range structure that contains information that can be used to
326 convert sample values to or from physical units.  The pointer is valid
327 until the comedi device <CODE>it</CODE> is closed.  If there is an
328 error, NULL is returned.
329 <P>Source: <CODE>/lib/get.c</CODE>
330 <P>
331 <P>
332 <H2><A NAME="ss4.20">4.20 comedi_get_rangetype()</A>
333 </H2>
334
335 <P>
336 <P><CODE>int comedi_get_rangetype(comedi_t *it,unsigned int subdevice,unsigned int
337 chan);</CODE>
338 <P>The function <CODE>comedi_get_rangetype()</CODE> returns an integer
339 that represents the number of range specifications available for a
340 particular channel <CODE>chan</CODE> of the subdevice <CODE>subdevice</CODE>, as well as a conversion table to convert sample
341 values to/from physical units. 
342 <P>The macro
343 <CODE>RANGE_LENGTH(rangetype)</CODE>
344 can be used to determine the number of range specifications for a given
345 range type.
346 <P>Source: <CODE>/lib/get.c</CODE>
347 <P>
348 <P>
349 <H2><A NAME="comedi_get_subdevice_type"></A> <A NAME="ss4.21">4.21 comedi_get_subdevice_type()</A>
350 </H2>
351
352 <P>
353 <P><CODE>int comedi_get_subdevice_type(comedi_t *it,unsigned int subdevice);</CODE>
354 <P>The function <CODE>comedi_get_subdevice_type()</CODE> returns an
355 integer describing the type of subdevice that belongs to the comedi
356 device <CODE>it</CODE> and has the index <CODE>subdevice</CODE>.  The
357 function returns -1 is there is an error.
358 <P>Valid subdevice types are:
359 <P>
360 <UL>
361 <LI><CODE>COMEDI_SUBD_UNUSED</CODE>
362 Subdevice has no functionality, i.e., a place-holder.</LI>
363 <LI><CODE>COMEDI_SUBD_AI</CODE> Analog input</LI>
364 <LI><CODE>COMEDI_SUBD_AO</CODE> Analog output</LI>
365 <LI><CODE>COMEDI_SUBD_DI</CODE> Digital input</LI>
366 <LI><CODE>COMEDI_SUBD_DO</CODE> Digital output</LI>
367 <LI><CODE>COMEDI_SUBD_DIO</CODE>
368 Digital input/output.  Channels are configurable as to whether they
369 are inputs or outputs.</LI>
370 <LI><CODE>COMEDI_SUBD_COUNTER</CODE>    Counter</LI>
371 <LI><CODE>COMEDI_SUBD_TIMER</CODE>      Timer</LI>
372 <LI><CODE>COMEDI_SUBD_MEMORY</CODE>
373 Memory, e.g., EEPROM or dual-ported RAM</LI>
374 <LI><CODE>COMEDI_SUBD_CALIB</CODE>
375 Calibration DACs</LI>
376 <LI><CODE>COMEDI_SUBD_PROC</CODE>
377 Processor or DSP</LI>
378 </UL>
379 <P>Source: <CODE>/lib/get.c</CODE>
380 <P>
381 <P>
382 <H2><A NAME="ss4.22">4.22 comedi_get_timer()</A>
383 </H2>
384
385 <P>
386 <P>
387 <BLOCKQUOTE><CODE>
388 <PRE>
389 int comedi_get_timer(comedi_t *it,unsigned int subdev, double freq,unsigned int *trigvar,
390         double *actual_freq);
391 </PRE>
392 </CODE></BLOCKQUOTE>
393 <P><CODE>comedi_get_timer</CODE> returns the type of the timer of the subdevice
394 <CODE>subdev</CODE> of the device <CODE>it</CODE> , 
395 <P>Supported timers are:
396 <P>
397 <UL>
398 <LI>NULL</LI>
399 <LI>dt282x_timer</LI>
400 <LI>dt2814_timer</LI>
401 <LI>atmio_timer</LI>
402 <LI>acl8112_timer</LI>
403 <LI>nanosec_timer</LI>
404 </UL>
405 <P>Source: <CODE>/lib/timer.c</CODE>
406 <P>
407 <P>
408 <H2><A NAME="ss4.23">4.23 comedi_get_version_code()</A>
409 </H2>
410
411 <P>
412 <P><CODE>int comedi_get_version_code(comedi_t *it);</CODE>
413 <P>The function <CODE>comedi_get_version_code()</CODE> returns the
414 version code of the currently running comedi module.  The version
415 code is of the form 0x01072b, which is the version code for
416 version 1.7.43.
417 <P>Source: <CODE>/lib/get.c</CODE>
418 <P>
419 <P>
420 <H2><A NAME="ss4.24">4.24 comedi_loglevel()</A>
421 </H2>
422
423 <P>
424 <P><CODE>int comedi_loglevel(int loglevel);</CODE>
425 <P>This function affects the output of debugging and error messages
426 from comedlib.  By increasing the loglevel, additional debugging
427 information will be printed.  This function returns the previous
428 loglevel.  Some debugging information will only be printed if
429 comedilib was compiled with this debugging information included.
430 The loglevel can also be affected by the environment
431 variable COMEDI_LOGLEVEL.  The meaning of the loglevels is as
432 follows:
433 <P>COMEDILIB_LOGLEVEL=0
434 <P>Comedilib prints nothing.
435 <P>COMEDILIB_LOGLEVEL=1  (default)
436 <P>Comedilib only prints error messages when there is a
437 self-consistency error.
438 <P>COMEDILIB_LOGLEVEL=2
439 <P>Comedilib prints an error message whenever an invalid
440 parameter is passed to comedilib.
441 <P>COMEDILIB_LOGLEVEL=3
442 <P>Comedilib prints an error message whenever an error is generated
443 in the comedilib library or is generated in the C library when
444 called by comedilib.
445 <P>COMEDILIB_LOGLEVEL=4
446 <P>Comedilib prints a lot of debugging messages.
447 <P>
448 <P>Source: <CODE>/lib/error.c</CODE>
449 <P>
450 <P>
451 <H2><A NAME="ss4.25">4.25 comedi_open()</A>
452 </H2>
453
454 <P>
455 <P><CODE>comedi_t *comedi_open(char *fn);</CODE>
456 <P>Opens a comedi device specified by the filename fn.  Returns NULL
457 on error.  Returns a handle that is given as a parameter to other
458 comedilib functions.
459 <P>You are not supposed to have access to the structure comedi_t.
460 <P>Source: <CODE>/lib/comedi.c</CODE>
461 <P>
462 <P>
463 <P>
464 <H2><A NAME="comedi_perror"></A> <A NAME="ss4.26">4.26 comedi_perror()</A>
465 </H2>
466
467 <P>
468 <P><CODE>void comedi_perror(const char *s);</CODE>
469 <P>When a comedilib function fails, it usually returns -1 or
470 NULL, depending on the return type.  An internal library
471 variable stores an error number, which can be retrieved with 
472 <CODE>
473 <A HREF="#comedi_errno">comedi_errno()</A></CODE>.
474 This error number can be
475 converted to a human-readable form by the functions 
476 <CODE>comedi_perror()</CODE>
477 and <CODE>
478 <A HREF="#comedi_strerror">comedi_strerror()</A></CODE>.
479 <P>These functions are intended to mimic the behavior of the
480 standard C library functions <CODE>perror()</CODE>,
481 <CODE>strerror</CODE>, and <CODE>errno()</CODE>.  In particular,
482 comedilib functions sometimes return an error that is generated
483 inside the C library; the comedi error message in this case
484 is the same as the C library.
485 <P>The function <CODE>comedi_perror()</CODE> prints an error
486 message to stderr.  The error message consists of the
487 argument string, a colon, a space, a description of the error
488 condition, and a new line.
489 <P>Source: <CODE>/lib/error.c</CODE>
490 <P>
491 <P>
492 <P>
493 <H2><A NAME="comedi_strerror"></A> <A NAME="ss4.27">4.27 comedi_strerror()</A>
494 </H2>
495
496 <P>
497 <P><CODE>*comedi_strerror(int errnum);</CODE>
498 <P>When a comedilib function fails, it usually returns -1 or
499 NULL, depending on the return type.  An internal library
500 variable stores an error number, which can be retrieved with
501 <CODE>
502 <A HREF="#comedi_errno">comedi_errno()</A></CODE>.  This error number can be
503 converted to a human-readable form by the functions
504 <CODE>
505 <A HREF="#comedi_perror">comedi_perror()</A></CODE>
506 and <CODE>comedi_strerror()</CODE>.
507 <P>These functions are intended to mimic the behavior of the
508 standard C library functions <CODE>perror()</CODE>,
509 <CODE>strerror</CODE>, and <CODE>errno()</CODE>.  In particular,
510 comedilib functions sometimes return an error that is generated
511 inside the C library; the comedi error message in this case
512 is the same as the C library.
513 <P>The function <CODE>comedi_strerror()</CODE> returns a pointer to a
514 character string
515 describing the comedilib error <CODE>errnum</CODE>.  The persistence
516 of the returned pointer is undefined, and should not be trusted
517 after the next comedilib call.  An unrecognized error number will
518 return a pointer to the string "undefined error", or similar.
519 <P>Valid error strings are:
520 <P>
521 <UL>
522 <LI><CODE>"No error"</CODE></LI>
523 <LI><CODE>"Unknown error</CODE></LI>
524 <LI><CODE>"Bad comedi_t structure"</CODE></LI>
525 <LI><CODE>"Invalid subdevice"</CODE></LI>
526 <LI><CODE>"Invalid channel"</CODE></LI>
527 </UL>
528 <P>Source: <CODE>/lib/error.c</CODE>
529 <P>
530 <P>
531 <P>
532 <H2><A NAME="ss4.28">4.28 comedi_sv_init()</A>
533 </H2>
534
535 <P>
536 <P><CODE>int comedi_sv_init(comedi_sv_t *sv,comedi_t *dev,unsigned int subd,
537 unsigned int chan);</CODE>
538 <P>The special functions <CODE>comedi_sv_*()</CODE> are designed to
539 make it easy to accurately measure slowly varying analog inputs.
540 A slowly varying input is one that is effectively constant over the course
541 of approximately 100 A/D conversions.  However, since these
542 conversions can sometimes be pre-empted by scheduling, for most
543 purposes, a slowly varying signal should be effectively constant
544 for greater than 20 ms (the default Linux timeslice).
545 <P>By averaging many A/D conversions of a relatively constant
546 signal, it is possible to get a better measurement of the signal
547 than a single A/D conversion.  In general, the uncertainty of the
548 measurement decreases as the square root of the number of samples.
549 This is limited by the rate that which the signal varies, and
550 ultimately by the spurious free dynamic range of the A/D converter.
551 <P><CODE>comedi_sv_init</CODE> initializes the slow varying comedi structure
552 <CODE>sv</CODE> of the device <CODE>dev</CODE>, the subdevice <CODE>subd</CODE> (analog input) and
553 the channel <CODE>chan</CODE>.
554 The slow varying comedi structure <CODE>sv</CODE> of type <CODE>
555 <A HREF="comedilib_reference-2.html#comedi_sv_t">comedi_sv_t</A></CODE>
556 specifies the signal measurement. Default number of averaged samples is 100.
557 Returns zero on success, -1 on error.
558 <P>Source: <CODE>/lib/sv.c</CODE>
559 <P>
560 <P>
561 <P>
562 <H2><A NAME="ss4.29">4.29 comedi_sv_update()</A>
563 </H2>
564
565 <P>
566 <P><CODE>int comedi_sv_update(comedi_sv_t *sv);</CODE>
567 <P><CODE>comedi_sv_update</CODE> updates the slow varying comedi structure
568 <CODE>sv</CODE>.
569 Returns zero on success, -1 on error.
570 <P>Source: <CODE>/lib/sv.c</CODE>
571 <P>
572 <P>
573 <P>
574 <H2><A NAME="ss4.30">4.30 int comedi_sv_measure()</A>
575 </H2>
576
577 <P>
578 <P><CODE>int comedi_sv_measure(comedi_sv_t *it,double *data);</CODE>
579 <P><CODE>comedi_sv_measure</CODE> measures the slow variing signal. The measurement
580 is specified by the slow varying comedi structure <CODE>sv</CODE>, the result is
581 stored in <CODE>data</CODE>.
582 On success returns the number of samples, -1 on error.
583 <P>Source: <CODE>/lib/sv.c</CODE>
584 <P>
585 <P>
586 <P>
587 <H2><A NAME="comedi_to_phys"></A> <A NAME="ss4.31">4.31 comedi_to_phys()</A>
588 </H2>
589
590 <P>
591 <P><CODE>double comedi_to_phys(lsampl_t data, comedi_range *rng, lsampl_t maxdata);</CODE>
592 <P>Converts data given in sample values (lsampl_t, between 0 and maxdata) into physical units (double). 
593 The parameter <CODE>rng</CODE> represents the conversion information to use, and the parameter <CODE>maxdata</CODE> represents
594 the maximum possible data value for the channel that the data was read.
595 <P>Source: <CODE>/lib/range.c</CODE>
596 <P>
597 <P>
598 <P>
599 <H2><A NAME="ss4.32">4.32 comedi_trigger()</A>
600 </H2>
601
602 <P>
603 <P><CODE>int comedi_trigger(comedi_t *it,comedi_trig *trig);</CODE>
604 <P>The function <CODE>comedi_trigger()</CODE> instructs comedi to
605 perform the command specified by the 
606 <A HREF="comedilib_reference-3.html#comedi_trig_struct">trigger structure</A>
607 <CODE>trig</CODE>.  Results depend on the particular command
608 being issued.  If there is an error, -1 is returned.
609 <P>Complete information about comedi commands is given in the
610 manual page comedi(8).
611 <P>Source: <CODE>/lib/comedi.c</CODE>
612 <P>
613 <P>
614 <P>
615 <P>
616 <P>
617 <P>
618 <P>
619 <P>
620 <P>
621 <P>
622 <P>
623 <P>
624 <P>
625 <P>
626 <H2><A NAME="ss4.33">4.33 comedi_get_timer()</A>
627 </H2>
628
629 <P>
630 <P>
631 <BLOCKQUOTE><CODE>
632 <PRE>
633 int comedi_get_timer(comedi_t *it,unsigned int subdev,double freq,unsigned int *trigvar,
634         double *actual_freq);
635 </PRE>
636 </CODE></BLOCKQUOTE>
637 <P>
638 <P>
639 <P>
640 <P>
641 <HR>
642 Next
643 <A HREF="comedilib_reference-3.html">Previous</A>
644 <A HREF="comedilib_reference.html#toc4">Contents</A>
645 </BODY>
646 </HTML>