Skip to content

Sensor decoder context should not be reused in Sensor Read and Decode example #88812

@ymleung314

Description

@ymleung314

Describe the bug
When using the sample code in Sensor Polling Read docs, temp_decoder is reused for all sensor_decode. The frame iterator temp_decoder.fit is not reset after each read-decode cycle, later call to sensor_decode will just return 0.

See: https://docs.zephyrproject.org/latest/hardware/peripherals/sensor/read_and_decode.html

To Reproduce
Just set up the overlay and Kconfig for ICM42688 , copy and paste then run it.

Expected behavior
New values will read on every iteration.

Impact
May be confusing to sensor read-decode API first-time users.

Environment (please complete the following information):

  • OS: Linux

Additional context
Tested with an ICM42688.

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions