mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-05-14 19:29:32 +08:00
Increase beaglebone test coverage
This commit is contained in:
parent
b12bfc73f3
commit
0c9b644e6f
@ -188,7 +188,9 @@ func (b *BeagleboneAdaptor) PwmWrite(pin string, val byte) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// InitServo starts servo (not yet implemented)
|
// InitServo starts servo (not yet implemented)
|
||||||
func (b *BeagleboneAdaptor) InitServo() (err error) { return nil }
|
func (b *BeagleboneAdaptor) InitServo() (err error) {
|
||||||
|
return errors.New("InitServo is not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
// ServoWrite writes scaled value to servo in specified pin
|
// ServoWrite writes scaled value to servo in specified pin
|
||||||
func (b *BeagleboneAdaptor) ServoWrite(pin string, val byte) (err error) {
|
func (b *BeagleboneAdaptor) ServoWrite(pin string, val byte) (err error) {
|
||||||
@ -223,6 +225,9 @@ func (b *BeagleboneAdaptor) DigitalWrite(pin string, val byte) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sysfsPin, err := b.digitalPin(pin, sysfs.OUT)
|
sysfsPin, err := b.digitalPin(pin, sysfs.OUT)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return sysfsPin.Write(int(val))
|
return sysfsPin.Write(int(val))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package beaglebone
|
package beaglebone
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ func TestBeagleboneAdaptor(t *testing.T) {
|
|||||||
return []string{pattern + "5"}, nil
|
return []string{pattern + "5"}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gobot.Assert(t, a.PwmWrite("P9_99", 175), errors.New("Not a valid pin"))
|
||||||
a.PwmWrite("P9_14", 175)
|
a.PwmWrite("P9_14", 175)
|
||||||
gobot.Assert(
|
gobot.Assert(
|
||||||
t,
|
t,
|
||||||
@ -87,6 +89,9 @@ func TestBeagleboneAdaptor(t *testing.T) {
|
|||||||
i, _ := a.AnalogRead("P9_40")
|
i, _ := a.AnalogRead("P9_40")
|
||||||
gobot.Assert(t, i, 567)
|
gobot.Assert(t, i, 567)
|
||||||
|
|
||||||
|
i, err := a.AnalogRead("P9_99")
|
||||||
|
gobot.Assert(t, err, errors.New("Not a valid pin"))
|
||||||
|
|
||||||
// DigitalIO
|
// DigitalIO
|
||||||
a.DigitalWrite("usr1", 1)
|
a.DigitalWrite("usr1", 1)
|
||||||
gobot.Assert(t,
|
gobot.Assert(t,
|
||||||
@ -97,6 +102,8 @@ func TestBeagleboneAdaptor(t *testing.T) {
|
|||||||
a.DigitalWrite("P9_12", 1)
|
a.DigitalWrite("P9_12", 1)
|
||||||
gobot.Assert(t, fs.Files["/sys/class/gpio/gpio60/value"].Contents, "1")
|
gobot.Assert(t, fs.Files["/sys/class/gpio/gpio60/value"].Contents, "1")
|
||||||
|
|
||||||
|
gobot.Assert(t, a.DigitalWrite("P9_99", 1), errors.New("Not a valid pin"))
|
||||||
|
|
||||||
fs.Files["/sys/class/gpio/gpio10/value"].Contents = "1"
|
fs.Files["/sys/class/gpio/gpio10/value"].Contents = "1"
|
||||||
i, _ = a.DigitalRead("P8_31")
|
i, _ = a.DigitalRead("P8_31")
|
||||||
gobot.Assert(t, i, 1)
|
gobot.Assert(t, i, 1)
|
||||||
@ -110,4 +117,7 @@ func TestBeagleboneAdaptor(t *testing.T) {
|
|||||||
gobot.Assert(t, data, []byte{0x00, 0x01})
|
gobot.Assert(t, data, []byte{0x00, 0x01})
|
||||||
|
|
||||||
gobot.Assert(t, a.Finalize(), nil)
|
gobot.Assert(t, a.Finalize(), nil)
|
||||||
|
|
||||||
|
gobot.Assert(t, a.InitServo(), errors.New("InitServo is not yet implemented"))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user