As the title says... Chat on...

User avatar
By Matthewk
#64108 First off all,please forgive me, I am new to this, and there is a really good chance I am doing something dumb here, but it is driving me nuts.

I am working with the integer version of a custom build from the custom build site. This is built against "master" and I believe it is from the 2.0 tree. Is there a way to tell exactly what version you are building?

In my lua script, I join the network, and get an IP address. I so a SNTP sync and the clock gets set. I set up SNTP with the 1 option to let it update itself. In the function to do that I have it stamp when it does an update so I can see it.

Next I set up 5 cron jobs. One to go off at 0 minutes, one to go off at 15, than 30, than 45, than 55. I started doing this with just one line but got weird results so I broke it up. Here are the lines..

cron.schedule("0 * * * *", function(e)
tm = rtctime.epoch2cal(rtctime.get())
print(string.format("*** Cron Job 0 *** %04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
end)

cron.schedule("15 * * * *", function(e)
tm = rtctime.epoch2cal(rtctime.get())
print(string.format("*** Cron Job 15 *** %04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
end)

cron.schedule("30 * * * *", function(e)
tm = rtctime.epoch2cal(rtctime.get())
print(string.format("*** Cron Job 30 *** %04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
end)

cron.schedule("45 * * * *", function(e)
tm = rtctime.epoch2cal(rtctime.get())
print(string.format("*** Cron Job 45 *** %04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
end)

cron.schedule("55 * * * *", function(e)
tm = rtctime.epoch2cal(rtctime.get())
print(string.format("*** Cron Job 55 *** %04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
end)

Each time a cron job goes off it spits the time/date to the tty.

Initially I started with just 4 cron entries. 0, 15, 30, and 45. Things seemed to work pretty OK, except the 45 minute cron job would go off at 13 minutes. The rest were fine. Weird. After pulling a lot of hair out I added the 55 minute cron job, this one goes off at 23 minutes.

Here is one of the logs.

dofile(time.lua) Wednesday, March 22, 2017 15:22:24

dofile("time.lua")
Setting up Cron Jobs
> Time Sync 2017/03/22 19:22:33
*** Cron Job 55 *** 2017/03/22 19:23:00
*** Cron Job 30 *** 2017/03/22 19:30:00
*** Cron Job 0 *** 2017/03/22 20:00:00
*** Cron Job 45 *** 2017/03/22 20:13:00
*** Cron Job 15 *** 2017/03/22 20:15:00
*** Cron Job 55 *** 2017/03/22 20:23:00
*** Cron Job 30 *** 2017/03/22 20:30:00
*** Cron Job 0 *** 2017/03/22 21:00:00

So, is it my doing something stupid or are the 45 and 55 minute cron jobs not working as they should? Is this a bug in the code or is it me?
User avatar
By marcelstoer
#64109 Sorry, really short on time.

Matthewk wrote:I am working with the integer version of a custom build from the custom build site. This is built against "master" and I believe it is from the 2.0 tree. Is there a way to tell exactly what version you are building?


node.info() might help. When the firmware boots you should see something like this

Code: Select allNodeMCU custom build by frightanic.com
   branch: dev
   commit: 5425adefff62f9ea2094e3e4581a79f1424e4433
   SSL: true
   modules: file,gpio,http,net,node,tmr,uart,wifi,tls
 build    built on: 2017-01-06 19:39
 powered by Lua 5.1.4 on SDK 2.0.0(656edbf)


I heard that some tools swallow that first UART output but I know for a fact that ESPlorer does display it.
User avatar
By Matthewk
#64112 Thank you for the node.info tip. Oddly enough, just putting node.info() in the start of the program does not do anything. I have it right before it prints out that it sets up the cron jobs so I am sure it is being executed. For what it is worth, I have been using lualoader. I am not sure why but I liked it better than ESPlorer, but I may revisit that.

I have been watching the cron job for the afternoon now and it is dependable as clockwork, the cron job that should go off at the 45 minute mark goes off at 13 minutes, and the cron job that should go off at the 55 minute mark goes off at 23 minutes. Here is the last log I got before I started playing with the node.info()..

dofile(time.lua) Wednesday, March 22, 2017 15:22:24

dofile("time.lua")
Setting up Cron Jobs
> Time Sync 2017/03/22 19:22:33
*** Cron Job 55 *** 2017/03/22 19:23:00 :twisted:
*** Cron Job 30 *** 2017/03/22 19:30:00 :D
*** Cron Job 0 *** 2017/03/22 20:00:00 :D
*** Cron Job 45 *** 2017/03/22 20:13:00 :twisted:
*** Cron Job 15 *** 2017/03/22 20:15:00 :D
*** Cron Job 55 *** 2017/03/22 20:23:00 :twisted:
*** Cron Job 30 *** 2017/03/22 20:30:00 :D
*** Cron Job 0 *** 2017/03/22 21:00:00 :D
*** Cron Job 45 *** 2017/03/22 21:13:00 :twisted:
*** Cron Job 15 *** 2017/03/22 21:15:00 :D
*** Cron Job 55 *** 2017/03/22 21:23:00 :twisted:
*** Cron Job 30 *** 2017/03/22 21:30:00 :D
*** Cron Job 0 *** 2017/03/22 22:00:00 :D
*** Cron Job 45 *** 2017/03/22 22:13:00 :twisted:
*** Cron Job 15 *** 2017/03/22 22:15:00 :D