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

odd SNTP behavior that sometimes happens when synchronizing #364

Open
jkent opened this issue Apr 14, 2017 · 4 comments
Open

odd SNTP behavior that sometimes happens when synchronizing #364

jkent opened this issue Apr 14, 2017 · 4 comments

Comments

@jkent
Copy link
Contributor

jkent commented Apr 14, 2017

My project uses the SNTP code -- most of the time it behaves as expected, but occasionally it will act up and time will go backwards a few hours a second, starting from the synchronized time. Here is my code I've tested it with:

https://gitlab.jkent.net/wtf/wifilcd/blob/master/main.c#L53
https://gitlab.jkent.net/wtf/wifilcd/blob/master/clock.c#L245

and here is the observed behavior:

https://www.youtube.com/watch?v=eYdcxB7kLnQ

@kanflo
Copy link
Contributor

kanflo commented Apr 18, 2017

That's odd. Have you verified the SNPT replies with printf's or eg. wireshark?

@jkent
Copy link
Contributor Author

jkent commented Apr 18, 2017

Not yet, I should have time this week to dig in deeper.

@Rutger798
Copy link

I have the same issue, and enabled some extra SNTP logging with: -DSNTP_LOGD -DSNTP_LOGD_WITH_PRINTF
after some day's of logging it looks like "RTC counter wrapped" occurred

And that only happens in:
// Check if a timer wrap has occurred. Compensate sntp_base reference // if affirmative. // TODO: think about multitasking and race conditions static inline void sntp_check_timer_wrap(uint32_t current_value) { if (current_value < tim_ref) { // Timer wrap has occurred, compensate by subtracting 2^32 to ref. sntp_base -= 1LLU<<32; // DEBUG SNTP_LOGD("SNTP RTC counter wrapped"); } }

and that also shows the issue in the comment, "multitasking"...

@Rutger798
Copy link

Soo that brings me to the open pull requests:
But both are to old to merge.....

#157
#148

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

3 participants