libsigrok
0.4.0
sigrok hardware access and backend library
|
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... | |
Handling and converting analog data.
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 | ||
) |
Definition at line 120 of file analog.c.
References sr_analog_encoding::digits, sr_datafeed_analog::encoding, sr_analog_encoding::is_bigendian, sr_analog_encoding::is_digits_decimal, sr_analog_encoding::is_float, sr_datafeed_analog::meaning, sr_analog_encoding::offset, sr_rational::p, sr_rational::q, sr_analog_encoding::scale, sr_datafeed_analog::spec, sr_analog_spec::spec_digits, SR_OK, and sr_analog_encoding::unitsize.
int sr_analog_to_float | ( | const struct sr_datafeed_analog * | analog, |
float * | outbuf | ||
) |
Convert an analog datafeed payload to an array of floats.
[in] | analog | The analog payload to convert. Must not be NULL. analog->data, analog->meaning, and analog->encoding must not be NULL. |
[out] | outbuf | Memory 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.
SR_OK | Success. |
SR_ERR | Unsupported encoding. |
SR_ERR_ARG | Invalid argument. |
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.
[in] | analog | Struct containing the unit, MQ and MQ flags. Must not be NULL. analog->meaning must not be NULL. |
[out] | result | Pointer 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().
SR_OK | Success. |
SR_ERR_ARG | Invalid argument. |
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.
[out] | r | Rational number struct to set. Must not be NULL. |
[in] | p | Numerator. |
[in] | q | Denominator. |
Definition at line 347 of file analog.c.
References sr_rational::p, and sr_rational::q.