Name

comedi_lsampl_to_phys — Convert 32-bit samples to physical units

Synopsis

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

Description

Converts n 32-bit sample values (lsampl_t, between 0 and maxdata) separated by src_stride bytes from the buffer pointed to by src to physical unit values (double) 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 was read. The mapping between raw data values and physical units is linear and assumes that the converter has ideal characteristics.

Conversion of endpoint sample values, that is, sample values equal to 0 or maxdata, is affected by the Comedilib out-of-range behavior (see function comedi_set_global_oor_behavior). If the out-of-range behavior is set to COMEDI_OOR_NAN, endpoint values are converted to NAN. If the out-of-range behavior is set to COMEDI_OOR_NUMBER, the endpoint values are converted similarly to other values.

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(lsampl_t) and sizeof(double) respectively).

Return value

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