1
Function: comedi_close -- close a Comedi device
5
Close a device previously opened by comedi_open().
7
If sucessful, comedi_close returns 0. On failure, -1 is returned.
9
Function: comedi_open -- open a Comedi device
11
Param: const char * filename
13
Open a Comedi device specified by the file filename.
15
If sucessful, comedi_open returns a pointer to a valid comedi_t
16
structure. This structure is transparent; the pointer should not
17
be dereferenced by the application. NULL is returned on failure.
19
Function: comedi_loglevel -- change Comedilib logging properties
23
This function affects the output of debugging and error messages
24
from Comedilib. By increasing the loglevel, additional debugging
25
information will be printed. Error and debugging messages are
26
printed to the stream stderr.
28
The default loglevel can be set by using the environment variable
29
COMEDI_LOGLEVEL. The default loglevel is 1.
31
In order to conserve resources, some debugging information is
32
disabled by default when Comedilib is compiled.
34
The meaning of the loglevels is as follows:
36
COMEDI_LOGLEVEL=0 Comedilib prints nothing.
38
COMEDI_LOGLEVEL=1 (default) Comedilib prints error messages when
39
there is a self-consistency error (i.e., an internal bug.)
41
COMEDI_LOGLEVEL=2 Comedilib prints an error message when an invalid
44
COMEDI_LOGLEVEL=3 Comedilib prints an error message whenever an
45
error is generated in the Comedilib library or in the C library,
46
when called by Comedilib.
48
COMEDI_LOGLEVEL=4 Comedilib prints a lot of junk.
50
This function returns the previous loglevel.
52
Function: comedi_perror -- print a Comedilib error message
56
When a Comedilib function fails, it usually returns -1 or
57
NULL, depending on the return type. An internal library
58
variable stores an error number, which can be retrieved with
59
comedi_errno(). This error number can be converted to a
60
human-readable form by the functions comedi_perror()
61
and comedi_strerror().
63
These functions are intended to mimic the behavior of the
64
standard C library functions perror(), strerror(), and errno.
65
In particular, Comedilib functions sometimes return an error
66
that is generated inside the C library; the comedi error
67
message in this case is the same as the C library.
69
The function comedi_perror() prints an error message to stderr.
70
The error message consists of the argument string, a colon, a
71
space, a description of the error condition, and a new line.
73
Function: comedi_strerror -- return string describing Comedilib error code
77
When a Comedilib function fails, it usually returns -1 or
78
NULL, depending on the return type. An internal library
79
variable stores an error number, which can be retrieved with
80
comedi_errno(). This error number can be converted to a
81
human-readable form by the functions comedi_perror()
82
and comedi_strerror().
84
These functions are intended to mimic the behavior of the
85
standard C library functions perror(), strerror(), and errno.
86
In particular, Comedilib functions sometimes return an error
87
that is generated inside the C library; the comedi error
88
message in this case is the same as the C library.
90
The function comedi_strerror() returns a pointer to a
92
describing the Comedilib error errnum. The persistence
93
of the returned pointer is undefined, and should not be trusted
94
after the next Comedilib call. An unrecognized error number will
95
return a pointer to the string "undefined error", or similar.
97
Function: comedi_errno -- number of last Comedilib error
101
When a Comedilib function fails, it usually returns -1 or
102
NULL, depending on the return type. An internal library
103
variable stores an error number, which can be retrieved with
104
comedi_errno(). This error number can be converted to a
105
human-readable form by the functions comedi_perror()
106
and comedi_strerror().
108
These functions are intended to mimic the behavior of the
109
standard C library functions perror(), strerror(), and errno.
110
In particular, Comedilib functions sometimes return an error
111
that is generated inside the C library; the comedi error
112
message in this case is the same as the C library.
114
The function comedi_errno() returns an integer describing
115
the most recent comedilib error. This integer may be used
116
as the errnum parameter for comedi_strerror().
118
Note that comedi_errno() is deliberately different than the
119
variable errno. This is to overcome difficulties in making
122
Function: comedi_fileno -- integer descriptor of Comedilib device
124
Param: comedi_t * device
126
The function comedi_fileno returns the integer descriptor for
127
the device dev. This descriptor can then be used as the
128
file descriptor parameter of read(), write(), etc.
129
This function is intended to mimic the standard C library
130
function fileno(). If dev is an invalid comedi_t
131
pointer, the function returns -1 and sets the appropriate
132
Comedilib error value.
134
Function: comedi_get_n_subdevices -- number of subdevices
136
Param: comedi_t * device
138
Returns the number of subdevices belonging to the Comedi
139
device referenced by the parameter device.
141
Function: comedi_get_version_code -- Comedi version code
143
Param: comedi_t * device
145
Returns the Comedi kernel module version code. A valid Comedi
146
device referenced by the parameter device is necessary to
147
communicate with the kernel module. On error, -1 is returned.
149
The version code is encoded as a bitfield of three 8-bit
150
numbers. For example, 0x00073d is the version code for
153
This function is of limited usefulness. A typical
154
mis-application of this function is to use it to determine
155
if a certain feature is supported. If the application needs
156
to know of the existence of a particular feature, an existence
157
test function should be written and put in the Comedilib source.
159
Function: comedi_get_driver_name -- Comedi driver name
161
Param: comedi_t * device
163
The function comedi_get_driver_name returns a pointer
164
to a string containing the name of the driver being used by comedi
165
for the comedi device represented by device. This pointer is
166
valid until the device is closed. This function returns NULL
167
if there is an error.
169
Function: comedi_get_board_name -- Comedi device name
171
Param: comedi_t * device
173
The function comedi_get_board_name returns a pointer
174
to a string containing the name of the device. This pointer is
175
valid until the comedi descriptor it is closed. This
176
function returns NULL if there is an error.
178
Function: comedi_get_subdevice_type -- type of subdevice
180
Param: comedi_t * device
181
Param: unsigned int subdevice
183
The function comedi_get_subdevice_type() returns an
184
integer describing the type of subdevice that belongs to the comedi
185
device device and has the index subdevice. The
186
function returns -1 if there is an error.
188
XXX Subdevice type table
190
Function: comedi_find_subdevice_by_type -- search for subdevice type
192
Param: comedi_t * device
194
Param: unsigned int start_subdevice
196
The function comedi_find_subdevice_by_type() tries to
197
locate a subdevice belonging to comedi device device,
198
having type type, starting with the subdevice
199
start_subdevice. If it finds a subdevice with the requested
200
type, it returns its index. If it does not locate the requested
201
subdevice, it returns -1 and sets the Comedilib error number to
202
XXX "subdevice not found". If there is an error, the function
203
returns -1 and sets the appropriate error.
205
Function: comedi_get_read_subdevice -- find streaming input subdevice
207
Param: comedi_t * device
209
The function comedi_get_read_subdevice() returns the subdevice
210
that allows streaming input for device dev. If no subdevice
211
supports streaming input, -1 is returned and the Comedilib error
212
number is set to XXX "subdevice not found".
214
Function: comedi_get_write_subdevice -- find streaming output subdevice
216
Param: comedi_t * device
218
The function comedi_get_write_subdevice() returns the subdevice
219
that allows streaming output for device dev. If no subdevice
220
supports streaming output, -1 is returned and the Comedilib error
221
number is set to XXX "subdevice not found".
223
Function: comedi_get_subdevice_flags -- properties of subdevice
225
Param: comedi_t * device
226
Param: unsigned int subdevice
228
This function returns a bitfield describing the capabilities of
229
the specified subdevice. If there is an error, -1 is returned,
230
and the Comedilib error value is set.
234
Function: comedi_get_n_channels -- number of subdevice channels
236
Param: comedi_t * device
237
Param: unsigned int subdevice
239
The function comedi_get_n_channels() returns the number
240
of channels of the subdevice belonging to the comedi device device
241
and having index subdevice. This function returns -1 on error and
242
the Comedilib error value is set.
244
Function: comedi_range_is_chan_specific -- range information depends on channel
246
Param: comedi_t * device
247
Param: unsigned int subdevice
249
If each channel of the specified subdevice has different range
250
information, this function returns 1. Otherwise, this function
251
returns 0. On error, this function returns -1.
253
Function: comedi_maxdata_is_chan_specific -- maximum sample depends on channel
255
Param: comedi_t * device
256
Param: unsigned int subdevice
258
If each channel of the specified subdevice has different maximum
259
sample values, this function returns 1. Otherwise, this function
260
returns 0. On error, this function returns -1.
262
Function: comedi_get_maxdata -- maximum sample of channel
264
Param: comedi_t * device
265
Param: unsigned int subdevice
266
Param: unsigned int channel
268
The function comedi_get_maxdata() returns the maximum
269
valid data value for channel chan of subdevice
270
subdevice belonging to the comedi device device
271
This function returns 0 on error.
273
Function: comedi_get_n_ranges -- number of ranges of channel
275
Param: comedi_t * device
276
Param: unsigned int subdevice
277
Param: unsigned int channel
279
The function comedi_get_n_ranges() returns the number
280
of ranges of the channel chan belonging to the subdevice
281
of the comedi device device. This function returns -1 on error.
283
Function: comedi_get_range -- range information of channel
284
Retval: comedi_range *
285
Param: comedi_t * device
286
Param: unsigned int subdevice
287
Param: unsigned int channel
288
Param: unsigned int range
290
The function comedi_get_range() returns a pointer to a
291
comedi_range structure that contains information that can be used to
292
convert sample values to or from physical units. The pointer is valid
293
until the Comedi device device is closed. If there is an
294
error, NULL is returned.
296
Function: comedi_find_range -- search for range
298
Param: comedi_t * device
299
Param: unsigned int subdevice
300
Param: unsigned int channel
301
Param: unsigned int unit
305
The function comedi_find_range() tries to
306
locate the optimal (smallest) range for the channel chan
307
belonging to a subdevice of the comedi device device,
308
that includes both min and max in units.
309
If a matching range is found, the index of the matching range is
310
returned. If no matching range is available, the function returns
313
Function: comedi_get_buffer_size -- streaming buffer size of subdevice
315
Param: comedi_t * device
316
Param: unsigned int subdevice
318
The function comedi_get_buffer_size() returns the size (in bytes)
319
of the streaming buffer for the subdevice specified by device and
320
subdevice. On error, -1 is returned.
322
Function: comedi_get_max_buffer_size -- maximum streaming buffer size
324
Param: comedi_t * device
325
Param: unsigned int subdevice
327
The function comedi_get_max_buffer_size() returns the maximum
328
allowable size (in bytes) of the streaming buffer for the subdevice
329
specified by device and subdevice. Changing the maximum buffer
330
size requires appropriate privileges. On error, -1 is returned.
332
Function: comedi_set_buffer_size -- streaming buffer size of subdevice
334
Param: comedi_t * device
335
Param: unsigned int subdevice
336
Param: unsigned int size
338
The function comedi_set_buffer_size() changes the size of the
339
streaming buffer for the subdevice specified by device and subdevice.
340
The parameter size must be a multiple of the virtual memory page
343
The virtual memory page size can be determined using
344
sysconf(_SC_PAGE_SIZE).
346
Function: comedi_trigger -- perform streaming input/output (deprecated)
348
Param: comedi_t * device
349
Param: comedi_trig * trig
352
The function comedi_trigger() instructs Comedi to
353
perform the command specified by the trigger structure trig.
354
The return value depends on
355
the particular trig being issued. If there is an
356
error, -1 is returned.
358
Function: comedi_do_insnlist -- perform multiple instructions
360
Param: comedi_t * device
361
Param: comedi_insnlist * list
363
The function comedi_do_insnlist() performs multiple Comedi
364
instructions as part of one system call. In addition, Comedi
365
attempts to perform the instructions atomically, that is, on
366
standard Linux kernels, no process preemption should occur
367
during the instructions. However, the process may be preempted
368
before or after the group of instructions.
370
This function can be used to avoid the overhead of multiple
371
system calls, or to ensure that multiple instructions occur
372
without significant delay between them.
374
Preemption may occur if any of the instructions or the data
375
arrays of any of the instructions exist in non-resident or
378
The function comedi_do_insnlist() returns the number of
379
sucessfully completed instructions. Error information for
380
the unsucessful instruction is not available. If there is
381
an error before the first instruction can be executed, -1
384
Function: comedi_do_insn -- perform instruction
386
Param: comedi_t * device
387
Param: comedi_insn * instruction
389
The function comedi_do_insn() performs a single instruction.
390
If sucessful, comedi_do_insn() returns the number of samples
391
measured, which may be less than the number of requested
392
samples. Comedi limits the number of requested samples in
393
order to enforce fairness among processes. If there is an
394
error, -1 is returned.
396
Function: comedi_lock -- subdevice reservation
398
Param: comedi_t * device
399
Param: unsigned int subdevice
401
The function comedi_lock() reserves a subdevice for use by the
402
current process. While the lock is held, no other process is
403
allowed to read, write, or configure that subdevice, although
404
other processes can read information about the subdevice. The
405
lock is released when comedi_unlock() is called, or the device
406
is closed. If sucessful, 0 is returned. If there is an error,
409
Function: comedi_unlock -- subdevice reservation
411
Param: comedi_t * device
412
Param: unsigned int subdevice
414
The function comedi_unlock() released a subdevice lock acquired
415
by comedi_lock(). If sucessful, 0 is returned, otherwise -1.
417
Function: comedi_to_phys -- convert sample to physical units
420
Param: comedi_range * range
421
Param: lsampl_t maxdata
423
Converts data given in sample values (lsampl_t, between 0 and
424
maxdata) into physical units (double). The parameter range
425
represents the conversion information to use, and the parameter
426
maxdata represents the maximum possible data value for the
427
channel that the data was read.
429
Conversion of endpoint sample values, that is, sample values
430
equal to 0 or maxdata, is affected by the Comedilib out-of-range
431
behavior. If the out-of-range behavior is set to COMEDI_OOR_NAN,
432
endpoint values are converted to NAN. If the out-of-range
433
behavior is set to COMEDI_OOR_NUMBER, the endpoint values are
434
converted similarly to other values.
436
If there is an error, NAN is returned.
438
Function: comedi_from_phys -- convert physical units to sample
441
Param: comedi_range * range
442
Param: lsampl_t maxdata
444
Converts data given in physical units (data) into sample values
445
(lsampl_t, between 0 and maxdata). The parameter rng
446
represents the conversion information to use, and the parameter
447
maxdata represents the maximum possible data value for the
448
channel that the data will be written to.
450
Conversion is not affected by out-of-range behavior. Out-of-range
451
data parameters are silently truncated to the range 0 to maxdata.
453
Function: comedi_data_read -- read single sample from channel
455
Param: comedi_t * device
456
Param: unsigned int subdevice
457
Param: unsigned int channel
458
Param: unsigned int range
459
Param: unsigned int aref
460
Param: lsampl_t * data
462
Reads a single sample on the channel specified by the Comedi
463
device device, the subdevice subdevice, and the channel channel.
464
For the A/D conversion (if appropriate),
465
the device is configured to use range specification
466
range and (if appropriate) analog reference type
467
aref. Analog reference types that are not supported
468
by the device are silently ignored.
470
The function comedi_data_read() reads one data value from
471
the specified channel and places the data value in the
472
location pointed to by data.
474
WARNING: comedi_data_read() does not do any pausing to
475
allow multiplexed analog inputs to settle before
476
performing an analog to digital conversion. If you are
477
switching between different channels and need to allow
478
your analog input to settle for an accurate reading,
479
use comedi_data_read_delayed(), or set the
480
input channel at an earlier time with
481
comedi_data_read_hint().
483
On sucess, comedi_data_read() returns 1 (the number of samples
484
read). If there is an error, -1 is returned.
486
Data values returned by this function are unsigned integers
487
less than or equal to the maximum sample value of the channel,
488
which can be determined using the function comedi_get_maxdata().
489
Conversion of data values to physical units can be performed
490
by the function comedi_to_phys().
492
Function: comedi_data_read_delayed -- read single sample from channel after delaying for specified settling time
494
Param: comedi_t * device
495
Param: unsigned int subdevice
496
Param: unsigned int channel
497
Param: unsigned int range
498
Param: unsigned int aref
499
Param: lsampl_t * data
500
Param: unsigned int nanosec
502
Similar to comedi_data_read() except it will wait for the
503
specified number of nanoseconds between setting the input
504
channel and taking a sample. For analog inputs, most
506
analog to digital converter which is multiplexed to be
507
able to read multiple channels. If the input is not allowed
508
to settle after the multiplexer switches channels, the
509
reading will be inaccurate. This function is useful
510
for allowing a multiplexed analog input to settle
511
when switching channels.
513
Although the settling time is specified in nanoseconds, the
514
actual settling time will be rounded up to the nearest
517
Function: comedi_data_read_hint -- tell driver which channel/range/aref you are going to read from next
519
Param: comedi_t * device
520
Param: unsigned int subdevice
521
Param: unsigned int channel
522
Param: unsigned int range
523
Param: unsigned int aref
525
Used to prepare an analog input for a subsequent call to
526
comedi_data_read(). It is not necessary to use this
527
function, but it can be useful for eliminating inaccuaracies
528
caused by insufficient settling times when switching the
530
or gain on an analog input. This function sets an analog input
531
to the channel, range, and aref specified but does not
532
perform an actual analog to digital conversion.
534
Alternatively, one can simply use comedi_data_read_delayed(),
536
input, pauses to allow settling, then performs a conversion.
538
Function: comedi_data_write -- write single sample to channel
540
Param: comedi_t * device
541
Param: unsigned int subdevice
542
Param: unsigned int channel
543
Param: unsigned int range
544
Param: unsigned int aref
547
Writes a single sample on the channel that is specified by the
548
Comedi device device, the subdevice subdevice, and the channel
549
channel. If appropriate, the device is configured to use range
550
specification range and analog reference type aref. Analog
551
reference types that are not supported by the device are
554
The function comedi_data_write() writes the data value specified
555
by the parameter data to the specified channel.
557
On sucess, comedi_data_write() returns 1 (the number of samples
558
written). If there is an error, -1 is returned.
560
Function: comedi_dio_config -- change input/output properties of channel
562
Param: comedi_t * device
563
Param: unsigned int subdevice
564
Param: unsigned int channel
565
Param: unsigned int direction
567
The function comedi_dio_config() configures individual channels
568
in a digital I/O subdevice to be either input or output, depending
569
on the value of parameter direction. Valid directions are
570
COMEDI_INPUT or COMEDI_OUTPUT.
572
Depending on the capabilities of the hardware device, multiple
573
channels may be grouped together to determine direction. In this
574
case, a single call to comedi_dio_config() for any channel in the
575
group will affect the entire group.
577
If sucessful, 1 is returned, otherwise -1.
579
Function: comedi_dio_read -- read single bit from digital channel
581
Param: comedi_t * device
582
Param: unsigned int subdevice
583
Param: unsigned int channel
584
Param: unsigned int * bit
586
The function reads the channel channel belonging to the
587
subdevice subdevice of device device. The data value that is
588
read is stored in the location pointed to by bit. This function
589
is equivalent to comedi_data_read(device,subdevice,channel,0,0,bit).
590
This function does not require a digital subdevice or a subdevice
591
with a maximum data value of 1 to work properly.
593
Return values and errors are the same as comedi_data_read().
595
Function: comedi_dio_write -- write single bit to digital channel
597
Param: comedi_t * device
598
Param: unsigned int subdevice
599
Param: unsigned int channel
600
Param: unsigned int bit
602
The function writes the value bit to the channel channel belonging
603
to the subdevice subdevice of device device. This function
604
is equivalent to comedi_data_write(device,subdevice,channel,0,0,bit).
605
This function does not require a digital subdevice or a subdevice
606
with a maximum data value of 1 to work properly.
608
Return values and errors are the same as comedi_data_write().
610
Function: comedi_dio_bitfield -- read/write multiple digital channels
612
Param: comedi_t * device
613
Param: unsigned int subdevice
614
Param: unsigned int write_mask
615
Param: unsigned int * bits
617
The function comedi_dio_bitfield() allows multiple channels to
618
be read simultaneously from a digital input or digital I/O device.
619
The parameter write_mask and the value pointed to by bits
620
are interpreted as bit fields, with the least significant bit
621
representing channel 0. For each bit in write_mask that is
622
set to 1, the cooresponding bit in *bits is written to the digital
623
output channel. After writing all the output channels, each
624
channel is read, and the result placed in the approprate bits in
625
*bits. The result of reading an output channel is undefined.
626
It is not possible to access channels greater than 31 using this
629
Function: comedi_sv_init -- slowly-varying inputs
631
Param: comedi_sv_t * sv
632
Param: comedi_t * device
633
Param: unsigned int subdevice
634
Param: unsigned int channel
637
The function comedi_sv_init() initializes the slow varying Comedi
638
structure sv to use the device device, the analog input subdevice
639
subdevice, and the channel channel. The slow varying Comedi
640
structure is used by comedi_sv_measure() to accurately measure
641
an analog input by averaging over many samples. The default
642
number of samples is 100. This function returns 0 on success,
645
Function: comedi_sv_update -- slowly-varying inputs
647
Param: comedi_sv_t * sv
650
The function comedi_sv_update() updates internal parameters of
651
the slowly varying Comedi structure sv.
653
Function: comedi_sv_measure -- slowly-varying inputs
655
Param: comedi_sv_t * sv
659
The function comedi_sv_measure() uses the slowly varying Comedi
660
structure sv to measure a slowly varying signal. If sucessful,
661
the result (in physical units) is stored in the location pointed
662
to by data, and the number of samples is returned. On error, -1
665
Function: comedi_get_cmd_src_mask -- streaming input/output capabilities
667
Param: comedi_t * device
668
Param: unsigned int subdevice
669
Param: comedi_cmd * command
671
The command capabilities of the subdevice indicated by the parameters
672
device and subdevice are probed, and the results placed in the
673
command structure pointed to by the parameter command. The trigger
674
source elements of the command structure are set to the logical OR
675
value of possible trigger sources. Other elements in the structure
676
are undefined. If sucessful, 0 is returned, otherwise -1.
678
Function: comedi_get_cmd_generic_timed -- streaming input/output capabilities
680
Param: comedi_t * device
681
Param: unsigned int subdevice
682
Param: comedi_cmd * command
683
Param: unsigned int period_ns
685
The command capabilities of the subdevice indicated by the parameters
686
device and subdevice are probed, and the results placed in the
687
command structure pointed to by the parameter command. The command
688
structure pointed to by the parameter command is modified to be a
689
valid command that can be used as a parameter to comedi_command().
690
The command measures samples at a rate that corresponds to the
691
period period_ns. The rate is adjusted to a rate that the device
692
can handle. If sucessful, 0 is returned, otherwise -1.
694
Function: comedi_cancel -- stop streaming input/outpu in progress
696
Param: comedi_t * device
697
Param: unsigned int subdevice
699
The function comedi_cancel() can be used to stop a Comedi command
700
previously started by comedi_command() that is still in progress
701
on the subdevice indicated by the parameters device and subdevice.
702
This may not return the subdevice to a ready state, since there may
703
be samples in the buffer that need to be read.
705
If sucessful, 0 is returned, otherwise -1.
707
Function: comedi_command -- start streaming input/output
709
Param: comedi_t * device
710
Param: comedi_cmd * command
712
The function comedi_command() starts streaming input or output. The
713
command structure pointed to by the parameter command specifies the
714
acquisition. For input subdevices, sample values are read using the
715
function read(). For output subdevices, sample vlaues are written
716
using the function write().
718
If sucessful, 0 is returned, otherwise -1.
720
Function: comedi_command_test -- test streaming input/output configuration
722
Param: comedi_t * device
723
Param: comedi_cmd * command
725
The function comedi_command_test() tests the command structure pointed
726
to by the parameter command and returns an integer describing the
727
testing stages that were sucessfully passed. In addition, if elements
728
of the command structure are invalid, they may be modified. Source
729
elements are modified to remove invalid source triggers. Argument
730
elements are adjusted or rounded to the nearest valid value.
734
Function: comedi_poll -- force updating of streaming buffer
736
Param: comedi_t * device
737
Param: unsigned int subdevice
739
The function comedi_poll() is used on a subdevice that has a
740
Comedi command in progress in order to update the streaming buffer.
741
If supported by the driver, all available samples are copied to
742
the streaming buffer. These samples may be pending in DMA buffers
743
or device FIFOs. If sucessful, the number of additional bytes
744
available is returned. If there is an error, -1 is returned.
746
Function: comedi_set_max_buffer_size -- streaming buffer size of subdevice
748
Param: comedi_t * device
749
Param: unsigned int subdevice
750
Param: unsigned int max_size
752
The function comedi_set_max_buffer_size() changes the maximum
753
allowable size (in bytes) of the streaming buffer for the subdevice
754
specified by device and subdevice. Changing the maximum buffer
755
size requires appropriate privileges. If sucessful, the old buffer
756
size is returned. On error, -1 is returned.
758
Function: comedi_get_buffer_contents -- streaming buffer status
760
Param: comedi_t * device
761
Param: unsigned int subdevice
763
The function comedi_get_buffer_contents() is used on a subdevice
764
that has a Comedi command in progress. The number of bytes that
765
are available in the streaming buffer is returned. If there is
766
an error, -1 is returned.
768
Function: comedi_mark_buffer_read -- streaming buffer status
770
Param: comedi_t * device
771
Param: unsigned int subdevice
772
Param: unsigned int num_bytes
774
The function comedi_mark_buffer_read() is used on a subdevice
775
that has a Comedi command in progress. This function can be
776
used to indicate that the next num_bytes bytes in the buffer
777
are no longer needed and may be discarded.
778
If there is an error, -1 is returned.
780
Function: comedi_get_buffer_offset -- streaming buffer status
782
Param: comedi_t * device
783
Param: unsigned int subdevice
785
The function comedi_get_buffer_offset() is used on a subdevice
786
that has a Comedi command in progress. This function returns
787
the offset in bytes of the read pointer in the streaming buffer.
788
This offset is only useful for memory mapped buffers.
789
If there is an error, -1 is returned.
791
Function: comedi_get_timer -- timer information (deprecated)
793
Param: comedi_t * device
794
Param: unsigned int subdevice
795
Param: double frequency
796
Param: unsigned int * trigvar
797
Param: double * actual_frequency
800
The function comedi_get_timer converts the frequency frequency
801
to a number suitable to send to the driver in a comedi_trig
802
structure. This function remains for compatibility with very
803
old versions of Comedi, that converted sampling rates to timer
804
values in the libary. This conversion is now done in the kernel,
805
and every device has the timer type nanosec_timer, indicating
806
that timer values are simply a time specified in nanoseconds.
808
Function: comedi_timed_1chan -- streaming input (deprecated)
810
Param: comedi_t * device
811
Param: unsigned int subdevice
812
Param: unsigned int channel
813
Param: unsigned int range
814
Param: unsigned int aref
815
Param: double frequency
816
Param: unsigned int num_samples
822
Function: comedi_set_global_oor_behavior -- out-of-range behavior
824
Param: enum comedi_oor_behavior behavior
827
This function changes the Comedilib out-of-range behavior.
828
This currently affects the behavior of comedi_to_phys() when
829
converting endpoint sample values, that is, sample values
830
equal to 0 or maxdata. If the out-of-range behavior is set to
831
COMEDI_OOR_NAN, endpoint values are converted to NAN. If the
832
out-of-range behavior is set to COMEDI_OOR_NUMBER, the endpoint
833
values are converted similarly to other values.
835
The previous out-of-range behavior is returned.
837
Function: comedi_apply_calibration -- set calibration from file
839
Param: comedi_t *device
840
Param: unsigned int subdevice
841
Param: unsigned int channel
842
Param: unsigned int range
843
Param: unsigned int aref
844
Param: const char *file_path
847
This function sets the calibration of the specified subdevice
848
so that it is in proper calibration when using the specified
849
channel, range and aref. Depending on the hardware, the
850
calibration settings used may or may not depend on the channel,
851
range, or aref. The file_path parameter can be used
852
to specify the file which contains the calibration information.
853
If <parameter>file_path</parameter> is NULL, then comedilib
855
file location. The calibration information used by this function
856
is generated by the comedi_calibrate program (see its man page).
858
The functions comedi_parse_calibration_file(),
859
comedi_apply_parsed_calibration(), and comedi_cleanup_calibration()
860
provide the same functionality at a slightly lower level.
862
Zero on success, a negative number on failure.
864
Function: comedi_apply_parsed_calibration -- set calibration from memory
866
Param: comedi_t * device
867
Param: unsigned int subdevice
868
Param: unsigned int channel
869
Param: unsigned int range
870
Param: unsigned int aref
871
Param: const comedi_calibration_t *calibration
874
This function is similar to comedi_apply_calibration()
875
except the calibration information is read from memory
876
instead of a file. This function can be more
877
efficient than comedi_apply_calibration() since the
878
calibration file does not need to be reparsed with
879
every call. The <parameter>calibration</parameter> is
880
obtained by a call to comedi_parse_calibration_file().
883
Zero on success, a negative number on failure.
885
Function: comedi_cleanup_calibration_file -- free calibration resources
887
Param: comedi_calibration_t *calibration
890
This function frees the resources associated with a
891
<parameter>calibration</parameter> obtained from
892
comedi_parse_calibration_file(). <parameter>calibration</parameter>
893
can not be used again after calling this function.
895
Function: comedi_get_default_calibration_path -- get default calibration file path
900
This function returns a string containing a default calibration file
901
path appropriate for <parameter>dev</parameter>. Memory for the
902
string is allocated by the function, and should be freed when
903
the string is no longer needed.
905
A string which contains a file path useable by
906
comedi_parse_calibration_file(). On error, NULL is returned.
908
Function: comedi_parse_calibration_file -- set calibration
909
Retval: comedi_calibration_t*
910
Param: const char *file_path
913
This function parses a calibration file (produced by the
914
comedi_calibrate program) and returns a pointer to a
915
comedi_calibration_t which can be passed to the
916
comedi_apply_parsed_calibration() function. When you are
917
finished using the comedi_calibration_t, you should
918
call comedi_cleanup_calibration() to free the resources
919
associated with the comedi_calibration_t.
921
The comedi_get_default_calibration_path() function may
922
be useful in conjunction with this function.
924
A pointer to parsed calibration information on success, or NULL on failure.