periph icon indicating copy to clipboard operation
periph copied to clipboard

Halt() does not unblock WaitForEdge()

Open toxygene opened this issue 5 years ago • 2 comments

According to the documentation, calling Halt() or In() on a pin should cause WaitForEdge() to unblock and return false. When I attempt to do this on a Raspberry Pi Zero W, however, WaitForEdge() does not become unblocked.

package main

import (
	"fmt"
	"time"

	"periph.io/x/periph/conn/gpio"
	"periph.io/x/periph/conn/gpio/gpioreg"
	"periph.io/x/periph/host"
)

func main() {
	if _, err := host.Init(); err != nil {
		panic(err)
	}

	aPin := gpioreg.ByName("23")
	aPin.In(gpio.PullUp, gpio.BothEdges)

	go func() {
		time.Sleep(1 * time.Second)

		fmt.Println("calling Halt()")
		aPin.Halt()
		fmt.Println("called Halt()")
	}()

	fmt.Println("wait for edge")
	aPin.WaitForEdge(-1)
	fmt.Println("done waiting for edge")
}

This program will output:

wait for edge
calling Halt()
called Halt()

and then block indefinitely.

Platform:

  • OS: Raspbian GNU/Linux 9
  • Board: Raspberry Pi Zero Wireless

toxygene avatar Oct 14 '19 21:10 toxygene

Sorry I didn't have time to play with this locally and won't likely have time until this weekend. :/

maruel avatar Oct 17 '19 00:10 maruel

Sorry I didn't have time to play with this locally and won't likely have time until this weekend. :/

Don't worry about it. I don't need it for anything critical -- it's only for a small side project I'm working on.

toxygene avatar Oct 17 '19 01:10 toxygene

Manually ported to https://github.com/periph/host/issues/36.

maruel avatar Sep 18 '23 20:09 maruel