Xenomai API  2.6.5
Range / conversion API
Collaboration diagram for Range / conversion API:

Functions

int a4l_sizeof_chan (a4l_chinfo_t *chan)
 Get the size in memory of an acquired element. More...
 
int a4l_sizeof_subd (a4l_sbinfo_t *subd)
 Get the size in memory of a digital acquired element. More...
 
int a4l_find_range (a4l_desc_t *dsc, unsigned int idx_subd, unsigned int idx_chan, unsigned long unit, double min, double max, a4l_rnginfo_t **rng)
 Find the must suitable range. More...
 
int a4l_rawtoul (a4l_chinfo_t *chan, unsigned long *dst, void *src, int cnt)
 Unpack raw data (from the driver) into unsigned long values. More...
 
int a4l_rawtof (a4l_chinfo_t *chan, a4l_rnginfo_t *rng, float *dst, void *src, int cnt)
 Convert raw data (from the driver) to float-typed samples. More...
 
int a4l_rawtod (a4l_chinfo_t *chan, a4l_rnginfo_t *rng, double *dst, void *src, int cnt)
 Convert raw data (from the driver) to double-typed samples. More...
 
int a4l_ultoraw (a4l_chinfo_t *chan, void *dst, unsigned long *src, int cnt)
 Pack unsigned long values into raw data (for the driver) More...
 
int a4l_ftoraw (a4l_chinfo_t *chan, a4l_rnginfo_t *rng, void *dst, float *src, int cnt)
 Convert float-typed samples to raw data (for the driver) More...
 
int a4l_dtoraw (a4l_chinfo_t *chan, a4l_rnginfo_t *rng, void *dst, double *src, int cnt)
 Convert double-typed samples to raw data (for the driver) More...
 

Detailed Description

Function Documentation

int a4l_dtoraw ( a4l_chinfo_t *  chan,
a4l_rnginfo_t *  rng,
void *  dst,
double *  src,
int  cnt 
)

Convert double-typed samples to raw data (for the driver)

Parameters
[in]chanChannel descriptor
[in]rngRange descriptor
[out]dstOuput buffer
[in]srcInput buffer
[in]cntCount of conversion to perform
Returns
the count of conversion performed, otherwise a negative error code:
  • -EINVAL is returned if some argument is missing or wrong; chan, rng and the pointers should be checked; check also the kernel log ("dmesg"); WARNING: a4l_fill_desc() should be called before using a4l_dtoraw()

References A4L_RNG_FACTOR, and a4l_sizeof_chan().

int a4l_find_range ( a4l_desc_t dsc,
unsigned int  idx_subd,
unsigned int  idx_chan,
unsigned long  unit,
double  min,
double  max,
a4l_rnginfo_t **  rng 
)

Find the must suitable range.

Parameters
[in]dscDevice descriptor filled by a4l_open() and a4l_fill_desc()
[in]idx_subdIndex of the concerned subdevice
[in]idx_chanIndex of the concerned channel
[in]unitUnit type used in the range
[in]minMinimal limit value
[in]maxMaximal limit value
[out]rngFound range
Returns
The index of the most suitable range on success. Otherwise:
  • -ENOENT is returned if a suitable range is not found.
  • -EINVAL is returned if some argument is missing or wrong; idx_subd, idx_chan and the dsc pointer should be checked; check also the kernel log ("dmesg"); WARNING: a4l_fill_desc() should be called before using a4l_find_range()

References a4l_get_chinfo(), a4l_get_rnginfo(), A4L_RNG_FACTOR, A4L_RNG_UNIT, and a4l_descriptor::magic.

int a4l_ftoraw ( a4l_chinfo_t *  chan,
a4l_rnginfo_t *  rng,
void *  dst,
float *  src,
int  cnt 
)

Convert float-typed samples to raw data (for the driver)

Parameters
[in]chanChannel descriptor
[in]rngRange descriptor
[out]dstOuput buffer
[in]srcInput buffer
[in]cntCount of conversion to perform
Returns
the count of conversion performed, otherwise a negative error code:
  • -EINVAL is returned if some argument is missing or wrong; chan, rng and the pointers should be checked; check also the kernel log ("dmesg"); WARNING: a4l_fill_desc() should be called before using a4l_ftoraw()

References A4L_RNG_FACTOR, and a4l_sizeof_chan().

int a4l_rawtod ( a4l_chinfo_t *  chan,
a4l_rnginfo_t *  rng,
double *  dst,
void *  src,
int  cnt 
)

Convert raw data (from the driver) to double-typed samples.

Parameters
[in]chanChannel descriptor
[in]rngRange descriptor
[out]dstOuput buffer
[in]srcInput buffer
[in]cntCount of conversion to perform
Returns
the count of conversion performed, otherwise a negative error code:
  • -EINVAL is returned if some argument is missing or wrong; chan, rng and the pointers should be checked; check also the kernel log ("dmesg"); WARNING: a4l_fill_desc() should be called before using a4l_rawtod()

References A4L_RNG_FACTOR, and a4l_sizeof_chan().

int a4l_rawtof ( a4l_chinfo_t *  chan,
a4l_rnginfo_t *  rng,
float *  dst,
void *  src,
int  cnt 
)

Convert raw data (from the driver) to float-typed samples.

Parameters
[in]chanChannel descriptor
[in]rngRange descriptor
[out]dstOuput buffer
[in]srcInput buffer
[in]cntCount of conversion to perform
Returns
the count of conversion performed, otherwise a negative error code:
  • -EINVAL is returned if some argument is missing or wrong; chan, rng and the pointers should be checked; check also the kernel log ("dmesg"); WARNING: a4l_fill_desc() should be called before using a4l_rawtod()

References A4L_RNG_FACTOR, and a4l_sizeof_chan().

int a4l_rawtoul ( a4l_chinfo_t *  chan,
unsigned long *  dst,
void *  src,
int  cnt 
)

Unpack raw data (from the driver) into unsigned long values.

This function takes as input driver-specific data and scatters each element into an entry of an unsigned long table. It is a convenience routine which performs no conversion, just copy.

Parameters
[in]chanChannel descriptor
[in]rngRange descriptor
[out]dstOuput buffer
[in]srcInput buffer
[in]cntCount of transfer to copy
Returns
the count of copy performed, otherwise a negative error code:
  • -EINVAL is returned if some argument is missing or wrong; chan, rng and the pointers should be checked; check also the kernel log ("dmesg"); WARNING: a4l_fill_desc() should be called before using a4l_ultoraw()

References a4l_sizeof_chan().

int a4l_sizeof_chan ( a4l_chinfo_t *  chan)

Get the size in memory of an acquired element.

According to the board, the channels have various acquisition widths. With values like 8, 16 or 32, there is no problem finding out the size in memory (1, 2, 4); however with widths like 12 or 24, this function might be helpful to guess the size needed in RAM for a single acquired element.

Parameters
[in]chanChannel descriptor
Returns
the size in memory of an acquired element, otherwise a negative error code:
  • -EINVAL is returned if the argument chan is NULL

Referenced by a4l_dtoraw(), a4l_ftoraw(), a4l_rawtod(), a4l_rawtof(), a4l_rawtoul(), and a4l_ultoraw().

int a4l_sizeof_subd ( a4l_sbinfo_t *  subd)

Get the size in memory of a digital acquired element.

This function is only useful for DIO subdevices. Digital subdevices are a specific kind of subdevice on which channels are regarded as bits composing the subdevice's bitfield. During a DIO acquisition, all bits are sampled. Therefore, a4l_sizeof_chan() is useless in this case and we have to use a4l_sizeof_subd(). With bitfields which sizes are 8, 16 or 32, there is no problem finding out the size in memory (1, 2, 4); however with widths like 12 or 24, this function might be helpful to guess the size needed in RAM for a single acquired element.

Parameters
[in]subdSubdevice descriptor
Returns
the size in memory of an acquired element, otherwise a negative error code:
  • -EINVAL is returned if the argument chan is NULL or if the subdevice is not a digital subdevice

References A4L_SUBD_DI, A4L_SUBD_DIO, A4L_SUBD_DO, and A4L_SUBD_TYPES.

Referenced by a4l_sync_dio().

int a4l_ultoraw ( a4l_chinfo_t *  chan,
void *  dst,
unsigned long *  src,
int  cnt 
)

Pack unsigned long values into raw data (for the driver)

This function takes as input a table of unsigned long values and gather them according to the channel width. It is a convenience routine which performs no conversion, just formatting.

Parameters
[in]chanChannel descriptor
[in]rngRange descriptor
[out]dstOuput buffer
[in]srcInput buffer
[in]cntCount of transfer to copy
Returns
the count of copy performed, otherwise a negative error code:
  • -EINVAL is returned if some argument is missing or wrong; chan, rng and the pointers should be checked; check also the kernel log ("dmesg"); WARNING: a4l_fill_desc() should be called before using a4l_ultoraw()

References a4l_sizeof_chan().