diff --git a/platforms/intel-iot/joule/joule_adaptor.go b/platforms/intel-iot/joule/joule_adaptor.go index aebcbb59..6a2bbc4b 100644 --- a/platforms/intel-iot/joule/joule_adaptor.go +++ b/platforms/intel-iot/joule/joule_adaptor.go @@ -136,9 +136,6 @@ func (e *Adaptor) PWMPin(pin string) (sysfsPin sysfs.PWMPinner, err error) { sysPin := sysfsPinMap[pin] if sysPin.pwmPin != -1 { if e.pwmPins[sysPin.pwmPin] == nil { - if err = e.DigitalWrite(pin, 1); err != nil { - return - } e.pwmPins[sysPin.pwmPin] = sysfs.NewPWMPin(sysPin.pwmPin) if err = e.pwmPins[sysPin.pwmPin].Export(); err != nil { return diff --git a/platforms/intel-iot/joule/joule_adaptor_test.go b/platforms/intel-iot/joule/joule_adaptor_test.go index 52cf056f..35014eef 100644 --- a/platforms/intel-iot/joule/joule_adaptor_test.go +++ b/platforms/intel-iot/joule/joule_adaptor_test.go @@ -180,3 +180,21 @@ func TestAdaptorPwm(t *testing.T) { err = a.PwmWrite("4", 100) gobottest.Assert(t, err, errors.New("Not a PWM pin")) } + +func TestAdaptorPwmPinExportError(t *testing.T) { + a, fs := initTestAdaptor() + + delete(fs.Files, "/sys/class/pwm/pwmchip0/export") + + err := a.PwmWrite("25", 100) + gobottest.Assert(t, strings.Contains(err.Error(), "/sys/class/pwm/pwmchip0/export: No such file"), true) +} + +func TestAdaptorPwmPinEnableError(t *testing.T) { + a, fs := initTestAdaptor() + + delete(fs.Files, "/sys/class/pwm/pwmchip0/pwm0/enable") + + err := a.PwmWrite("25", 100) + gobottest.Assert(t, strings.Contains(err.Error(), "/sys/class/pwm/pwmchip0/pwm0/enable: No such file"), true) +}