rust-embedded / rust-sysfs-pwm

Linux PWM Access via Sysfs in Rust
Apache License 2.0
47 stars 16 forks source link

Bugfix: Sync operations after writes #6

Closed Istar-Eldritch closed 6 years ago

Istar-Eldritch commented 6 years ago

This is a bugfix to solve the following problem:

Issue observed:

After setting duty_cycle, period and enabling the pwm interface the expected signal is not emitted.

System context: Raspberry PI 3B running Raspbian Stretch Lite: Version: June 2018 Release date: 2018-06-27 Kernel version: 4.14

Potential solution:

After observing the issue and seeing that the buffer was written to the file descriptor but that this action it was not triggering the pwm signal I thought about the possibility of the buffer not being properly flushed. By adding sync_content on the file the issue seems to be solved.

I still have some doubts on what may actually be going on, so if a better explanation is found I'll be more than happy to know about it :smile: .

Istar-Eldritch commented 6 years ago

BTW, I just saw that in the CI it's testing against rust 1.6. Is it worth to update the CI config to allow the library to use at least the new goodies to deal with results like the ? operator?

posborne commented 6 years ago

BTW, I just saw that in the CI it's testing against rust 1.6. Is it worth to update the CI config to allow the library to use at least the new goodies to deal with results like the ? operator?

Yeah, we'll definitely want to do that.

posborne commented 6 years ago

@Istar-Eldritch sorry for the delay in reviewing; as noted in the comments, I do not think that the sync calls actually have any effect on writes to unbuffered sysfs file descriptors.

Istar-Eldritch commented 6 years ago

Thank you for your review @posborne, your answer makes sense. Sorry, I didn't reply earlier either, I didn't saw the notification.

Do you have any guidance towards a proper solution?

Istar-Eldritch commented 6 years ago

Closing this as it's not going anywhere and it's not required by the repo.

I'm still open to tips to solve the issue for real or at least get a better understanding of what is causing it.

Cheers