Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: sensor decoder associated data #73031

Open
teburd opened this issue May 20, 2024 · 3 comments
Open

RFC: sensor decoder associated data #73031

teburd opened this issue May 20, 2024 · 3 comments
Assignees
Labels
area: Sensors Sensors RFC Request For Comments: want input from the community

Comments

@teburd
Copy link
Collaborator

teburd commented May 20, 2024

Introduction

The new sensor API seperates the tasks of reading raw data from the device and interpreting (decoding) that data into a common numerical format, with common units, and such. The decoder today is stateless by design, but this leads to some issues when state is useful to avoid large amounts of data passing from the device driver to the decoder.

Problem description

The BME280 driver has a significant number of calibration values that are read once at startup and then used to compensate values. In the current PR looking to make use of read + decode APIs with this device the compensation values are being passed along with the read values to the decoder.

#72395

This requires a relatively large amount of memory (~64 bytes) compared to the actual sensor reading (8 bytes). In the ideal scenario the decoder would have access to the compensation values for that sensor so that it can compensate the readings without having to pass along the compensation parameters.

Proposed change

Provide a pattern for passing along shared static data from the device driver to the decoder instance, in a way that works with user space.

Concerns and Unresolved Questions

What is the best manner of doing this? Or is it even needed if we try a different route.

@teburd teburd added the RFC Request For Comments: want input from the community label May 20, 2024
@teburd teburd added the area: Sensors Sensors label May 20, 2024
@teburd
Copy link
Collaborator Author

teburd commented May 20, 2024

Sensor WG 05/20/2024

Two ideas came up

  • Could pass a pointer in the buffer so the decoder could read it
  • Could generate a per device instance API wrapper that knows how to find the static data

Both effectively require a way of exposing shared state potentially with a thread in user space.

@teburd
Copy link
Collaborator Author

teburd commented May 20, 2024

A potentially different option might be (and I realized this after the meeting) share only the compensated values. The compensated values are larger, but in this case are still much smaller than the compensation parameters themselves.

E.g. the sensor provides the compensated temperature, pressure, humidity. The decoder takes those and provides fixed point values with appropriate units/scale.

The compensation parameters then remain private to the sensor driver, at the cost of an extra word or two of memory being saved in the "raw" sensor readings, and the raw sensor readings are just not quite as raw as the straight register values from the device in this instance.

@ubieda
Copy link
Collaborator

ubieda commented May 20, 2024

A potentially different option might be (and I realized this after the meeting) share only the compensated values. The compensated values are larger, but in this case are still much smaller than the compensation parameters themselves.

My 2-cents on this: I like better keeping the data-conversion in the decoder as much as practical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Sensors Sensors RFC Request For Comments: want input from the community
Projects
Status: No status
Development

No branches or pull requests

3 participants