-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with watcher on Pi Zero #1
Comments
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? |
Thanks for responding @brian-armstrong — yes, |
@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? |
@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 |
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 : 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. |
Hello, |
Hello Brian,
I’m using the latest Raspbian image on Raspberry Pi Zero + Zero Ws, I can read a pin manually without issue, but I haven’t gotten any action out of the watcher. I have two questions:
Has the library been tested on the Zero / Zero W before? If not, is there any reason to think it might not be compatible?
I’m using BCM pin 7 (physical pin 26) as an input. As far as I understood, the kernel uses BCM numbering;
pin := gpio.NewInput(7)
works, so is there any reason whywatcher.AddPin(7)
wouldn’t?Thanks for your help!
The text was updated successfully, but these errors were encountered: