Skip to content

Getting edge causes a crash on a Raspberry Pi 4 Model B Rev 1.5 #139

@just-doit

Description

@just-doit

Board Type

Raspberry Pi 4 Model B Rev 1.5

Operating System

Linux 6.6.20+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.20-1+rpt1 (2024-03-07) aarch64 GNU/Linux

Swift Version

Swift version 5.10 (swift-5.10-RELEASE)
Target: aarch64-unknown-linux-gnu
Prebuild

Description

A pin is configured as an input and should call up a function when it changes (both high->low and low-high).
When getting the value of the edge property an exception is raised.
In my opinion, this is caused by the getter making the following call:

            return GPIOEdge(rawValue: getStringValue("gpio "+String(id)+"/edge")!)!

This ends up at readFromFile with the following path: /sys/class/gpio/gpio0/edge.
However, this does not exist on my device, so that nil is returned.
This is unwrapped with ! -> boom.

This is what /sys/class/gpiolooks like:

total 0
drwxrwxr-x  2 root gpio    0 Apr 30 14:39 .
drwxr-xr-x 65 root root    0 Jan  1  1970 ..
--w--w----  1 root gpio 4096 Apr 30 14:39 export
lrwxrwxrwx  1 root gpio    0 Apr 30 14:39 gpiochip512 -> ../../devices/platform/soc/fe200000.gpio/gpio/gpiochip512
lrwxrwxrwx  1 root gpio    0 Apr 30 14:39 gpiochip570 -> ../../devices/platform/soc/soc:firmware/soc:firmware:gpio/gpio/gpiochip570
--w--w----  1 root gpio 4096 Apr 30 14:39 unexport

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions