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

Add libgpiod support #283

Merged
merged 4 commits into from
Nov 25, 2023
Merged

Add libgpiod support #283

merged 4 commits into from
Nov 25, 2023

Conversation

ew1abz
Copy link
Contributor

@ew1abz ew1abz commented Jun 14, 2020

libgpiod - C library and tools for interacting with the Linux GPIO character device (gpiod stands for GPIO device).

Since Linux 4.8 the GPIO sysfs interface is deprecated. User space should use the character device instead.

@wb2osz
Copy link
Owner

wb2osz commented Nov 14, 2020

Thanks for all your great ideas.
I tried this on a Raspberry Pi with all the latest updates on Buster.
The gpiod and libgpiod-dev packages were installed.
The direwolf PTT with gpiod seemed to go well but the GPIO pin did not change.

ptt gpiod gpiochip0 -24

Suggestion: Accept either gpiochip0 or /dev/gpiochip0. It took me a while to figure out why the latter form was failing.

"gpioinfo" mostly works but it does not have the pin names making me think it has not yet been fully customized for the RPi.

"gpioset" did not change the pin state.

gpioset gpiochip0 24=0
gpioset gpiochip0 24=1

I will get back to this after gpioset is working properly.

@ew1abz
Copy link
Contributor Author

ew1abz commented Dec 16, 2020

I tried this on a Raspberry Pi with all the latest updates on Buster.

Suddenly they rolled out a new version 13 days ago, but it shouldn't affect the test you did. Now Raspberry OS has 5.4.79 kernel still based on Debian Buster.

Suggestion: Accept either gpiochip0 or /dev/gpiochip0. It took me a while to figure out why the latter form was failing.

Good idea. I'll add the additional check.

"gpioinfo" mostly works but it does not have the pin names making me think it has not yet been fully customized for the RPi.

It depends on Linux kernel version. The latest one has all bindings: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/bcm2837-rpi-3-b.dts#n51

"gpioset" did not change the pin state.
gpioset gpiochip0 24=1

It works for me but only for 40 usec. Use gpioset -m wait gpiochip0 24=1 for testing.

The direwolf PTT with gpiod seemed to go well but the GPIO pin did not change.
ptt gpiod gpiochip0 -24

Let me double check that. I didn't test inverted configuration.

Anyway, thanks for trying.

@wb2osz
Copy link
Owner

wb2osz commented Nov 22, 2023

This is the first thing going into development version 1.8.

@wb2osz wb2osz merged commit c87534f into wb2osz:dev Nov 25, 2023
1 of 9 checks passed
@wb2osz
Copy link
Owner

wb2osz commented Nov 26, 2023

PTT with gpiod/libgpiod is now available in the "dev" branch.
I did a little bit of testing on an RPi 3 and it works for a simple case.
It needs more testing under a variety of situations.
Here is how to use it.

(1) Install packages gpiod and libgpiod-dev.
(2) cd to direwolf source dir. "git pull" to get latest source.
(3) Rebuild direwolf, starting with the cmake step so the new packages are noticed.
(4) When direwolf starts, notice that libgpiod is listed in optional features.
(5) run "gpioinfo" command to get list of gpio chip names and corresponding I/O lines.
For an RPi 3, the name is "gpiochip0." I have not tried on other models yet.
(6) In your config file, change PTT line from "PTT GPIO n" to "PTT GPIOD gpiochip0 n" where n is the I/O line number.

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