From 991af9a201312ee25fd30de5007ffdb65fd19204 Mon Sep 17 00:00:00 2001 From: Thomas Kohler Date: Sat, 28 Oct 2023 13:57:35 +0200 Subject: [PATCH] jetson(PWM): fix set period (#1019) --- platforms/jetson/pwm_pin.go | 2 +- platforms/jetson/pwm_pin_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platforms/jetson/pwm_pin.go b/platforms/jetson/pwm_pin.go index 18b432e0..93a3f57a 100644 --- a/platforms/jetson/pwm_pin.go +++ b/platforms/jetson/pwm_pin.go @@ -89,7 +89,7 @@ func (p *PWMPin) SetPeriod(period uint32) error { if period < minimumPeriod { return errors.New("Cannot set the period more then minimum") } - if err := p.writeFile(fmt.Sprintf("pwm%s/period", p.fn), fmt.Sprintf("%v", p.period)); err != nil { + if err := p.writeFile(fmt.Sprintf("pwm%s/period", p.fn), fmt.Sprintf("%v", period)); err != nil { return err } p.period = period diff --git a/platforms/jetson/pwm_pin_test.go b/platforms/jetson/pwm_pin_test.go index 5bddaa8d..a61e2275 100644 --- a/platforms/jetson/pwm_pin_test.go +++ b/platforms/jetson/pwm_pin_test.go @@ -55,11 +55,11 @@ func TestPwmPin(t *testing.T) { assert.Equal(t, "", fs.Files[dutyCyclePath].Contents) assert.NoError(t, pin.SetPeriod(20000000)) - // TODO: see PR #990 assert.Equal(t, "20000000", fs.Files[periodPath].Contents) + assert.Equal(t, "20000000", fs.Files[periodPath].Contents) period, _ := pin.Period() assert.Equal(t, uint32(20000000), period) assert.ErrorContains(t, pin.SetPeriod(10000000), "Cannot set the period of individual PWM pins on Jetson") - // TODO: see PR #990 assert.Equal(t, "20000000", fs.Files[periodPath].Contents) + assert.Equal(t, "20000000", fs.Files[periodPath].Contents) dc, _ := pin.DutyCycle() assert.Equal(t, uint32(0), dc)