LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   setting system time from embedded application (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/setting-system-time-from-embedded-application-758360/)

grinderr 09-28-2009 10:43 PM

setting system time from embedded application
 
I need to be able to set the system time from with in my embedded application. I am writing an app using Sourcery_G++ with the target being an phytec 3250 ARM9 running embedded Linux kernel 2.6.26. I know that I can set the system time from the command prompt using "date 092819402009" but what is the similar function calls from within an application?

thanks

Matir 09-29-2009 06:00 PM

Look at stime(2).

grinderr 10-06-2009 09:22 AM

setting system time
 
I tried using mktime() to set the system time from my embedded application, but it doesnt persist. I also have looked at stime(2), but from the documentation it doesnt appear that is the right way to go. I was looking at sys_clock_settime(), can anyone tell me about the usage of this routine from an embedded application?

thanks

Matir 10-06-2009 05:58 PM

mktime() sets the operating system time. sys_clock_settime() allows the setting of an in-kernel clock, but it still won't set the hardware time. For hardware time, you need to look at something like hwclock.


All times are GMT -5. The time now is 05:52 AM.