smoltcp-rs / smoltcp

a smol tcp/ip stack
BSD Zero Clause License
3.63k stars 402 forks source link

Use of `fugit` instead of custom time implementation. #908

Open liamkinne opened 4 months ago

liamkinne commented 4 months ago

Would the maintainers be open to using fugit for the Instantand Duration rather than the custom implementation within this project?

Would save a bit of complexity in my code having to convert between the smoltcp types and the fugit types used by the SysTick library I'm using.

If someone gives the go ahead, I'm happy start working on a PR.

Dirbaio commented 4 months ago

I personally think fugit is a bit hard to use with the u32/u64/etc and NUM/DENOM generics.

I'm not opposed to the idea, but only if there's a strong motivation beyond "some other library happens to use fugit", because there's other embedded libraries that use other types for time too.

besides, what timebase (NUM/DENOM) would smoltcp use for the time? still hardcode it to microseconds? in that case you'll still have to convert between that and whatever your microcontroller is using.

liamkinne commented 4 months ago

Yeah I did think about the timebase problem. Fugit does have a method .convert() to handle different time bases. Given conversion is built-in, then I think a microsecond timebase would be fine and doesn't deviate from the current implementation.

Fugit makes the most sense to me because of it's ubiquity among HAL implementations and so in my mind having support for at least them is better than for none.

Other options are feature-gating the use of fugit or trying to make the time provider generic (my least favorite option to be clear).