Skip to content

Record GPIO location in handle#261

Merged
fhunleth merged 1 commit into
mainfrom
open-handle-status
Jul 12, 2026
Merged

Record GPIO location in handle#261
fhunleth merged 1 commit into
mainfrom
open-handle-status

Conversation

@fhunleth

Copy link
Copy Markdown
Member

This is convenient when debugging to see which handle is which. Plus it
makes Circuits.GPIO.status/1 work on open handles.

This is convenient when debugging to see which handle is which. Plus it
makes `Circuits.GPIO.status/1` work on open handles.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/1 to accept either a gpio_spec (existing behavior) or an open handle (new behavior).
  • Record GPIO location(s) on Circuits.GPIO.CDev handles so handle-based status/1 can query the correct line.
  • Add tests covering status/1 on 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 thread lib/gpio.ex
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)

@fhunleth
fhunleth merged commit 0270169 into main Jul 12, 2026
10 checks passed
@fhunleth
fhunleth deleted the open-handle-status branch July 12, 2026 20:53
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 this pull request may close these issues.

2 participants