-
Notifications
You must be signed in to change notification settings - Fork 49
Enhancement: Switch time.monotonic() to supervisor.ticks_ms() #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
supervisor appears to be supported by most builds -- I'll do some checking, but this may be a good way to go As discussed on discord, I was hoping "deep sleep" would also help, but it is not clear if it will. |
I have working code, with time.monotonic() replaced with supervisor.ticks_ms(), and the diff function mentioned in your link. Unfortunately the whole Pull Request, pylint, and black is still a bit to complicated for me. |
@mrdalgaard Feel free to post your code here -- I was just looking at what it would involve. |
Heres the diff, just to keep it brief:
|
@mrdalgaard Thanks -- looks good. I was at first concerned about mixing the float values and the int values but python seems to be pretty good at that. I'll do some testing and create a PR for discussion in the next few days. Thanks for bringing this up. |
hmm -- ran into a snag ... The implementation of "Blinka" that supports using Circuitpython libraries on Raspberry Pi's does not support "supervisor" .... |
I have a kludge working on the Pi and regular MCUs... I'm not ready to commit it yet, but here it is if you want to have a look and comment.
|
Since we're already checking for supervisor.ticks_ms, would checking for time.monotonic_ns as the first fallback also make sense? Or is that just overcomplicating things..? The issue faced is repeated across many modules using time.monotonic() for timeouts, just to mention a few: Even though the RFM library will likely experience the problem the most (the timeout here is used for non wired signals, and with a fairly short timeout), maybe a generalized approach would make sense. Either way, I'm happy if it is solved in the RFM9x lib. |
Also, time.monotonic() does not have the same accuracy loss on the Raspberry Pi so it should not be an issue there. |
@mrdalgaard PR #68 created -- please review and comment. |
As many RFM9x projects are likely to be in a remote location, and running for long'ish periods, the accuracy of time.monotonic() will over time degrade into the seconds range, making send_with_ack, and receive timeouts longer then desired.
self.ack_wait = 0.5 would effectively become self.ack_wait = 1
self.receive_timeout = 0.5 would become self.receive_timeout = 1
This would become worse over time. (higher values)
Switching to supervisor.ticks_ms() would solve this, however I'm unsure if its available on all platforms yet.
The text was updated successfully, but these errors were encountered: