Name

comedi_sampl_from_phys — convert physical units to 16-bit samples

Synopsis

#include <comedilib.h>
int comedi_sampl_from_phys(sampl_t * dest,
 int dest_stride,
 const double * src,
 int src_stride,
 const comedi_range * range,
 lsampl_t maxdata,
 int n);
 

Description

Converts n physical unit values (double) separated by src_stride bytes from the buffer pointed to by src to 16-bit sample values (sampl_t, between 0 and maxdata) separated by dest_stride bytes into the buffer pointed to by dest. The parameter range represents the conversion information to use, and the parameter maxdata represents the maximum possible data value for the channel that the data will be written to. The mapping between physical units and raw data values is linear and assumes that the converter has ideal characteristics.

Conversion is not affected by out-of-range behavior. Out-of-range physical unit values are silently truncated to the range 0 to maxdata.

Note that the stride values are in bytes, so the parameters dest_stride and src_stride should be multiples of the element sizes of their respective dest and src buffers (sizeof(double) and sizeof(sampl_t) respectively).

Return value

The function returns the number of out-of-range values encountered during the conversion.