Specifications

Comedi
38 / 148
Synopsis
#include <comedilib.h>
int comedi_data_read(comedi_t * device, unsigned int subdevice, unsigned int channel, unsigned int range, unsigned int aref,
lsampl_t * data);
Description
Reads a single sample on the channel specified by the Comedi device device, the subdevice subdevice, and the channel ch-
annel. For the A/D conversion (if appropriate), the device is configured to use range specification range and (if appropriate)
analog reference type aref. Analog reference types that are not supported by the device are silently ignored.
The function comedi_data_read() reads one data value from the specified channel and stores the value in
*
data.
WARNING: comedi_data_read() 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 comedi_data_read_delayed(), or set the input channel at an earlier time with comedi_data_r-
ead_hint().
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 comedi_get_maxdata(). Conversion of data values to physical units can be performed
by the functions comedi_to_phys() (linear conversion) or comedi_to_physical() (non-linear polynomial conversion).
Return value
On success, comedi_data_read() returns 1 (the number of samples read). If there is an error, -1 is returned.
5.4.1.3 comedi_data_read_n
comedi_data_read_n — read multiple samples from channel
Synopsis
#include <comedilib.h>
int comedi_data_read_n(comedi_t * device, unsigned int subdevice, unsigned int channel, unsigned int range, unsigned int aref,
lsampl_t * data, unsigned int n);
Description
Similar to comedi_data_read() except it reads n samples into the array data. The precise timing of the samples is not
hardware controlled.
5.4.1.4 comedi_data_read_delayed
comedi_data_read_delayed — read single sample from channel after delaying for specified settling time
Synopsis
#include <comedilib.h>
int comedi_data_read_delayed(comedi_t * device, unsigned int subdevice, unsigned int channel, unsigned int range, unsigned
int aref, lsampl_t * data, unsigned int nanosec);