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

Callback example pin mode failed #21

Open
sanj3k opened this issue Apr 23, 2024 · 1 comment
Open

Callback example pin mode failed #21

sanj3k opened this issue Apr 23, 2024 · 1 comment

Comments

@sanj3k
Copy link

sanj3k commented Apr 23, 2024

Hi, I have an issue I want to use a python script to setup three pins for interrupt input but seem to fail already in the beginning. Also just out of curiosity is there no possibility to have the debounce parameter?

Type "help", "copyright", "credits" or "license" for more information.
>>> import wiringpi
>>> PIN_TO_SENSE = 5
>>> def gpio_callback():
...     print("GPIO_CALLBACK!")
...
>>> wiringpi.wiringPiSetupGpio()
0
>>> wiringpi.pinMode(PIN_TO_SENSE, wiringpi.GPIO.INPUT)
Pin mode failed!

### And if I use wiringPiSetup without Gpio suffix then I cant create the interrupt service routine.
>>> wiringpi.wiringPiSetup()
0
>>> wiringpi.pinMode(5,GPIO.INPUT)
>>> wiringpi.pullUpDnControl(5,GPIO.PUD_UP)
>>> def gpio_callback():
...     print("GPIO_CALLBACK!")
...
>>> wiringpi.wiringPiISR(5, GPIO.INT_EDGE_FALLING, gpio_callback)
wiringPiISR: unable to open /sys/class/gpio/gpio36/value: No such file or directory

### Currently installed version
Help on module wiringpi:

NAME
    wiringpi

DESCRIPTION
    # This file was automatically generated by SWIG (http://www.swig.org).
    # Version 4.0.2
    #
    # Do not make changes to this file unless you know what you are doing--modify
    # the SWIG interface file instead.
@sanj3k
Copy link
Author

sanj3k commented Apr 23, 2024

By the way I have just stumbled upon the documentation where it says SetupGpio means we have to use the GPIO column for pin values and now I dont get pin mode failed :) in my case wpi 5 is gpio 36 and it works but it didnt work for higher than 63 values??

image

>>> PIN_TO_SENSE = 98
>>> wiringpi.wiringPiSetupGpio()
0
>>> wiringpi.pinMode(PIN_TO_SENSE, wiringpi.GPIO.INPUT)
>>> wiringpi.pullUpDnControl(PIN_TO_SENSE,wiringpi.GPIO.PUD_UP)
>>> wiringpi.wiringPiISR(98, wiringpi.GPIO.INT_EDGE_FALLING, gpio_callback)
wiringPiISR: pin must be 0-63 (98)
root@belabox:~#python3
>>> import wiringpi
>>> wiringpi.wiringPiSetupGpio()
0
>>> wiringpi.pinMode(36, wiringpi.GPIO.INPUT)
>>> wiringpi.pullUpDnControl(36,wiringpi.GPIO.PUD_UP)
>>> wiringpi.wiringPiISR(36, wiringpi.GPIO.INT_EDGE_FALLING, gpio_callback)
>>> GPIO_CALLBACK!
GPIO_CALLBACK!
GPIO_CALLBACK!
GPIO_CALLBACK!

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

1 participant