-
Notifications
You must be signed in to change notification settings - Fork 2k
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
saul: Ignore extra dimensions in read functions #12863
Conversation
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested ACK
@leandrolanzieri any objections? |
There was a problem hiding this 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
Contribution description
This PR modifies the current ADC and GPIO SAUL functions to not fill the extra dimensions of thephydat_t
struct with zeros. This allows the calling function to automatically detect the dimensions used by the SAUL sensor or actuator by filling it withPHYDAT_MIN
orPHYDAT_MAX
and checking which of thephydat::val[]
s are modified after asaul_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 (withsaul_gpio
andsaul_adc
included as modules).Issues/PRs references
None