Decodes a single raw data buffer.
More...
#include <sensor.h>
Decodes a single raw data buffer.
Data buffers are provided on the RTIO context that's supplied to sensor_read.
◆ decode
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.
for (int i = 0; i < NUM_DISTANCE_CHANNELS; i++) {
fit = 0;
}
@ SENSOR_CHAN_DISTANCE
Distance.
Definition sensor.h:144
- Parameters
-
| [in] | buffer | Buffer provided on the RTIO context |
| [in] | chan_spec | Channel specification to decode |
| [in,out] | fit | Current frame iterator |
| [in] | max_count | Maximum number of frames to decode |
| [out] | data_out | Decoded data |
- Returns
- Number of frames that were decoded
- Return values
-
| -EINVAL | Invalid parameters or unsupported channel |
| -ENODATA | Requested data type not present in the frame |
◆ get_frame_count
Get the frame_count for a specified chan_spec from the buffer.
- Parameters
-
| [in] | buffer | The buffer provided via the RTIO context |
| [in] | chan_spec | The channel specification to count |
| [out] | frame_count | The frame count for a specified chan_spec |
- Return values
-
| 0 | On success |
| -EINVAL | Invalid channel specification |
◆ get_size_info
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] | channel | The channel to query |
| [out] | base_size | The size of decoding the first frame |
| [out] | frame_size | The additional size of every additional frame |
- Returns
- 0 on success
-
-ENOTSUP if the channel is not supported
◆ has_trigger
Check if the given trigger type is present.
- Parameters
-
| [in] | buffer | The buffer provided on the RTIO context |
| [in] | trigger | The trigger type in question |
- Returns
- Whether the trigger is present in the buffer
The documentation for this struct was generated from the following file: