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

Enumerate valid chips #20

Open
EliRibble opened this issue May 31, 2023 · 3 comments
Open

Enumerate valid chips #20

EliRibble opened this issue May 31, 2023 · 3 comments

Comments

@EliRibble
Copy link

It appears that the only way to determine how many chips are valid is to attempt gpiochip_open with some number of different integers and discard any failures. Is there an API to get the list of chips numbers that are valid? If not, what is the range of integers we should test?

@joan2937
Copy link
Owner

joan2937 commented May 31, 2023

The Linux kernel will assign gpiochip numbers. I assume they would be assigned in order 0, 1, 2, etc. I can think of no reason for not assigning in that order. So try opening increasing numbers until there is a failure.

However that is my assumption. I do not know if the kernel makes any guarantee.

@EliRibble
Copy link
Author

Thanks - is there a way to distinguish between "that chip does not exist" and "the chip exists, but you can't get a handle to it"?

@DanielDecker
Copy link

Type the following command in a the terminal to list all available gpiochips: ls /dev/gpiochip*
For more details try: sudo cat /sys/kernel/debug/gpio
I hope this helps!

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

3 participants