Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sensor_decoder_api Struct Reference

Decodes a single raw data buffer. More...

#include <zephyr/drivers/sensor.h>

Data Fields

int(* get_frame_count )(const uint8_t *buffer, struct sensor_chan_spec channel, uint16_t *frame_count)
 Get the number of frames in the current buffer.
int(* get_size_info )(struct sensor_chan_spec channel, size_t *base_size, size_t *frame_size)
 Get the size required to decode a given channel.
int(* decode )(const uint8_t *buffer, struct sensor_chan_spec chan_spec, uint32_t *fit, uint16_t max_count, void *data_out)
 Decode up to max_count frames specified by chan_spec from the buffer.
bool(* has_trigger )(const uint8_t *buffer, enum sensor_trigger_type trigger)
 Check if the given trigger type is present.

Detailed Description

Decodes a single raw data buffer.

Data buffers are provided on the RTIO context that's supplied to sensor_read.

Field Documentation

◆ decode

int(* sensor_decoder_api::decode) (const uint8_t *buffer, struct sensor_chan_spec chan_spec, uint32_t *fit, uint16_t max_count, void *data_out)

Decode up to max_count frames specified by chan_spec from the buffer.

Sample showing the process of decoding at most

MAX_FRAMES for each distance
sensor channel. The frame iterator is reset for each new channel to allow the
full history of each channel to be decoded.
@code{.c}
for (int i = 0; i < NUM_DISTANCE_CHANNELS; i++) {
fit = 0;
decoder->decode(buffer, {SENSOR_CHAN_DISTANCE, i}, &fit, MAX_FRAMES, out);
}
@ SENSOR_CHAN_DISTANCE
Distance.
Definition sensor.h:123
Parameters
[in]bufferBuffer provided on the RTIO context
[in]chan_specChannel specification to decode
[in,out]fitCurrent frame iterator
[in]max_countMaximum number of frames to decode
[out]data_outDecoded data
Returns
Number of frames that were decoded
Return values
-EINVALInvalid parameters or unsupported channel
-ENODATARequested data type not present in the frame

◆ get_frame_count

int(* sensor_decoder_api::get_frame_count) (const uint8_t *buffer, struct sensor_chan_spec channel, uint16_t *frame_count)

Get the number of frames in the current buffer.

Parameters
[in]bufferThe buffer provided on the RTIO context.
[in]channelThe channel to get the count for
[out]frame_countThe number of frames on the buffer (at least 1)
Returns
0 on success
-ENOTSUP if the channel/channel_idx aren't found

◆ get_size_info

int(* sensor_decoder_api::get_size_info) (struct sensor_chan_spec channel, size_t *base_size, size_t *frame_size)

Get the size required to decode a given channel.

When decoding a single frame, use base_size. For every additional frame, add another frame_size. As an example, to decode 3 frames use: 'base_size + 2 * frame_size'.

Parameters
[in]channelThe channel to query
[out]base_sizeThe size of decoding the first frame
[out]frame_sizeThe additional size of every additional frame
Returns
0 on success
-ENOTSUP if the channel is not supported

◆ has_trigger

bool(* sensor_decoder_api::has_trigger) (const uint8_t *buffer, enum sensor_trigger_type trigger)

Check if the given trigger type is present.

Parameters
[in]bufferThe buffer provided on the RTIO context
[in]triggerThe trigger type in question
Returns
Whether the trigger is present in the buffer

The documentation for this struct was generated from the following file: