An archive of community.esquilo.io as of Saturday January 26, 2019.

Timestamp on EOS rev 0.4 change?

gwittie

I upgraded to release 0.4 of EOS and ran into this unix timestamp problem. The following console output with added comments indicates the Esquilo board is starting from 12-14-2015, 9:26:20 (CST) after powering up. I can change the date/time with the time set command and will work correctly until I power down. It will then revert back to the Dec 14, 2015 date/time. My console output should have most commands include from a previous issue that is similar to this.

Checked timestamp after board ran for a while...

Saving file 'sd:/Projects/DateTime/date_time_v1.nut'...done.
Running nut 'sd:/Projects/DateTime/date_time_v1.nut'.
System time: 2015-12-14T11:43:02-06 <--- system("time") should be 2016-01-19...
Unix timestamp= 1450114982
Local time(CST):
12-14-2015 T 11:43:2
Dec-14-2015 T 11:43:2

Running nut 'sd:/Projects/DateTime/date_time_v1.nut'.
System time: 2015-12-14T11:43:15-06
Unix timestamp= 1450114995
Local time(CST):
12-14-2015 T 11:43:15
Dec-14-2015 T 11:43:15

Running nut 'sd:/Projects/DateTime/date_time_v1.nut'.
System time: 2015-12-14T11:43:25-06
Unix timestamp= 1450115005
Local time(CST):
12-14-2015 T 11:43:25
Dec-14-2015 T 11:43:25

Powered down Esquilo for 1 minute, restarted board and reran date/time code

Running nut 'sd:/Projects/DateTime/date_time_v1.nut'.
System time: 2015-12-14T09:22:47-06 <--- Going back in time
Unix timestamp= 1450106567
Local time(CST):
12-14-2015 T 9:22:47
Dec-14-2015 T 9:22:47

Running nut 'sd:/Projects/DateTime/date_time_v1.nut'.
System time: 2015-12-14T09:26:20-06 <----- 4 minutes later
Unix timestamp= 1450106780
Local time(CST):
12-14-2015 T 9:26:20
Dec-14-2015 T 9:26:20

system("log")
2015-12-14T15:22:36Z INFO Esquilo Operating System (EOS)
2015-12-14T15:22:36Z INFO for Esquilo Air
2015-12-14T15:22:36Z INFO Version 0.4
2015-12-14T15:22:36Z INFO Copyright (c) 2014-2015 Esquilo Corp.
2015-12-14T15:22:36Z INFO Starting USB CDC
2015-12-14T15:22:36Z INFO Initializing WICED
2015-12-14T15:22:36Z INFO Starting Wiced
2015-12-14T15:22:37Z INFO WLAN MAC Address: 00:0B:6C:42:1B:96
2015-12-14T15:22:37Z INFO WLAN Firmware: wl0: Nov 7 2014 16:03:45 version 5.90.230.12 FWID 01-653405d4
2015-12-14T15

On a Macbook Air:
sudo ntpdate -u sntp.esquilo.io

19 Jan 19:57:59 ntpdate[776]: adjust time server 104.131.44.56 offset 0.059220 sec

system("eos task")
Task Name Task # Stack Prio State Error


USB CDC 1 1200 10 LWEVENT_BLOCKED TIMEOUT 0x00000000
Idle Task 2 224 15 READY 0x00000000
Main 3 1500 12 BLOCKED 0x00000000
WICED Worker 4 1500 10 LWMSGQ_READ_BLOCKED 0x00000000
WICED 5 1500 9 LWSEM_BLOCKED

gwittie

Sorry for the bold text. Your editor did that for some reason. I am not yelling at you...

Scott_Shumate

Esquilo does not have a battery so you'll lose the clock every time you power off and the time will revert back to the software build time. The solution for this is to run SNTP on Esquilo to set the clock from a network time server. It should be enabled by default. You can check in the Network Services menu in the IDE. Make sure SNTP is enabled and that you have a valid SNTP server. By default, it is set to sntp.esquilo.io which is our own server.

gwittie

I did check that and my system has your SNTP server name and the checkbox was checked to enable this function. Is there another way to check the server connection?

gwittie

I just found the SNTP query commands in the EOS Shell docs. I'll try them tonight.

gwittie

I have tried the netcfg commands from the EOS Shell docs and could not get the SNTP server to respond.
Everything looks like it should be able to query the SNTP server and get the current date/time, but it does not work. Is there anything else to try? I do not want to revert to a RTC board to get this functionality.

Here is the output of the nut that contains the commands.

Running nut 'sd:/Projects/DateTime/date_time_v1.nut'.
System time: 2015-12-14T09:23:43-06
SNTP start is enabled
SNTP Server : sntp.esquilo.io
Unable to query SNTP server
Hostname : esquilo_421b96
DNS Address : 0.0.0.0
FTPD start : disabled
HTTPD start : enabled
HTTPD auth : disabled
HTTPD index : /index.html
SNTP start : enabled
SNTP server : sntp.esquilo.io
Telnetd start : disabled
ESTP start : enabled
ESTP peer : estp.esquilo.io
ESTP status : down
Unix timestamp= 1450106623
Local time(CST):
12-14-2015 T 9:23:43

Here is my nut code...
//
// Date/Time Demo
//
require(["system","Netcfg"]);
// Define month string array for storing month names
local monthStr = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]

print("System time: ");
system("time");

system("netcfg sntp start");
system("netcfg sntp server");

system("netcfg sntp query sntp.esquilo.io");

system("netcfg status");

// system("time set 2016-01-16T15:05:00")
//print("\n");

// Get the current local date/time
t <- date(time(), 'l');
print("Unix timestamp= "+time()+"\n");

// Print the date + time
// Note: month value starts at 0 instead of 1 - Squirrel issue
print("Local time(CST):" + "\n");

print((t.month+1) + "-" + t.day + "-" + t.year + " T ");
print(t.hour + ":" + t.min + ":" + t.sec + "\n");

print(monthStr[t.month] + "-" + t.day + "-" + t.year + " T ");

Scott_Shumate

Based on this line:

DNS Address : 0.0.0.0

You don't seem to have a DNS server configured. Usually, this is passed in to Esquilo from your DHCP server. You could configure one manually. Google's public DNS works well at 8.8.8.8. system("net dns server 8.8.8.8"). Alternatively you could use the IP address instead of the DNS name for our SNTP server which is 104.131.44.56.

gwittie

Thanks. The DNS server was the issue.

This problem was a result of moving to manual IP number setup to get a predictable IP number rather than with DHCP. I was tired of getting different IP numbers over time. In my manual setup, I missed getting the DNS server number from my router to put in the EOS setup. The date/time value is reading correctly now.