Skip to content

epoll_wait error with libgpiod2 after suspend/resume #2598

Description

Describe the bug

After my application resumes from standby/suspend, GPIO edge-event notifications stop being delivered entirely for the affected pin. This resulted in an GpiodException (see "Actual behavior" below).

I'm using LibGpiodV2Driver (System.Device.Gpio.Drivers.LibGpiodV2Driver) on an embedded arm64 Linux device that goes into standby and is later resumed. When the device is suspended/resumed while a callback is registered, that pin never fires an event again, even though the physical GPIO line is still changing state.

Steps to reproduce

const int PinNumber = 1; // Or any other GPIO pin
const int ChipNumber = 0; // Or any other GPIO chip number
var controller = new GpioController(new LibGpiodV2Driver(chipNumber: ChipNumber));

controller.OpenPin(PinNumber);
controller.RegisterCallbackForPinValueChangedEvent(
    PinNumber,
    PinEventTypes.Falling | PinEventTypes.Rising,
    (sender, eventArgs) =>
    {
        Console.WriteLine($"Pin Event: {eventArgs.ChangeType}");
    });

Console.WriteLine("Waiting for events. Now suspend and resume the device...");
Console.ReadLine();
  1. Run the app and confirm pin-change events are printed while toggling pin <PinNumber>.
  2. Put the device into standby/suspend, then resume it.
  3. Toggle the pin again.

Expected behavior

Pin-change events for pin <PinNumber> should keep being delivered after the device resumes from standby, the same as before suspending.

Actual behavior

No further events are received for that pin after resume. The following is written to the console once, right after resume:

 Unhandled exception while handling libgpiodv2 edge events: System.Device.Gpio.Drivers.GpiodException: Error while waiting for edge events, epoll_wait: Error: 'Interrupted system call'
at System.Device.Gpio.Libgpiod.V2.LineRequest.<>c__DisplayClass19_0.<WaitEdgeEventsRespectfully>b__0()
at System.Device.Gpio.Libgpiod.V2.LineRequest.WaitEdgeEventsRespectfully(Nullable`1 timeout)
at System.Device.Gpio.Drivers.LibGpiodV2EventObserver.HandleEdgeEventsOfRequestInLoop(LineRequest request)

The application itself keeps running, but the pin never reports changes again until the app is restarted.

Versions used

  • dotnet --info on the machine being used to build
dotnet --info
.NET SDK:
 Version:           10.0.301
 Commit:            96856fd726
 Workload version:  10.0.300-manifests.8c7d7c03
 MSBuild version:   18.6.4+96856fd72

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.26100
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\10.0.301\
  • dotnet --info on the machine where app is being run (not applicable for self-contained apps)
    app is running self-contained
  • Version of System.Device.Gpio package
    4.2.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions