Comments (6)
Hi, thanks for reporting.
This does not look like a bug to me. RTIC simply requires some operations to be supported on Monotonic::Instant
and Monotonic::Duration
for it to be valid.
In this case you are using fugit
as the underlying time library, whose Instant
represents a wrap-able time.
So any Instant
is valid MAX/2 - 1
ticks around it. This means that your example is correct behavior, as the the new instant is within the correct span for a valid instant:
fugit::Instant::<u32, 1, 1000>::from_ticks(0xffff_ffff) + fugit::Duration::<u32, 1, 1000>::from_ticks(10)
Instant { ticks: 9 } // Correct
On the old book chapter you found, this is not valid anymore.
It was for RTIC 0.5
and the Monotonic
trait replaces the old method.
Is there anything else you'd like to ask or that I should clarify?
from rtic.
to clarify, it's correct behavior that tasks might be executed either immediately (if now + delay wraps) or at the intended delay ± jitter, not delay ± jitter?
from rtic.
Sort of, it does not depend on wrapping - just if the instant is in the future or in the past.
So if an instant is in the past the task will be executed immediately, else it will be scheduled.
With fugit
this means that you can represent time that is MAX/2 - 1
ticks into the future or the past compared to a specific Instant
.
The library does the needed math to make this happen.
from rtic.
In principle jitter cannot be negative (besides the jitter of the HW timer). There is also a difference between a task being "released" (ready to run), and the actual execution. This may cause accumulated drift if using "now" as the timebase.
from rtic.
Sort of, it does not depend on wrapping - just if the instant is in the future or in the past. So if an instant is in the past the task will be executed immediately, else it will be scheduled. With
fugit
this means that you can represent time that isMAX/2 - 1
ticks into the future or the past compared to a specificInstant
. The library does the needed math to make this happen.
But you can't represent a time up to MAX/2-1
ticks into the future relative to any specific Instant
though correct? Only relative to Instant
0, otherwise it's ambiguous whether it was intended to be in the past. I think it's surprising that spawn_after
/ reschedule_after
might end up being basically the same as spawn
, depending on the current value of the clock and what duration, since the addition with wrapping is hidden in the implementation of spawn_after
/ reschedule_after
.
In principle jitter cannot be negative (besides the jitter of the HW timer). There is also a difference between a task being "released" (ready to run), and the actual execution. This may cause accumulated drift if using "now" as the timebase.
Ah yes good clarifications, I wasn't accurate.
Overall the behavior makes sense once one knows of all the details and limitations. I do think it'd be nice to be less surprising, either by documentation or better yet some indication from the API that wrapping/as-soon-as-possible execution might occur rather than duration + jitter.
As it stands it also makes for potentially complicated calling code if one really does need the proper wait. I can't judge whether it's important often enough to justify updating the implementation to support it automatically though.
from rtic.
By extending the Monotonic timer to a u64 store, duration will be large enough for (all) practical use cases, and solves the original issue. Please re-open this issue if further clarifications are needed.
from rtic.
Related Issues (20)
- Monotonics: non-hardcoded tick rate HOT 2
- Clean application shutdown HOT 2
- embedded-hal-bus with rtic v2 in embedded-hal 1.0.0 HOT 14
- timeout_after memory usage HOT 1
- nested lock() can allow access to unlocked resources HOT 5
- `docs.rs` page for `rtic` v2.1.1 is not available
- broken usage example for i2c sharing HOT 2
- Software/Hardware Task interfaction with RTIC v2 HOT 2
- How to invoke code before RTIC main part. HOT 1
- Docs: Examples are broken and not showing HOT 3
- `atomic-polyfill` is deprecated
- rtic_monotonics 2.0 not in crates.io??? HOT 5
- Consider adding a hook to run code at the beginning of the entry point HOT 3
- SPI devices on shared bus (embedded-hal-bus) HOT 2
- Locked Status with Multiple Shared Resources HOT 1
- Software tasks and the stack HOT 2
- Support for embedded_alloc
- Call to SCB::sys_reset() results in locked up core. HOT 3
- rtic-monotonic on stm32 TIM20 or TIM17
- How to get the time stamp in a RTIC Rust Embedded application HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rtic.