Added basic test for CHIP PWM functions

Signed-off-by: Erik Agsjö <erik.agsjo@gmail.com>
This commit is contained in:
Erik Agsjö 2017-03-13 22:46:26 +01:00
parent 5593924945
commit e125805554
2 changed files with 11 additions and 2 deletions

View File

@ -15,6 +15,7 @@ import (
var _ gobot.Adaptor = (*Adaptor)(nil)
var _ gpio.DigitalReader = (*Adaptor)(nil)
var _ gpio.DigitalWriter = (*Adaptor)(nil)
var _ gpio.ServoWriter = (*Adaptor)(nil)
var _ i2c.Connector = (*Adaptor)(nil)
type NullReadWriteCloser struct {
@ -90,3 +91,13 @@ func TestChipAdaptorI2c(t *testing.T) {
gobottest.Assert(t, a.Finalize(), nil)
}
func TestChipAdaptorInvalidPWMPin(t *testing.T) {
a := initTestChipAdaptor()
err := a.PwmWrite("LCD-D2", 42)
gobottest.Refute(t, err, nil)
err = a.ServoWrite("LCD-D2", 120)
gobottest.Refute(t, err, nil)
}

View File

@ -37,8 +37,6 @@ func unexportPWM() (err error) {
return err
}
// return fmt.Errorf("PWM is not available, check device tree setup")
func (c *Adaptor) initPWM(pwmFrequency float64) (err error) {
const basePath = pwmSysfsPath + "/pwm0"