Skip to content
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

BeagleBone adaptor panics when trying to use direct pin #98

Closed
trevrosen opened this issue Aug 23, 2014 · 2 comments
Closed

BeagleBone adaptor panics when trying to use direct pin #98

trevrosen opened this issue Aug 23, 2014 · 2 comments

Comments

@trevrosen
Copy link
Collaborator

Hi there,
I am getting an index out of range panic when trying to use a direct pin driver with a BeagleBone adaptor. Below is a minimal repro case as well as some system information. It should be noted that the repro case here is very similar to the provided BB direct pin example at https://github.com/hybridgroup/gobot/blob/master/examples/beaglebone_direct_pin.go

Repro script

package main
import(
        _"github.com/hybridgroup/gobot"
        "github.com/hybridgroup/gobot/platforms/beaglebone"
        "github.com/hybridgroup/gobot/platforms/gpio"
)

func main() {
        beagleboneAdaptor := beaglebone.NewBeagleboneAdaptor("testbox")
        gpioPin           := gpio.NewDirectPinDriver(beagleboneAdaptor, "mahDevice", "P9_12")
        gpioPin.DigitalWrite(1)
}

Stack trace:

root@beaglebone:~/go/src/bbb_test# ./bbb_test
panic: runtime error: index out of range

goroutine 16 [running]:
runtime.panic(0x103658, 0x1a3264)
    /usr/local/go/src/pkg/runtime/panic.c:279 +0x1a0
github.com/hybridgroup/gobot/platforms/beaglebone.(*BeagleboneAdaptor).digitalPin(0x1032e080, 0x110fb8, 0x5, 0x10fde8, 0x1, 0xb6fc8370)
    /root/go/src/github.com/hybridgroup/gobot/platforms/beaglebone/beaglebone_adaptor.go:237 +0x68
github.com/hybridgroup/gobot/platforms/beaglebone.(*BeagleboneAdaptor).DigitalWrite(0x1032e080, 0x110fb8, 0x5, 0x1)
    /root/go/src/github.com/hybridgroup/gobot/platforms/beaglebone/beaglebone_adaptor.go:174 +0x54
github.com/hybridgroup/gobot/platforms/gpio.(*DirectPinDriver).DigitalWrite(0x10318150, 0x1032e001)
    /root/go/src/github.com/hybridgroup/gobot/platforms/gpio/direct_pin_driver.go:65 +0x88
main.main()
    /root/go/src/bbb_test/main.go:12 +0xd0

System information

root@beaglebone:~/go/src/bbb_test# cat /etc/issue
Debian GNU/Linux 7 \n \l
root@beaglebone:~/go/src/bbb_test# go version
go version go1.3 linux/arm
@trevrosen
Copy link
Collaborator Author

In the spirit of solving my own issue, I have been looking into this. It seems that the digitalPins array has a length of 0 at the time that it is being accessed. Still investigating, but feeling like I'm on the right track.

@trevrosen
Copy link
Collaborator Author

Sorry for thrash on this -- realized that I would need to call Connect(), which I would've known if I'd have rtfm'd harder in the first place. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant