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

Support invalidating references to a GPIO to allow it to be opened again #209

Open
fhunleth opened this issue Sep 16, 2024 · 0 comments
Open

Comments

@fhunleth
Copy link
Contributor

The problem is that if a GPIO reference gets lost in some process's state, it's no longer possible to open that GPIO. This happens when using GPIOs at the IEx prompt, since return values are saved in the session history. It can also happen in code that returns GPIO references rather than wrapping them in GenServers so there's only one owning process.

Currently it's hard to debug lost GPIO references other than to reboot. It would be a lot nicer to be able to invalidate old references and try again.

If you run this, try the following for now:

  1. For non-performance critical code, use Circuits.GPIO.write_one/3 and Circuits.GPIO.read_one/2 instead. This totally avoids references.
  2. Create a GenServer that holds the GPIO reference in its state.
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

No branches or pull requests

1 participant