Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Halt() does not unblock WaitForEdge() #423

Closed
toxygene opened this issue Oct 14, 2019 · 3 comments
Closed

Halt() does not unblock WaitForEdge() #423

toxygene opened this issue Oct 14, 2019 · 3 comments

Comments

@toxygene
Copy link

toxygene commented Oct 14, 2019

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
@maruel
Copy link
Contributor

maruel commented Oct 17, 2019

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

@toxygene
Copy link
Author

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.

@maruel
Copy link
Contributor

maruel commented Sep 18, 2023

Manually ported to periph/host#36.

@maruel maruel closed this as completed Sep 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants