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.
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.
Bug Report: GPIO Event and Value Handling Discrepancy
Board Type
Operating System
Swift Version
Installed using
swiftlang.xyzDescription 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:onChange) do not fire when pressing the button.GPIO.valuereflects the correct value change when the button is pressed.Switching to
RaspberryPi4_2024:GPIO.valueno longer returns the correct value.Investigation Findings
The filenames in
/sys/class/gpio/match the IDs used inRaspberryPi4_2024, which are offset by 512 (e.g.,/sys/class/gpio/gpio538/valuefor GPIO 26).Thus,
RaspberryPi4_2024seems necessary for proper event handling.However, the ids in
RaspberryPi4_2024appear 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.