2014-06-10 10:01:53 +08:00
|
|
|
# Beaglebone
|
2014-04-26 18:11:51 +08:00
|
|
|
|
2014-06-10 10:01:53 +08:00
|
|
|
This package provides the Gobot adaptor for the [Beaglebone Black](http://beagleboard.org/Products/BeagleBone+Black/)
|
2014-04-26 18:11:51 +08:00
|
|
|
|
|
|
|
## Getting Started
|
|
|
|
|
2014-06-10 10:01:53 +08:00
|
|
|
## Installing
|
|
|
|
```
|
2014-07-07 03:17:10 +08:00
|
|
|
go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/platforms/gobot/beaglebone
|
2014-06-10 10:01:53 +08:00
|
|
|
```
|
2014-04-26 18:11:51 +08:00
|
|
|
|
|
|
|
## Cross compiling for the Beaglebone Black
|
|
|
|
You must first configure your Go environment for arm linux cross compiling
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ cd $GOROOT/src
|
|
|
|
$ GOOS=linux GOARCH=arm ./make.bash --no-clean
|
|
|
|
```
|
|
|
|
|
|
|
|
Then compile your Gobot program with
|
|
|
|
```bash
|
2014-06-10 10:01:53 +08:00
|
|
|
$ GOARM=7 GOARCH=arm GOOS=linux go build examples/beaglebone_blink.go
|
2014-04-26 18:11:51 +08:00
|
|
|
```
|
|
|
|
|
2014-06-10 10:01:53 +08:00
|
|
|
If you are running the official Angstrom or Debian linux through the usb->ethernet connection, you can simply upload your program and execute it with
|
2014-04-26 18:11:51 +08:00
|
|
|
``` bash
|
2014-06-10 10:01:53 +08:00
|
|
|
$ scp beaglebone_blink root@192.168.7.2:/home/root/
|
|
|
|
$ ssh -t root@192.168.7.2 "./beaglebone_blink"
|
2014-04-26 18:11:51 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2014-07-11 08:02:00 +08:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/beaglebone"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/gpio"
|
2014-04-26 18:11:51 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-07-11 08:02:00 +08:00
|
|
|
gbot := gobot.NewGobot()
|
|
|
|
|
|
|
|
beagleboneAdaptor := beaglebone.NewBeagleboneAdaptor("beaglebone")
|
|
|
|
led := gpio.NewLedDriver(beagleboneAdaptor, "led", "P9_12")
|
2014-04-26 18:11:51 +08:00
|
|
|
|
2014-07-11 08:02:00 +08:00
|
|
|
work := func() {
|
|
|
|
gobot.Every(1*time.Second, func() {
|
|
|
|
led.Toggle()
|
|
|
|
})
|
|
|
|
}
|
2014-04-26 18:11:51 +08:00
|
|
|
|
2014-07-11 08:02:00 +08:00
|
|
|
robot := gobot.NewRobot("blinkBot",
|
|
|
|
[]gobot.Connection{beagleboneAdaptor},
|
|
|
|
[]gobot.Device{led},
|
|
|
|
work,
|
|
|
|
)
|
2014-04-26 18:11:51 +08:00
|
|
|
|
2014-07-11 08:02:00 +08:00
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
|
|
|
gbot.Start()
|
2014-04-26 18:11:51 +08:00
|
|
|
}
|
2014-07-11 08:02:00 +08:00
|
|
|
```
|