Skip to content
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

[rtl872x] fix millis() may jump after ~37 hours. #2750

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

XuGuohui
Copy link
Member

@XuGuohui XuGuohui commented Mar 7, 2024

Problem

If left running, the P2 millis count will suddenly skip ~3200 seconds between the 36 - 37 hour mark.

Solution

Handle the sys timer overflow in correct manner.

Steps to Test

Run the attached app.

Example App

#include "Particle.h"

SYSTEM_MODE(AUTOMATIC);
SYSTEM_THREAD(ENABLED);

SerialLogHandler logHandler(LOG_LEVEL_INFO);

unsigned long last_time;

void setup() {
    last_time = millis();
}

void loop() {
    unsigned long time = millis();
    if (time > last_time + 10000) {
        Log.info("%d", (int) Time.now());
        if (time > last_time + 30000) {
            Log.warn("Time skip");
            RGB.control(true);
            RGB.color(255, 0, 0);
            while (1);
        }
        last_time = time;
    }
}

References

https://app.shortcut.com/particle/story/125902/millis-count-suddenly-jumps-3200-s-after-36-hours-of-use


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

@XuGuohui XuGuohui added this to the 5.8.0 milestone Mar 7, 2024
@XuGuohui XuGuohui force-pushed the fix/SC125902/rtl872x-millis-jumps branch from 97a9362 to 87c26fb Compare March 8, 2024 04:33
@XuGuohui XuGuohui merged commit 87b4d54 into develop Mar 8, 2024
13 checks passed
@XuGuohui XuGuohui deleted the fix/SC125902/rtl872x-millis-jumps branch March 8, 2024 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants