john77
Posts: 49
Joined: Tue Nov 26, 2019 11:04 am

Re: Problem using libgpiod

Tue Dec 31, 2019 6:22 am

DougieLawson wrote:
Mon Dec 30, 2019 11:36 pm
Are you using the right pin numbering scheme?

https://pinout.xyz/pinout/pin11_gpio17
https://pinout.xyz/pinout/pin16_gpio23
As I understood I should pass the BCM number (17) as an argument, not a physical pin (11).
I added
printf ("chip %p\n", chip);
printf ("line %p\n", line);
And I see
chip 0x3078c
line 0x30790
Also it should be
0x2f78c
0x2f790
shouldn't it?

User avatar
DougieLawson
Posts: 40247
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Problem using libgpiod

Tue Dec 31, 2019 6:35 am

You've not told us what model of Raspberry you're using so it's impossible to tell you.
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

john77
Posts: 49
Joined: Tue Nov 26, 2019 11:04 am

Re: Problem using libgpiod

Tue Dec 31, 2019 6:58 am

DougieLawson wrote:
Tue Dec 31, 2019 6:35 am
You've not told us what model of Raspberry you're using so it's impossible to tell you.
I'm not sure what model but it's quite old - it has 20-pin connector.

User avatar
DougieLawson
Posts: 40247
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Problem using libgpiod

Tue Dec 31, 2019 8:11 am

Test your wiring with a small chunk of python3.

Code: Select all

#!/usr/bin/python3
from gpiozero import LED, Button
from signal import pause

led = LED(17)
button = Button(23)

button.when_pressed = led.on
button.when_released = led.off

pause()
When GPIO23 is connected to GND the LED on GPIO17 should light up.

Notice the pause there so that the python3 program doesn't end before the button state is read and the LED is lit up. GPIO actions are very short lived.
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

john77
Posts: 49
Joined: Tue Nov 26, 2019 11:04 am

Re: Problem using libgpiod

Tue Dec 31, 2019 8:53 am

DougieLawson wrote:
Tue Dec 31, 2019 8:11 am
Test your wiring with a small chunk of python3.
It might be working good, no doubt. But my goal to get it running with gpiod lib. I develop in Qt C/C++.

Daniel Gessel
Posts: 121
Joined: Sun Dec 03, 2017 1:47 am
Location: Boston area, MA, US
Contact: Website Twitter

Re: Problem using libgpiod

Wed Jan 01, 2020 3:35 pm

I believe the only documentation on libgpiod is the source code itself. Do you have that as reference? For output (controlling a pimoroni blinkt on a Pi4) I ended up using the ioctl calls directly as it seemed easier than using the library. I’m Not sure if the ioctl interface or libgpiod is kept more stable from kernel to kernel.

I’m confused as to why you think the pointers returned by the library should have any particular values: iirc, they are just the results of malloc calls.

lanmrpi
Posts: 12
Joined: Sun Apr 10, 2016 1:18 am
Location: New Mexico, US
Contact: Website

Re: Problem using libgpiod

Fri Jun 05, 2020 3:29 pm

did you ever figure out how to use the libgpiod library?

I managed to install it, and was able to reproduce the code for making an LED blink, however I was not able to read any pins, or attach an event/interrupt to a pin.

If you want, I can post the blink equivalent with the libgpiod library

Ron

swahren
Posts: 149
Joined: Mon Sep 19, 2016 5:24 pm
Location: Germany

Re: Problem using libgpiod

Fri Jun 05, 2020 6:36 pm

libgpiod already contains binaries to play with: gpioinfo, gpioset, gpioget

Why not start playing with them?

lanmrpi
Posts: 12
Joined: Sun Apr 10, 2016 1:18 am
Location: New Mexico, US
Contact: Website

Re: Problem using libgpiod

Fri Jun 05, 2020 10:39 pm

huh?..

I am writing something, in C, that decodes quadrature encoder. I have some C code that does work and do that with wiringPi, but want to do it with libgpiod of course, now that sysfs is deprecated.

Redkey
Posts: 5
Joined: Fri Jan 10, 2020 4:08 pm

Re: Problem using libgpiod

Wed Aug 26, 2020 2:11 pm

If you want, I can post the blink equivalent with the libgpiod library.
I would like to see your blink source code.
Thanks
Ken

Return to “C/C++”