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

Raspberry Pi 4 Model B Change Events Won't Fire #143

Open
gestrich opened this issue Dec 1, 2024 · 0 comments
Open

Raspberry Pi 4 Model B Change Events Won't Fire #143

gestrich opened this issue Dec 1, 2024 · 0 comments

Comments

@gestrich
Copy link

gestrich commented Dec 1, 2024

Bug Report: GPIO Event and Value Handling Discrepancy

Board Type

  • Raspberry Pi 4 Model B Rev 1.4

Operating System

  • Debian GNU/Linux 12 (bookworm)

Swift Version

  • Swift 6.0.1
    Installed using swiftlang.xyz

Description of the Issue

When using a button wired to GPIO 26 as an input, I encountered inconsistent behavior with GPIO event handling and value reading depending on the board configuration used.

  • Using RaspberryPi4:

    • Issue: GPIO events (e.g., onChange) do not fire when pressing the button.
    • Observation: Manually reading GPIO.value reflects the correct value change when the button is pressed.
  • Switching to RaspberryPi4_2024:

    • Issue: GPIO events now fire properly, but manually reading GPIO.value no longer returns the correct value.

Investigation Findings

  • The filenames in /sys/class/gpio/ match the IDs used in RaspberryPi4_2024, which are offset by 512 (e.g., /sys/class/gpio/gpio538/value for GPIO 26).
    Thus, RaspberryPi4_2024 seems necessary for proper event handling.

  • However, the ids in RaspberryPi4_2024 appear to break the memory mapping.


Workaround

Here's a workaround I'm currently using. This ensures that the memory address calculations work as they did in RaspberryPi4 but the filenames will be offset by 512 as done in RaspberryPi4_2024. I don't understand all the details of this class so its likely I'm missing some things.

gestrich added a commit to gestrich/SwiftyGPIO that referenced this issue Dec 1, 2024
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