warthog618 / gpio Goto Github PK
View Code? Open in Web Editor NEWA native Go library for Raspberry Pi GPIO
License: MIT License
A native Go library for Raspberry Pi GPIO
License: MIT License
run gpop.test sometimes OK, sometimes may FAIL.
error message is following:
pi@raspberrypi:~ $ ./gpio.test -test.bench=.*
--- FAIL: TestCloseInterrupts (0.06s)
interrupt_test.go:312: Spurious interrupt during close 0
FAIL
Currently the Pin struct doesn't export a way of getting the pin number that caused to watcher handler to run.
This makes writing generic handlers impossible.
Adding a reader to the Pin struct for the internal pin value would make things way easier. Something like
func (pin *Pin) Pin() uint8 {
return pin.pin
}
Another option would be to export the pin field, but then it would be possible to set that value externally.
I found it depends on soo many modules which I can't download all, and I can't get it compiled.
after remove file go.mod, go.sum, fallback to go get mode, it compile OK.
maybe somethin error whit go module ?
BTW: I very this project : wonderful function, clear APIs ...
hi,
my app crashed for the first time while using this library (nil pointer dereference) so it couldn't call Unwatch()
on all the buttons nor gpio.Close()
.
when the app is now started again, I get the error that the pin is already in use.
what is the proper way to claim a pin again? I actually want to "force use" the pin because the application must always "just work".
./dio.go:186:19: invalid operation: 1 << (pin & 31) (shift count type int, must be unsigned integer)
./dio.go:242:28: invalid operation: mem[pin.fsel] >> modeShift (shift count type int, must be unsigned integer)
./dio.go:272:33: invalid operation: modeMask << modeShift (shift count type int, must be unsigned integer)
./dio.go:272:69: invalid operation: uint32(mode) << modeShift (shift count type int, must be unsigned integer)
./dio.go:334:47: invalid operation: pullMask << shift (shift count type int, must be unsigned integer)
./dio.go:334:79: invalid operation: uint32(pull) << shift (shift count type int, must be unsigned integer)
Hi Kent,
We are looking for a Golang package to access GPIO on our Banana PI M4 board. Your project seems promising but realize that this is for Raspberry PI board. If we want to use your project for our Banana PI board, what changes do we have to make and where the changes have to be made. Or if you are able to make the changes to it so as to enable support for Banana PI M4 that would be excellent.
Thank you for your help.
David.
no error on first run. when I cancel the program with ctrl-c getting this error. (Raspberry pi 3 B+)
err=pin.Watch(gpio.EdgeBoth, func(pin *gpio.Pin) {
fmt.Printf("Pin 4 is %v\n", pin.Read())
})
if err!=nil {
panic(err)
}
defer pin.Unwatch()
panic: pin already in use
goroutine 1 [running]:
panic(0xd2b10, 0x1040c198)
/usr/lib/go-1.7/src/runtime/panic.go:500 +0x33c
Just dropping by to say thank you for an excellent library. Source code is clear and idiomatic from a targetted Go/Linux/RPI system perspective. The README gives a nice introduction and justification.
I refactored my code from @hybridgroup's Gobot GPIO ButtonDriver to use your library instead and saw a significant reduction in resource consumption.
Below stats from top
are enough to see the huge difference during a non-eventful watch period.
Before:
RES SHR S %CPU %MEM
7432 2416 S 4.7 1.7
After:
RES SHR S %CPU %MEM
2404 1964 S 0.0 0.5
I actually had to hunt for the pid because the process no longer shows up in top when ordered by CPU usage. Nice work!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.