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

How to do monitor for an event on more than one input? #18

Open
sdc-andy opened this issue Aug 23, 2019 · 3 comments · Fixed by #35
Open

How to do monitor for an event on more than one input? #18

sdc-andy opened this issue Aug 23, 2019 · 3 comments · Fixed by #35

Comments

@sdc-andy
Copy link

sdc-andy commented Aug 23, 2019

How do you extend the gpioevents.rs example to handle multiple input pins using event handlers?

EDIT: To clarify, I don't really want to have to follow the poll methodology in monitor.rs as polling IO pins is inefficient and prone to missing changes in IO state.

-Andy.

@posborne
Copy link
Member

posborne commented Aug 23, 2019

Polling using your mechanism of choice is fine -- Providing a way to conveniently integrate this lib with tokio is not in the lib today but is something that probably should be added (probably behind a feature flag).

Events on the GPIO are queued using cdev so you will not miss them unless you really are not keeping up in your userspace application. Each event comes with a timestamp from interrupt context which is what should be used if you care about when an event really happened.

If the lines are on the same gpiochip you can read multiple using a MultiLineHandle (see https://github.com/rust-embedded/gpio-cdev/blob/master/examples/multiread.rs). The equivalent of events on this type of handle is not implemented at present although I think it should be possible (though I haven't tested this).

@massimiliano-mantione
Copy link

The equivalent of events on this type of handle is not implemented at present although I think it should be possible (though I haven't tested this).

Could you please provide a pointer to the docs of the C API that specify how to do it?
I am really interested in this and could provide a PR.
I would test it reading the two lines of a quadrature encoder (this is the use case I have).

@bors bors bot closed this as completed in 448d6fd Aug 2, 2020
@bors bors bot closed this as completed in #35 Aug 2, 2020
@rubberduck203
Copy link

I don't think #35 should have closed this issue.
While it's possible to monitor multiple lines for events, it's not nearly as ergonomic as the single line API.
I would personally love to see something like the Line::events() and LineEventHandle iterator implemented for Lines and (a new?) MultiLineEventHandle.

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.

4 participants