jetson(PWM): fix set period (#1019)

This commit is contained in:
Thomas Kohler 2023-10-28 13:57:35 +02:00 committed by GitHub
parent f219a4055d
commit 991af9a201
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -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)