Skip to content

Commit

Permalink
jetson(PWM): fix set period (hybridgroup#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
gen2thomas authored Oct 28, 2023
1 parent f219a40 commit 991af9a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion platforms/jetson/pwm_pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions platforms/jetson/pwm_pin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 991af9a

Please sign in to comment.