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

saul: Ignore extra dimensions in read functions #12863

Merged
merged 1 commit into from
Dec 5, 2019

Conversation

bergzand
Copy link
Member

@bergzand bergzand commented Dec 3, 2019

Contribution description

This PR modifies the current ADC and GPIO SAUL functions to not fill the extra dimensions of the phydat_t struct with zeros. This allows the calling function to automatically detect the dimensions used by the SAUL sensor or actuator by filling it with PHYDAT_MIN or PHYDAT_MAX and checking which of the phydat::val[]s are modified after a saul_reg_read().

This PR is a small cleanup in the ADC and GPIO SAUL functions to not fill the unused dimensions of the phydat_t struct with zeros`

This PR can be ignored if there is a better way to automatically detect the number of dimensions used by a sensor (without hard coding).

The return value of the read call indicates the number of dimensions

@haukepetersen does this PR align with the concepts and ideas behind SAUL?

Testing procedure

examples/saul should still read out ADC and GPIO-based SAUL devices (with saul_gpio and saul_adc included as modules).

Issues/PRs references

None

@bergzand bergzand added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: drivers Area: Device drivers Area: SAUL Area: Sensor/Actuator Uber Layer labels Dec 3, 2019
@smlng
Copy link
Member

smlng commented Dec 3, 2019

doesn't the return value of the function state how many dimensions are used? However, I agree none the less that changing (or setting) values that are actually not used in a buffer passed into the function is not so nice behaviour.

@smlng smlng added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines labels Dec 3, 2019
@bergzand
Copy link
Member Author

bergzand commented Dec 4, 2019

doesn't the return value of the function state how many dimensions are used? However, I agree none the less that changing (or setting) values that are actually not used in a buffer passed into the function is not so nice behaviour.

Well, that's a bit embarrassing, so much for reading the docs.

Let's consider this a cleanup then, I'll modify the description to reflect this

@bergzand bergzand added Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation and removed Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Dec 4, 2019
@smlng smlng added the Reviewed: 3-testing The PR was tested according to the maintainer guidelines label Dec 5, 2019
Copy link
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested ACK

@smlng
Copy link
Member

smlng commented Dec 5, 2019

@leandrolanzieri any objections?

Copy link
Contributor

@leandrolanzieri leandrolanzieri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leandrolanzieri any objections?

Nope, as cleanup this makes sense :-) ACK

@leandrolanzieri leandrolanzieri merged commit 5c6410b into RIOT-OS:master Dec 5, 2019
@fjmolinas fjmolinas added this to the Release 2020.01 milestone Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: drivers Area: Device drivers Area: SAUL Area: Sensor/Actuator Uber Layer CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants