-
Notifications
You must be signed in to change notification settings - Fork 935
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
fix: rtos-trace time missing #2541
fix: rtos-trace time missing #2541
Conversation
embassy-executor intentionally doesn't depend on Also can you add one line with the right features to |
That's what I was feeling. Move the GCDs to the embassy-time-driver, but didn't reexport it in the embassy-time crate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
embassy-executor/src/raw/mod.rs
Outdated
#[cfg(feature = "rtos-trace")] | ||
impl rtos_trace::RtosTraceOSCallbacks for Executor { | ||
fn task_list() { | ||
// We don't know what tasks exist, so we can't send them. | ||
} | ||
#[cfg(feature = "integrated-timers")] | ||
fn time() -> u64 { | ||
Instant::now().as_micros() | ||
const GCD_1M: u64 = gcd(embassy_time_driver::TICK_HZ, 1_000_000); | ||
let us_per_tick = (1000 / GCD_1M) / (embassy_time_driver::TICK_HZ / GCD_1M); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1000 -> 1_000_000
also: the order of operations here will accumulate error if tick rate is not a clean divisor of 1e6. Note:
- embassy_time:
(ticks * (1000 / GCD_1K)) / (embassy_time_driver::TICK_HZ / GCD_1K);
- this PR:
ticks * ((1000 / GCD_1K) / (embassy_time_driver::TICK_HZ / GCD_1K));
if you do the division first, it'll get rounded a bit, and that error will accumulate for every second passed. Or in extreme cases, if the tick rate is higher than 1MHz us_per_tick
will be exactly 0
. If you multiply first then divide, the rounding is just +/- 1us independently of the absolute value of the uptime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, just fixed it.
Sorry about the back in forth in this PR., I'll take my time for the future ones
9c6322a
to
d48620d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Could not compile when
rtos-trace
was enabled due to missing embassy_time feature. Note that I addedembassy-time
for thertos-trace
featureWe could probably derive from
embassy-time-driver::now()
if it's preferred and don't want to depend onembassy-time