wiringOP-Python
wiringOP-Python copied to clipboard
Callback example pin mode failed
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.
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??
>>> 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!