libsigrok  0.4.0
sigrok hardware access and backend library
Functions
Analog data handling

Handling and converting analog data. More...

Functions

SR_PRIV int sr_analog_init (struct sr_datafeed_analog *analog, struct sr_analog_encoding *encoding, struct sr_analog_meaning *meaning, struct sr_analog_spec *spec, int digits)
 
int sr_analog_to_float (const struct sr_datafeed_analog *analog, float *outbuf)
 Convert an analog datafeed payload to an array of floats. More...
 
int sr_analog_unit_to_string (const struct sr_datafeed_analog *analog, char **result)
 Convert the unit/MQ/MQ flags in the analog struct to a string. More...
 
void sr_rational_set (struct sr_rational *r, int64_t p, uint64_t q)
 Set sr_rational r to the given value. More...
 

Detailed Description

Handling and converting analog data.

Function Documentation

SR_PRIV int sr_analog_init ( struct sr_datafeed_analog analog,
struct sr_analog_encoding encoding,
struct sr_analog_meaning meaning,
struct sr_analog_spec spec,
int  digits 
)
int sr_analog_to_float ( const struct sr_datafeed_analog analog,
float *  outbuf 
)

Convert an analog datafeed payload to an array of floats.

Parameters
[in]analogThe analog payload to convert. Must not be NULL. analog->data, analog->meaning, and analog->encoding must not be NULL.
[out]outbufMemory where to store the result. Must not be NULL.

Sufficient memory for outbuf must have been pre-allocated by the caller, who is also responsible for freeing it when no longer needed.

Return values
SR_OKSuccess.
SR_ERRUnsupported encoding.
SR_ERR_ARGInvalid argument.
Since
0.4.0

Definition at line 171 of file analog.c.

References sr_analog_meaning::channels, sr_datafeed_analog::data, sr_datafeed_analog::encoding, sr_analog_encoding::is_bigendian, sr_analog_encoding::is_float, sr_analog_encoding::is_signed, sr_datafeed_analog::meaning, sr_datafeed_analog::num_samples, sr_analog_encoding::offset, sr_rational::p, sr_rational::q, sr_analog_encoding::scale, SR_ERR, SR_ERR_ARG, SR_OK, and sr_analog_encoding::unitsize.

int sr_analog_unit_to_string ( const struct sr_datafeed_analog analog,
char **  result 
)

Convert the unit/MQ/MQ flags in the analog struct to a string.

Parameters
[in]analogStruct containing the unit, MQ and MQ flags. Must not be NULL. analog->meaning must not be NULL.
[out]resultPointer to store result. Must not be NULL.

The string is allocated by the function and must be freed by the caller after use by calling g_free().

Return values
SR_OKSuccess.
SR_ERR_ARGInvalid argument.
Since
0.4.0

Definition at line 309 of file analog.c.

References sr_datafeed_analog::meaning, sr_analog_meaning::mqflags, SR_ERR_ARG, SR_OK, and sr_analog_meaning::unit.

void sr_rational_set ( struct sr_rational r,
int64_t  p,
uint64_t  q 
)

Set sr_rational r to the given value.

Parameters
[out]rRational number struct to set. Must not be NULL.
[in]pNumerator.
[in]qDenominator.
Since
0.4.0

Definition at line 347 of file analog.c.

References sr_rational::p, and sr_rational::q.