sys/arduino: use 64bit usec to compute millis()#12275
Merged
Merged
Conversation
This is quick solution to avoid wrapping around after 4294967 milliseconds. It uses xtimer_now_usec64 instead of xtimer_now_usec. Notice that this is more expansive than the previous solution, especially on AVR systems.
maribu
approved these changes
Sep 19, 2019
maribu
left a comment
Member
There was a problem hiding this comment.
ACK. (I am 100% sure that this PR works, even without testing.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution description
This is quick solution to avoid wrapping around after 4294967 milliseconds.
It uses xtimer_now_usec64 instead of xtimer_now_usec.
Notice that this is more expansive than the previous solution, especially
on AVR systems.
Testing procedure
Use the new upcoming #12180 which adds support for using Arduino libraries. The test program is a simple loop with
TalkingLED, flashing leds. Without the fix in this PR the test program will hang roughly after 4295 seconds. I realize that this is way too long for a normal test program. An alternative is to create a special test program which would bump the "now" value to, say 4290 seconds, wait 10 seconds and look at themillis(). But I don't think it is worth the effort.Issues/PRs references
See also #12180 and #12116