Bug in setSNTP implementation #7131
Replies: 1 comment
-
Posted at 2019-01-30 by Wilberforce Isn't this because when the espruino starts its at time 0 - 1970 and then you are setting the time - so the intervals immediately expire? What if you set the time first and then set the intervals? @gfwilliams - any ideas? Posted at 2019-01-30 by SergeP
Yes. And settimeofday() does not correct them, so they try to catch up the time.
It depends. Because SNTP subsystem is asynchronous and so time may be really changed before or after intervals setup. It checks connection, for example, and repeats NTP request every few minutes or every hour. Posted at 2019-01-30 by Wilberforce
I don't understand why this would make a difference? Do you think this would update existing intervals? Posted at 2019-01-31 by SergeP Sorry, I was wrong. I had not read jshSetSystemTime() implementation and based on fact that my JS SNTP module calls it and works. Now I see that truth is deeper. Now I do not see where intervals are recalculated after time change. Posted at 2019-01-31 by @gfwilliams Maybe just call Posted at 2019-01-31 by Wilberforce Will calling Posted at 2019-01-31 by SergeP @gfwilliams, @wilberforce I see that jsiLastIdleTime should be changed when we change system time (by any way) to intervals remain in correct state. Posted at 2019-02-01 by @gfwilliams Yes - https://github.com/espruino/Espruino/blob/master/src/jswrap_interactive.c#L372 The timeouts work by repeated decrement based on jsiLastIdleTime, so as long as that is set it's ok.
Because setTime calls Posted at 2019-02-01 by SergeP @gfwilliams, thank you! Now I see jsiLastIdleTime change! @wilberforce, it looks like it is easiest way to call jswrap_interactive_setTime(). Or may be to implement similar own function if you prefer to set system time with millisecond precision. Posted at 2019-02-02 by Wilberforce Issue added here: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2019-01-29 by SergeP
I've found bug in setSNTP implementation. Now I have simple example. Also I think I know reason.
After setSNTP call both intervals works as if they are with zero delay.
I think it happens because SNTP subsystem uses settimeofday() inside by default and so does not change interval times.
It is possible to redefine SNTP_SET_SYSTEM_TIME macro to call jshSetSystemTime() instead of settimeofday(). I think it will repair the bug. I think also lwipopts.h is good place for it.
Beta Was this translation helpful? Give feedback.
All reactions