Record GPIO location in handle#261
Merged
Merged
Conversation
This is convenient when debugging to see which handle is which. Plus it makes `Circuits.GPIO.status/1` work on open handles.
There was a problem hiding this comment.
Pull request overview
This PR enhances Circuits.GPIO.status/1 so it can report status for an already-open GPIO handle (useful for debugging and for observing the current consumer/direction/pull/drive on a live handle), and adds tests for the new behavior.
Changes:
- Extend
Circuits.GPIO.status/1to accept either agpio_spec(existing behavior) or an open handle (new behavior). - Record GPIO location(s) on
Circuits.GPIO.CDevhandles so handle-basedstatus/1can query the correct line. - Add tests covering
status/1on open handles and the unsupported group-handle case.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/circuits_gpio_test.exs | Adds coverage for status/1 on open handles and group handles. |
| lib/gpio/handle.ex | Extends the Circuits.GPIO.Handle protocol with a status/1 callback. |
| lib/gpio/cdev.ex | Stores handle location(s) and implements handle-based status/1. |
| lib/gpio.ex | Updates status/1 docs/spec and adds dispatch for handle arguments. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+246
to
+248
| @spec status(gpio_spec() | Handle.t()) :: {:ok, status()} | {:error, atom()} | ||
| def status(handle) when is_struct(handle), do: Handle.status(handle) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is convenient when debugging to see which handle is which. Plus it
makes
Circuits.GPIO.status/1work on open handles.