Network time and rtc


#1

Hi,
I am using 16.07 version legato developer studio my board is also suppoting that . I want to write program for getting time from network and store it into rtc . le_rtc.h and pa_rtc.h files could not be resoled. so please tell me how to get network updated time and how to store in rtc.
Thanks and regards,
K Subrahmaniam


#2

Hi subrahmaniam,

Per understanding, if you want to do all in your application, you need to develop according to NTP protocol (i.e. RFC-1305, RFC-5905).

In latest Legato release, le_data_GetDate() and le_data_GetTime() is introduced for NTP support to ease development.
https://docs.legato.io/latest/c_le_data.html#c_le_data_time

But for your case using 16.07, I think the easiest way is to use Linux script or call those Linux tool in your app.

You may refer to my test below:

root@swi-mdm9x15:~# cm data connect 30&
root@swi-mdm9x15:~# Connected through interface ‘rmnet0’

root@swi-mdm9x15:~# ntpd -p pool.ntp.org
root@swi-mdm9x15:~# date
Fri Jul 13 09:50:43 UTC 2018
root@swi-mdm9x15:~# cm rtc set “$(date +’%d %b %Y %H:%M:%S’)”
root@swi-mdm9x15:~# cm rtc
13 Jul 2018 09:50:58
root@swi-mdm9x15:~#

Hope it help.
Thx


FX30 for site survey coverage
#3

Hi lotam ,
Thank you , I used Linux command date %T “…” It works but when power off and on it is not saved rtc .
What is the function to call commands in program guide me if any
Thanks and regards,
K subrahmaniam


#4

Have you check “cm rtc” and correct time is set?

Also which WP and MangOH board you are using?

In my case the time is correct after power cut, test using WP750x on MangOH green.


#5

Thank you,

i used cm rtc also .

should i do any hardware changes i am changing 750x on mangoH green.

and I mounted sd card as told in the forum mount -ofmask=0111 … . sd card is mounted and by using touch command i am able to create a txt file in /etc/sd . im using fopen("/etc/sd/test.txt,“w”) in code . it shows file creation error. and i used system(“touch /etc/sd/test.txt”) even though i could not create file in /etc/sd/. in command line i am able to create by touch command. what is wrong in program . ls_file.h did not work becuase it 16.07.

thanks and regards,

K Subrahmaniam


#6

Hi Subrahmaniam,

For network time and rtc, please share your test log.

For file creation issue, best you can submit a new post with your code snippet to follow.

Thx