# Network time and rtc

**URL:** <https://forum.legato.io/t/network-time-and-rtc/3429>\
**Category:** Uncategorized\
**Created:** [July 10, 2018, 5:19pm UTC](https://forum.legato.io/t/network-time-and-rtc/3429 "2018-07-10T17:19:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![subrahmaniam](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@subrahmaniam](https://forum.legato.io/u/subrahmaniam)\
**Post date:** [July 10, 2018, 5:19pm UTC](https://forum.legato.io/t/network-time-and-rtc/3429/1 "2018-07-10T17:19:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lotam](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lotam](https://forum.legato.io/u/lotam)\
**Post date:** [July 13, 2018, 10:00am UTC](https://forum.legato.io/t/network-time-and-rtc/3429/2 "2018-07-13T10:00:59Z")

</div>

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](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](http://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

---

<div class="post-metadata">

**Author:** ![subrahmaniam](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@subrahmaniam](https://forum.legato.io/u/subrahmaniam)\
**Post date:** [July 13, 2018, 7:15pm UTC](https://forum.legato.io/t/network-time-and-rtc/3429/3 "2018-07-13T19:15:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lotam](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lotam](https://forum.legato.io/u/lotam)\
**Post date:** [July 14, 2018, 12:37pm UTC](https://forum.legato.io/t/network-time-and-rtc/3429/4 "2018-07-14T12:37:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![subrahmaniam](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@subrahmaniam](https://forum.legato.io/u/subrahmaniam)\
**Post date:** [July 15, 2018, 6:00pm UTC](https://forum.legato.io/t/network-time-and-rtc/3429/5 "2018-07-15T18:00:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lotam](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lotam](https://forum.legato.io/u/lotam)\
**Post date:** [July 16, 2018, 1:17am UTC](https://forum.legato.io/t/network-time-and-rtc/3429/6 "2018-07-16T01:17:52Z")

</div>

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
