I cannot seem to get the interrupt functionality working - my callback is always fired immediately, regardless of the timeout I set or the state of the pin.
I'm using the exact code from the README, but with two changes:
I'm using GPIO4 (4 in the code)
I'm trying different timeout values like 999999
The screen floods with these messages:
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
If I change the state of the pin, I'll see the value change accordingly:
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 0
Pin 4 changed to: 0
Pin 4 changed to: 0
Pin 4 changed to: 0
Pin 4 changed to: 0
Pin 4 changed to: 0
Pin 4 changed to: 0
Pin 4 changed to: 0
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
Pin 4 changed to: 1
But the callback still fires rapidly when the state isn't changing.
I tried testing the underlying stream_select() myself by running the following commands as root...
echo 4 > /sys/class/gpio/unexport # Start from a clean state
echo 4 > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio4/direction
echo "both" > /sys/class/gpio/gpio4/edge
I cannot seem to get the interrupt functionality working - my callback is always fired immediately, regardless of the timeout I set or the state of the pin.
I'm using the exact code from the README, but with two changes:
4
in the code)The screen floods with these messages:
If I change the state of the pin, I'll see the value change accordingly:
But the callback still fires rapidly when the state isn't changing.
I tried testing the underlying
stream_select()
myself by running the following commands as root...Followed by this PHP script as root:
The script immediately ends with the following output:
This occurs both when nothing is connected to the pin (value is HIGH) and when the pin is connected directly to GND (value is LOW).
I wonder if perhaps this only occurs with certain Pi devices? I'm using a Raspberry Pi 3 running Raspbian Jessie.