Skip to content

Unable to use embedded_time to implement Monotonic in 1.0 #578

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

Closed
ZoeyR opened this issue Jan 4, 2022 · 3 comments
Closed

Unable to use embedded_time to implement Monotonic in 1.0 #578

ZoeyR opened this issue Jan 4, 2022 · 3 comments

Comments

@ZoeyR
Copy link

ZoeyR commented Jan 4, 2022

Hi,

I can't seem to find a way to implement the Monotonic trait using embedded_time. The duration and instant types from embedded_time don't fulfill the strict requirements put in place in rtic 1.0. Consider the following implementation:

impl Monotonic for RtcClock {
    type Instant = embedded_time::Instant<Self>;

    type Duration = embedded_time::duration::Microseconds;
}

The following error will be produced.

error[E0271]: type mismatch resolving `<Instant<RtcClock<R, P>> as Sub>::Output == Microseconds`
   --> embedded-util/src/time.rs:131:5
    |
131 |     type Instant = embedded_time::Instant<Self>;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Microseconds`, found struct `embedded_time::duration::Generic`
    |
    = note: expected struct `Microseconds`
               found struct `embedded_time::duration::Generic<u64>`
note: required by a bound in `rtic_monotonic::Monotonic::Instant`
   --> /home/zoey/.cargo/registry/src/github.com-1ecc6299db9ec823/rtic-monotonic-1.0.0/src/lib.rs:39:30
    |
39  |         + Sub<Self::Instant, Output = Self::Duration>;
    |

However if you switch to using embedded_time::duration::Generic you get the following error:

error[E0277]: the trait bound `embedded_time::duration::Generic<u64>: FixedPoint` is not satisfied
   --> embedded-util/src/time.rs:131:5
    |
131 |     type Instant = embedded_time::Instant<Self>;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FixedPoint` is not implemented for `embedded_time::duration::Generic<u64>`
    |
    = note: required because of the requirements on the impl of `Sub<embedded_time::duration::Generic<u64>>` for `Instant<RtcClock<R, P>>`
note: required by a bound in `rtic_monotonic::Monotonic::Instant`
   --> /home/zoey/.cargo/registry/src/github.com-1ecc6299db9ec823/rtic-monotonic-1.0.0/src/lib.rs:38:31
    |
38  |         + Sub<Self::Duration, Output = Self::Instant>
    |

Are there any examples of using embedded_time in rtic 1.0? Or do we have to use fugit from now on?

@korken89
Copy link
Collaborator

korken89 commented Jan 4, 2022

You can use embedded_time, but you need to use the 0.13 release branch.
It implements the requirements we have, and we have tested implementing the Monotonic trait against this branch.

@ZoeyR
Copy link
Author

ZoeyR commented Jan 4, 2022

ah, so its not released yet. Good to know.

@korken89
Copy link
Collaborator

korken89 commented Jan 4, 2022

Unfortunately not. Maybe worth poking and asking when the release will come.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants