-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
time() does not work without active NTP server #1679
Comments
I use this workaround for now:
|
I m looking for full software rtc in core libraries too. |
Thanks, @everslick! @far5893 There is widely known Time library from arduino.cc, but it is not compiled with 2.1.0-rc2 for me. And of course, this is not core lib @igrr Please take attention to string handling in sntp_xxx code. I have got exception 28 (or sometimes 9) with sntp_asctime[_r] and sntp_sync_xxx approx after 22-24 hours uptime. there is only
|
sntp_xxx functions come from espressif SDK, as far as I can tell. On Sun, Feb 28, 2016, 13:04 Alexander Voronin [email protected]
|
@igrr Huh :( May be some try/catch over sntp_xxx in esp8266/time.c ? But I'm not sure this may help |
Maybe you will have a look at this library: It was developed from a version with ticker library without network Am 28.02.2016 um 11:30 schrieb Alexander Voronin:
|
Wrong thread, I guess. |
@Juppit Your version have same issue as this - system snmp_xxx functions does not provide correct time if no ntp sync was made prior. Another bug is in SNTPClock::begin - |
These are not c++ exceptions, these are CPU exceptions, so try/catch won't help here. Do you have a test case which is failing? I'd rather try to reproduce it and report to Espressif. |
@igrr I don't know how to reproduce it a bit stable. I'll try write minimal code only for timesync/print just now, but I have no idea how to speed up testing - 20+ hours before exception.. may be wifi connection issue while sync, may be some string formatting... |
20 hours is not that bad, I can probably hook it up to gdb and let it run On Sun, Feb 28, 2016, 14:50 Alexander Voronin [email protected]
|
hey, if I got this right you are looking for some RTC capabilities. I have used the "TimeLib.h" for that. To initialize the time, I send a head request to a google server. I sync it every night and it's running since 2 weeks now... |
@kaeferfreund Nope. I am looking for system capability to work w/o internet/NTP server. I know about TimeLib (distributed now as arduino.cc's Time.h). My use case is sensor, that may be sometimes offline and may go online w/o internet/NTP access. I plan to use DS3231 as backup RTC in my v3.1 PCB design but I just don't want to use third party lib where an system implementation exists. @igrr, 5hrs. Still working. Neither blocking port 123 on router, nor disabling wifi access does not reproduce fail. But for now I know time intervals of internal time sync )) - if NTP accessible, then sunc performed every hour, if not - every approx 33seconds. PS: I am not familiar with gdb, but try tomorrow at work (not sure it will work on cubietruck, sot first try on PC) |
@igrr Three day test - all ok, no crash. May be an issue with printing I'll try with more complex code and open separate issue if found something. |
FYI: I have the feeling, that stack growth has to do with Exception(28). I On Wed, Mar 2, 2016 at 4:32 PM, Alexander Voronin [email protected]
|
You can measure stack usage for the code which runs on Arduino task (i.e. called from Edit: |
In my case Exception 28 usually indicate incorrect usage of pointers - UPD: tested with |
@ivan: thanx for the hint. but i'm not sure, if i do it right: i create a cont_t object: static cont_t stack; in setup() i call: in loop() i do: every two seconds. but the log always reads: do i have to spawn a separate main loop with my cont_t object using On Wed, Mar 2, 2016 at 6:13 PM, Alexander Voronin [email protected]
|
Not exactly, you need to use the existing object. extern "C" cont_t g_cont;
loop() {
size_t free = cont_get_free_stack(&g_cont);
// etc
} P.S. for further discussion please visit our gitter chat or open a separate issue, let's not hijack the original issue :) |
On Thu, Mar 3, 2016 at 4:32 PM, Ivan Grokhotkov [email protected]
ahh, thx. without calling cont_init() on it i guess ? |
thank you for your effort, your implementation and example seem to work. b) I think it should be emphasized in the example that there is no automatic DST switchover in core functions. So maybe you would like to add few lines to setup() to show how easy real TZ setup can be achieved?
I'm not belitteling your effort but I think the general arduino user is not concerned about monotonic system timestamps, they more likely are searching for local realtime. IMHO People concerned about monotonic µs timestamps should be using sdk ... |
It would be nice to have such an official example sketch with energy saving and NTP updates when coming up alive to keep sensor logs accurate. Instead of adding your not-arduinish-too few lines, why wouldn't you write something like this function and propose it as a PR along with a sketch using it (a new one or the current esp8266/NTP-TZ-DST)
@igrr @devyte what would you think of such an overload of configTime() ? |
Hi d-a-v, |
Alright, I've been keeping out of this discussion on purpose, mostly because I'm not using this time functionality, and because I currently don't have the details loaded into my brain of what the "standard" or "posixy" way of doing things are. What I am using is TimeLib, from which I derived my own slightly modified version, and it has been working without issues for months now.
Do you want me to spend some time looking into the implementation, so that I can provide more detailed feedback? Maybe we can look into incorporating some of the TimeLib stuff here, making that lib superflous. |
As we are in the "core", it should only provide 1a & 1b. |
@5chufti our core can provide 1a and 1b in favor of arduino compatibility, but we can also provide 1c as our own lib, similar to our other ESP8266* libs. |
@d-a-v I'll try to take a look at the current time/ntp code, contrast against the arduino docs and against what I'm using, and provide feedback at that point. I'll try to come up with a way to get the best of all worlds. Please don't spend more time on this until then. |
I will not enter into details. What I proposed was quite simple and, I believe, coherent.
with some defines which are not stored into ram/flash like the We would then have one arduinish simple line per sketch that would configure in the most simple way accurate local time including DST for those who would like it, with no harm for others. That's all what I suggested :) |
I need to know, for low powered sketches wanting to keep accurate NTP time, if the |
Hi,
The results show that with LwIP V2 time until first valid timestamp was considerably longer than with old version.
Using "sntp_force_request()" this is now considerably shortened, especially with persistent WiFi connection !!!
so, again, thank you for your effort |
Thanks for testing ! |
#3889 @BrandonLWhite |
@d-a-v , yes for sure. I believe what should happen is to remove setting s_bootTimeSet in
then over in settimeofday
Another thing I will throw out there, is that I think "boot time" should be renamed. It is really just an offset from micros64 that gets you the current REALTIME. |
:) my words ... |
@BrandonLWhite @5chufti can you please check #4001 ? |
as soon as I'm back from holidays... |
optional settimeofday()'s callback fix esp8266#1679
optional settimeofday()'s callback fix #1679
Basic Infos
Hardware
Hardware: ESP-12E
Core Version: 2.1.0-rc2
Description
"Internal" time.c functions always return 0 /1970-01-01/ if not synced via NTP.
I want to initialize internal clock via constant or from RTC for log timestamping (so I don't need precise time on startup, but valid measured intervals)
Settings in IDE
Module: Generic ESP8266 Module
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Mode: qio
Flash Frequency: 80Mhz
Upload Using: SERIAL
Reset Method: ck
Sketch
Debug Messages
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: