Giter Site home page Giter Site logo

Comments (6)

brian-armstrong avatar brian-armstrong commented on September 16, 2024

Hi @curiositry,

Sorry to hear it didn't work. I don't know if the Zero has been tried but can't think of any specific reason it wouldn't work.

Just to confirm, do you have a /sys/class/gpio directory?

from gpio.

curiositry avatar curiositry commented on September 16, 2024

Thanks for responding @brian-armstrong β€” yes, /sys/class/gpio does exist.

from gpio.

brian-armstrong avatar brian-armstrong commented on September 16, 2024

@curiositry I can think of one thing, after rereading some of my code. It looks like the Watcher will not fail gracefuly if you Close it before calling Watch. If you did that, Watch would just hang forever.

Just to be sure, could you share the code that uses the Watcher, or make sure that it isn't somehow getting Closed prematurely?

from gpio.

curiositry avatar curiositry commented on September 16, 2024

@brian-armstrong Thanks for your help. Here are the relevant portions (I was basically just testing it with what’s in the README):

pin := gpio.NewInput(7)
fmt.Println(pin.Read())
watcher := gpio.NewWatcher()
watcher.AddPin(7)
defer watcher.Close()

for {
    fmt.Println("Starting watcher.")
    pin, value := watcher.Watch()
    fmt.Print("Watcher value: ")
    fmt.Println(pin)
    fmt.Print(value)
}

It would hang at pin, value := watcher.Watch() without printing anything.

from gpio.

olb17 avatar olb17 commented on September 16, 2024

Hi Brian

I had similar experience with go 1.9 and a raspberry pi model 1. I tracked the issue down to the way the fdset is built in the watcher :
fdset.Bits[val/64] |= 1 << uint(val) % 64 is not working on my set-up.

and should be fixed as fdset.Bits[val/64] |= 1 << (uint(val) % 64)

https://play.golang.org/p/HyV6wX-aihG

I propose you a PR to fix this.

from gpio.

lsdev75 avatar lsdev75 commented on September 16, 2024

Hello,
I've go 1.9.7 and the code is correctly fixed as per last olb17 message, but after some acquisitions the Watcher stops to detect pin changes even if using 'cat' I can see the gpio change.
I want to detect the falling edge so I put Falling instead of Both inside the watcher.

from gpio.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.