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

Cron not working for latest release #2080

Closed
ghost opened this issue Aug 17, 2017 · 7 comments
Closed

Cron not working for latest release #2080

ghost opened this issue Aug 17, 2017 · 7 comments
Labels

Comments

@ghost
Copy link

ghost commented Aug 17, 2017

Please note that the cron module works using build from branch 2.1.0-master_20170521 but doesn't work using the latest release (master branch) from the cloud build service.

8<------------------------ BUG REPORT -----------------------------------------

Expected behavior

Output using nodemcu firmware from branch 2.1.0-master_20170521.

NodeMCU 2.1.0 build unspecified powered by Lua 5.1.4 on SDK 2.1.0(116b762)

Time Sync 2017/08/17 08:32:21
Every Minute: 2017/08/17 08:32:21
Every Minute: 2017/08/17 08:33:00
Every Minute: 2017/08/17 08:34:00

...and so on with output of same format as above with different time every minute on new line.

Actual behavior

Output using nodemcu firmware from the cloud build service.

NodeMCU custom build by frightanic.com
branch: master
commit: b62fae9
SSL: false
modules: cron,file,gpio,net,node,rtctime,sntp,tmr,uart,wifi
build built on: 2017-08-17 06:35
powered by Lua 5.1.4 on SDK 2.1.0(116b762)

Time Sync 2017/08/17 07:16:31

...and no further output.

Test code

Provide a Minimal, Complete, and Verifiable example which will reproduce the problem.

-- add code here
function sync_success()
    tm = rtctime.epoch2cal(rtctime.get())
    print(string.format("Time Sync  %04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
    cron.schedule("* * * * *", function(e) 
		      tm = rtctime.epoch2cal(rtctime.get())
		      print(string.format("Every Minute: %04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
    end)
end

wifi.eventmon.register(wifi.eventmon.STA_GOT_IP, sntp.sync(nil, sync_success, nil, nil))
    
wifi.setmode(wifi.STATION)
    
station_cfg={}
station_cfg.ssid="xxxx"
station_cfg.pwd = "xxxx"
wifi.sta.config(station_cfg)
wifi.sta.connect()

NodeMCU version

The build for which the above code doesn't work is from the master branch from the cloud build website (https://nodemcu-build.com/index.php) so the branch must be 2.1.0-master_20170811.

Please note that my code works for the previous release of branch 2.1.0-master_20170521.
I used Docker to build the previous release.

Hardware

I am using the D1 mini with no special hardware setup.

8<------------------------ END BUG REPORT -------------------------------------

@nwf
Copy link
Member

nwf commented Aug 17, 2017

As you are able to build your own firmwares, could you try 'git bisect'-ing this for us, to narrow it down to a particular commit?

@riteshRcH
Copy link

I am facing the similar issue. Last commit where cron worked properly for me was c8ac5cf.

@pazulin
Copy link

pazulin commented Aug 22, 2017

I meet same problem. cron is not working . now I use older version

@nwf
Copy link
Member

nwf commented Aug 22, 2017

@ritesht93 Do you mean that e7f0639 doesn't work for you?

@pazulin Such "me too" posts are not terribly useful unless you can help us debug what's going on. Have you tried using a debug build and looking for more detailed differences than "is not working"?

@dnc40085
Copy link
Contributor

dnc40085 commented Aug 23, 2017

@nwf git bisect output:

d93465cd865dc21efac277e920cf7169d88273d7 is the first bad commit
commit d93465cd865dc21efac277e920cf7169d88273d7
Author: Philip Gladstone <[email protected]>
Date:   Tue Jul 18 16:51:20 2017 -0400

    Add tracking and control of the rate error in the clock crystal. (#1697)
    
    * Improve RTC timekeeping -- includes clock rate tracking
    * Improved division by 1M
    * Fix crash in sntp
    * Disable RTC debug
    * Get the offset correct
    * Add comments on where the mysterious numbers came from
    * Fix a crash with auto repeat mode and errors on repeat

:040000 040000 cbae4a4c4513941eb16daa0af53e11232aa9277b 92155b21adc0d1cb380b825638cd59042c39d675 M	app
:040000 040000 3114c2c327532399ebe0c4affb189418a24254ff 0d9901491740cca399d46121c618f2a3f480eda8 M	docs

nwf pushed a commit to nwf/nodemcu-firmware that referenced this issue Aug 23, 2017
That file is supposed to only be included once because it does things
like declare static globals.  As it stands, cron doesn't believe time is
ticking.

Fixes nodemcu#2080
@nwf
Copy link
Member

nwf commented Aug 23, 2017

Oh boy. At first blush, this is because app/include/rtc/rtctime_internal.h says

/*
 * It is vital that this file is only included once in the entire
 * system. 
 */

and yet both app/modules/cron.c and app/modules/rtctime.c include it. I'll open a PR momentarily.

marcelstoer pushed a commit that referenced this issue Aug 24, 2017
That file is supposed to only be included once because it does things
like declare static globals.  As it stands, cron doesn't believe time is
ticking.

Fixes #2080
@marcelstoer
Copy link
Member

Thanks for reporting @abhignair.

eiselekd pushed a commit to eiselekd/nodemcu-firmware that referenced this issue Jan 7, 2018
That file is supposed to only be included once because it does things
like declare static globals.  As it stands, cron doesn't believe time is
ticking.

Fixes nodemcu#2080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants