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

Document that accel_raw and accel_norm expect data to be ready #61

Closed
jacobrosenthal opened this issue Aug 1, 2020 · 6 comments · Fixed by #62
Closed

Document that accel_raw and accel_norm expect data to be ready #61

jacobrosenthal opened this issue Aug 1, 2020 · 6 comments · Fixed by #62

Comments

@jacobrosenthal
Copy link
Contributor

Were chatting over at https://github.com/BenBergman/lis3dh-rs

Most people dont understand that if you're polling, you need to be setting an appropriate data rate so that you're not requesting data before its ready.Really what you should be doing when polling in a tight loop is

            while !lis3dh.is_data_ready().unwrap() {}
            let dat = lis3dh.accel_raw().unwrap();

But if thats what you should be doing, should accel_raw just include that check directly?

It adds an extra round trip which might annoy some zero costers. And it would generally be implemented with some kind of WouldBlock non error which might be confusing/

Currently accel_raw doesnt specify.

I did a github search found one brave soul out of all the implementations who did exactly that
https://github.com/JosephBGerber/lis3dsh-rs/blob/5ef60fa5d95199df18fcfb20d6ea1a2e810c36b7/src/lib.rs

I think its worth implementers to weight in here

@tarcieri
Copy link
Contributor

tarcieri commented Aug 1, 2020

AccelRaw is a relatively new trait split from Accelerometer. It doesn’t have a particularly well-specified contract, but I’d say is generally assumed to be synchronous, so I’d suggest incorporating the busy-wait logic.

All that said, I think there is a lot of opportunity for specifying abstractions for other usage patterns, particularly interrupt-driven ones.

If you have any suggestions about any of these things, I’d love to hear them.

@jacobrosenthal
Copy link
Contributor Author

jacobrosenthal commented Aug 1, 2020

Yeah i was about to say it could be very common to get your data is ready signal from an interrupt, which means you dont want the extra check. Might be enough to document that its not expected _raw or _norm are validated for data is ready and explain the interrupt and polling patterns

@jacobrosenthal
Copy link
Contributor Author

Its a shame no one watches here. You should look at your downstream dependencies authors and ask them to star and watch so they can be kept in the loop :)

@tarcieri
Copy link
Contributor

tarcieri commented Aug 1, 2020

If there are specific GitHub issues or other resources you can link, I’d be curious to check them out. Separately it might be good to try to upstream this crate to the Embedded WG so there’s somewhere better to coordinate on improvements.

@jacobrosenthal
Copy link
Contributor Author

jacobrosenthal commented Aug 1, 2020 via email

@jacobrosenthal
Copy link
Contributor Author

jacobrosenthal commented Aug 1, 2020 via email

@jacobrosenthal jacobrosenthal changed the title How to deal with data not ready on accel_raw Document that accel_raw and accel_norm expect data to be ready Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants