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

bring_gpio_interrupt_into_userspace fails on Debian Buster, Rpi3B / 3B+ #29

Open
sibradzic opened this issue Jul 8, 2019 · 0 comments

Comments

@sibradzic
Copy link

Just tested the PiFace Digital 2 on just released Debian Buster, and it works great (some messing with device tree required to bring up SPI interface devices), official Debian on arm64 feels much snappier and riding upstream is "right thing to do" ™️...
However, as documented on https://wiki.debian.org/RaspberryPi3, GPIOs have to be accessed by offset of 458 in mind, which will cause bring_gpio_interrupt_into_userspace to fail:

>>> import pifacedigitalio
>>> pfd = pifacedigitalio.PiFaceDigital()
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pifacecommon/interrupts.py", line 385, in bring_gpio_interrupt_into_userspace
    with open(GPIO_INTERRUPT_DEVICE_VALUE):
FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/gpio/gpio25/value'

During handling of the above exception, another exception occurred:

OSError: [Errno 22] Invalid argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/dist-packages/pifacedigitalio/core.py", line 82, in __init__
    self.init_board()
  File "/usr/local/lib/python3.7/dist-packages/pifacedigitalio/core.py", line 114, in init_board
    self.enable_interrupts()
  File "/usr/local/lib/python3.7/dist-packages/pifacedigitalio/core.py", line 86, in enable_interrupts
    self.gpio_interrupts_enable()
  File "/usr/local/lib/python3.7/dist-packages/pifacecommon/interrupts.py", line 232, in gpio_interrupts_enable
    bring_gpio_interrupt_into_userspace()
  File "/usr/local/lib/python3.7/dist-packages/pifacecommon/interrupts.py", line 390, in bring_gpio_interrupt_into_userspace
    export_file.write(str(GPIO_INTERRUPT_PIN))
OSError: [Errno 22] Invalid argument

If I change GPIO_INTERRUPT_PIN = 25 to GPIO_INTERRUPT_PIN = 25 + 458 everything just works ™️
I'd like to submit a small patch that does the proper GPIO offset detection by checking /sys/bus/gpio/devices...

sibradzic added a commit to sibradzic/pifacecommon that referenced this issue Jul 8, 2019
This introduces GPIO offset detection by checking the dir name starting with
gpiochip[0-9]* found in /sys/bus/gpio/devices/gpiochip0/../gpio/.

Thec change is tested and confirmed working on Debian Buster 10 and Raspbian 9.9,
on boht Raspberry Pi 3B and 3B+
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