From e125805554f9e99667517f203c92b438c2078fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Agsj=C3=B6?= Date: Mon, 13 Mar 2017 22:46:26 +0100 Subject: [PATCH] Added basic test for CHIP PWM functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Erik Agsjö --- platforms/chip/chip_adaptor_test.go | 11 +++++++++++ platforms/chip/chip_pwm.go | 2 -- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/platforms/chip/chip_adaptor_test.go b/platforms/chip/chip_adaptor_test.go index c5f6857e..38c7afc9 100644 --- a/platforms/chip/chip_adaptor_test.go +++ b/platforms/chip/chip_adaptor_test.go @@ -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) +} diff --git a/platforms/chip/chip_pwm.go b/platforms/chip/chip_pwm.go index 369da341..d531c5f5 100644 --- a/platforms/chip/chip_pwm.go +++ b/platforms/chip/chip_pwm.go @@ -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"